upgrade.sh
changeset 571 a4aead244f75
parent 562 b5bb7b34e831
child 680 5365af94a8ec
equal deleted inserted replaced
465:c0e1fb1b0145 571:a4aead244f75
     5 
     5 
     6 LANG=C
     6 LANG=C
     7 PATH=/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
     7 PATH=/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
     8 PREFIX=/usr/local
     8 PREFIX=/usr/local
     9 
     9 
    10 PF_CONFDIR=$(postconf -h config_directory)
    10 DOVECOT_VERS=$(dovecot --version | awk '{print $1}')
    11 PF_GID=$(id -g $(postconf -h mail_owner))
       
    12 POSTCONF=$(which postconf)
       
    13 DOVECOT_VERS=$(dovecot --version | awk -F . '{print $1 $2}')
       
    14 LOCALE_DIR=${PREFIX}/share/locale
    11 LOCALE_DIR=${PREFIX}/share/locale
    15 DOC_DIR=${PREFIX}/share/doc/vmm
    12 DOC_DIR=${PREFIX}/share/doc/vmm
    16 if [ ${PREFIX} = "/usr" ]; then
    13 if [ ${PREFIX} = "/usr" ]; then
    17     MANDIR=${PREFIX}/share/man
    14     MANDIR=${PREFIX}/share/man
    18 else
    15 else
    19     MANDIR=${PREFIX}/man
    16     MANDIR=${PREFIX}/man
    20 fi
    17 fi
    21 DOCS="ChangeLog COPYING NEWS INSTALL README"
    18 DOCS="ChangeLog Configure.Dovecot_2 COPYING INSTALL NEWS README"
    22 
    19 
    23 INSTALL_OPTS="-g 0 -o 0 -p"
    20 INSTALL_OPTS="-g 0 -o 0 -p"
    24 INSTALL_OPTS_CF="-b -m 0640 -g ${PF_GID} -o 0 -p"
       
    25 
    21 
    26 if [ $(id -u) -ne 0 ]; then
    22 if [ $(id -u) -ne 0 ]; then
    27     echo "Run this script as root."
    23     echo "Run this script as root."
    28     exit 1
    24     exit 1
    29 fi
    25 fi
    30 
    26 
    31 # update config file before installing the new files.
    27 # update config file before installing the new files.
    32 ./update_config_0.4.x-0.5.py ${POSTCONF} ${DOVECOT_VERS:-10}
    28 ./update_config.py ${DOVECOT_VERS:-'1.2.11'}
    33 rv=$?
    29 rv=$?
    34 if [ $rv -eq 2 ]; then
    30 if [ $rv -eq 2 ]; then
    35 	echo "please run the install.sh script"
    31 	echo "please run the install.sh script"
    36 	exit 1
    32 	exit 1
    37 elif [ $rv -eq 3 ]; then
    33 elif [ $rv -eq 3 ]; then
    38     echo "please read the upgrade instructions at http://vmm.localdomain.org/"
    34     echo "please read the upgrade instructions at http://vmm.localdomain.org/"
    39     exit 1
    35     exit 1
    40 elif [ $rv -ne 0 ]; then
    36 elif [ $rv -ne 0 ]; then
    41     echo "Sorry, something went wrong. Please file a bug:"
    37     echo "Sorry, something went wrong. Please file a bug at:"
    42     echo "https://sourceforge.net/tracker/?group_id=213727"
    38     echo "https://bitbucket.org/pvo/vmm/issues"
    43     exit 1
    39     exit 1
    44 fi
    40 fi
    45 
    41 
    46 python setup.py -q install --prefix ${PREFIX}
    42 # remove old CamelCase files
       
    43 if [ -f /tmp/vmm_inst_dir ] ; then
       
    44     rm -rf `cat /tmp/vmm_inst_dir`
       
    45     rm -f /tmp/vmm_inst_dir
       
    46 fi
       
    47 
       
    48 python setup.py -q install --force --prefix ${PREFIX}
    47 python setup.py clean --all >/dev/null
    49 python setup.py clean --all >/dev/null
    48 
    50 
    49 install -m 0700 ${INSTALL_OPTS} vmm ${PREFIX}/sbin
    51 install -m 0700 ${INSTALL_OPTS} vmm ${PREFIX}/sbin
    50 
    52 
    51 [ -d ${LOCALE_DIR} ] || mkdir -m 0755 -p ${LOCALE_DIR}
    53 [ -d ${LOCALE_DIR} ] || mkdir -m 0755 -p ${LOCALE_DIR}
    56     [ -d ${ddir}  ] || mkdir -m 0755 -p ${ddir}
    58     [ -d ${ddir}  ] || mkdir -m 0755 -p ${ddir}
    57     msgfmt -o ${LOCALE_DIR}/${lang}/LC_MESSAGES/vmm.mo ${po}
    59     msgfmt -o ${LOCALE_DIR}/${lang}/LC_MESSAGES/vmm.mo ${po}
    58 done
    60 done
    59 cd - >/dev/null
    61 cd - >/dev/null
    60 
    62 
    61 # remove misplaced manual pages
       
    62 if [ -f /usr/local/share/man/man1/vmm.1 ]; then
       
    63     rm -f /usr/local/share/man/man1/vmm.1
       
    64 fi
       
    65 if [ -f /usr/local/share/man/man5/vmm.cfg.5 ]; then
       
    66     rm -f /usr/local/share/man/man5/vmm.cfg.5
       
    67 fi
       
    68 
       
    69 # install manual pages
    63 # install manual pages
    70 cd man
    64 cd man
    71 [ -d ${MANDIR}/man1 ] || mkdir -m 0755 -p ${MANDIR}/man1
    65 [ -d ${MANDIR}/man1 ] || mkdir -m 0755 -p ${MANDIR}/man1
    72 install -m 0644 ${INSTALL_OPTS} man1/vmm.1 ${MANDIR}/man1
    66 install -m 0644 ${INSTALL_OPTS} man1/vmm.1 ${MANDIR}/man1
    73 
    67 
    74 [ -d ${MANDIR}/man5 ] || mkdir -m 0755 -p ${MANDIR}/man5
    68 [ -d ${MANDIR}/man5 ] || mkdir -m 0755 -p ${MANDIR}/man5
    75 install -m 0644 ${INSTALL_OPTS} man5/vmm.cfg.5 ${MANDIR}/man5
    69 install -m 0644 ${INSTALL_OPTS} man5/vmm.cfg.5 ${MANDIR}/man5
    76 
    70 
    77 for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\? \! -name .svn)
    71 for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\?)
    78 do
    72 do
    79     for s in man1 man5; do
    73     for s in man1 man5; do
    80         [ -d ${MANDIR}/${l}/${s} ] || mkdir -m 0755 -p ${MANDIR}/${l}/${s}
    74         [ -d ${MANDIR}/${l}/${s} ] || mkdir -m 0755 -p ${MANDIR}/${l}/${s}
    81     done
    75     done
    82     if [ -f ${l}/man1/vmm.1 ]; then
    76     if [ -f ${l}/man1/vmm.1 ]; then