install.sh
changeset 760 b678a1c43027
parent 748 659c4476c57c
child 761 e4e656f19771
equal deleted inserted replaced
748:659c4476c57c 760:b678a1c43027
     1 #!/bin/sh
       
     2 #
       
     3 # Installation script for the Virtual Mail Manager
       
     4 # run: ./install.sh
       
     5 
       
     6 LANG=C
       
     7 PATH=/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
       
     8 PREFIX=/usr/local
       
     9 
       
    10 PF_CONFDIR=$(postconf -h config_directory)
       
    11 PF_GID=$(id -g $(postconf -h mail_owner))
       
    12 LOCALE_DIR=${PREFIX}/share/locale
       
    13 DOC_DIR=${PREFIX}/share/doc/vmm
       
    14 if [ ${PREFIX} = "/usr" ]; then
       
    15     MANDIR=${PREFIX}/share/man
       
    16     SYSCONFDIR=/etc
       
    17 else
       
    18     MANDIR=${PREFIX}/man
       
    19     SYSCONFDIR=${PREFIX}/etc
       
    20 fi
       
    21 DOCS="ChangeLog Configure.Dovecot_2 COPYING INSTALL NEWS README"
       
    22 
       
    23 INSTALL_OPTS="-g 0 -o 0 -p"
       
    24 INSTALL_OPTS_CF="-b -m 0640 -g ${PF_GID} -o 0 -p"
       
    25 
       
    26 if [ $(id -u) -ne 0 ]; then
       
    27     echo "Run this script as root."
       
    28     exit 1
       
    29 fi
       
    30 
       
    31 python setup.py -q install --force --prefix ${PREFIX}
       
    32 python setup.py clean --all >/dev/null
       
    33 
       
    34 [ -d ${SYSCONFDIR} ] || mkdir -m 0755 -p ${SYSCONFDIR}
       
    35 install -b -m 0600 ${INSTALL_OPTS} vmm.cfg ${SYSCONFDIR}/
       
    36 install ${INSTALL_OPTS_CF} postfix/pgsql-*.cf ${PF_CONFDIR}/
       
    37 install -m 0700 ${INSTALL_OPTS} vmm ${PREFIX}/sbin
       
    38 
       
    39 [ -d ${LOCALE_DIR} ] || mkdir -m 0755 -p ${LOCALE_DIR}
       
    40 cd po
       
    41 for po in $(ls -1 *.po); do
       
    42     lang=$(basename ${po} .po)
       
    43     ddir=${LOCALE_DIR}/${lang}/LC_MESSAGES
       
    44     [ -d ${ddir}  ] || mkdir -m 0755 -p ${ddir}
       
    45     msgfmt -o ${LOCALE_DIR}/${lang}/LC_MESSAGES/vmm.mo ${po}
       
    46 done
       
    47 cd - >/dev/null
       
    48 
       
    49 cd man
       
    50 [ -d ${MANDIR}/man1 ] || mkdir -m 0755 -p ${MANDIR}/man1
       
    51 install -m 0644 ${INSTALL_OPTS} man1/vmm.1 ${MANDIR}/man1
       
    52 
       
    53 [ -d ${MANDIR}/man5 ] || mkdir -m 0755 -p ${MANDIR}/man5
       
    54 install -m 0644 ${INSTALL_OPTS} man5/vmm.cfg.5 ${MANDIR}/man5
       
    55 
       
    56 for l in $(find . -maxdepth 1 -mindepth 1 -type d \! -name man\?)
       
    57 do
       
    58     for s in man1 man5; do
       
    59         [ -d ${MANDIR}/${l}/${s} ] || mkdir -m 0755 -p ${MANDIR}/${l}/${s}
       
    60     done
       
    61     if [ -f ${l}/man1/vmm.1 ]; then
       
    62         install -m 0644 ${INSTALL_OPTS} ${l}/man1/vmm.1 ${MANDIR}/${l}/man1
       
    63     fi
       
    64     if [ -f ${l}/man5/vmm.cfg.5 ]; then
       
    65         install -m 0644 ${INSTALL_OPTS} ${l}/man5/vmm.cfg.5 ${MANDIR}/${l}/man5
       
    66     fi
       
    67 done
       
    68 cd - >/dev/null
       
    69 
       
    70 [ -d ${DOC_DIR} ] || mkdir -m 0755 -p ${DOC_DIR}
       
    71 for DOC in ${DOCS}; do
       
    72     install -m 0644 ${INSTALL_OPTS} ${DOC} ${DOC_DIR}
       
    73 done
       
    74 
       
    75 [ -d ${DOC_DIR}/examples ] || mkdir -m 0755 -p ${DOC_DIR}/examples
       
    76 install -m 0644 ${INSTALL_OPTS} postfix/pgsql-*.cf ${DOC_DIR}/examples
       
    77 install -m 0644 ${INSTALL_OPTS} vmm.cfg ${DOC_DIR}/examples
       
    78 
       
    79 echo
       
    80 echo "Don't forget to edit ${PREFIX}/etc/vmm.cfg - or run: vmm cf"
       
    81 echo "and ${PF_CONFDIR}/pgsql-*.cf files."
       
    82 echo