Merge tag 'upstream/3.3.2'
[debian/amanda] / packaging / deb / amanda-backup-client.postinst
index c28fc4c57704a31020f9e4f2f995f88f51a3560b..5d6cb34a985b04e86e6a2df84364c41cf58f1961 100644 (file)
@@ -1,104 +1,5 @@
 #!/bin/sh
-
-SYSCONFDIR="/etc"
-LOCALSTATEDIR="/var"
-LOGDIR="${LOCALSTATEDIR}/log/amanda/"
-AMANDAHOMEDIR="${LOCALSTATEDIR}/lib/amanda"
-amanda_user=amandabackup
-amanda_group=disk
-xinetd_reload="restart"
-
-
-# Installing xinetd config and make it active.
-if [ -e /etc/xinetd.d ] && [ -d /etc/xinetd.d ] ; then
-       if [ ! -f /etc/xinetd.d/amandaclient ] ; then
-               cp ${AMANDAHOMEDIR}/example/xinetd.amandaclient /etc/xinetd.d/amandaclient || exit 1
-               echo -n "`date +'%b %e %Y %T'`: Reloading xinetd configuration..." 
-               if [ "${xinetd_reload}" = "reload" ] ; then
-                       /usr/sbin/invoke-rc.d xinetd ${xinetd_reload} # don't exit yet...
-                       if [ $? -ne 0 ] ; then
-                               echo -n "reload failed.  Attempting restart..." 
-                               /usr/sbin/invoke-rc.d xinetd restart || exit 1
-                       fi
-               else
-                       /usr/sbin/invoke-rc.d xinetd ${xinetd_reload} || exit 1
-               fi
-       fi
-fi
-
-echo "`date +'%b %e %Y %T'`: Installing '${LOCALSTATEDIR}/amanda/amandates'." 
-if [ ! -f ${LOCALSTATEDIR}/amanda/amandates ] ; then
-       touch ${LOCALSTATEDIR}/amanda/amandates || exit 1
-fi
-echo "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${LOCALSTATEDIR}/amanda/amandates'." 
-chown ${amanda_user}:${amanda_group} ${LOCALSTATEDIR}/amanda/amandates || exit 1
-chmod 0640 ${LOCALSTATEDIR}/amanda/amandates || exit 1
-if [ -x /sbin/restorecon ] ; then
-      /sbin/restorecon ${LOCALSTATEDIR}/amanda/amandates  || exit 1
-fi
-
-# Install .amandahosts to client
-echo "`date +'%b %e %Y %T'`: Checking '${AMANDAHOMEDIR}/.amandahosts' file." 
-if [ ! -f ${AMANDAHOMEDIR}/.amandahosts ] ; then
-       touch ${AMANDAHOMEDIR}/.amandahosts || exit 1
-fi
-for host in localhost localhost.localdomain ; do
-               if [ -z "`grep \"^${host}[[:blank:]]\+${amanda_user}[[:blank:]]\+amdump\" ${AMANDAHOMEDIR}/.amandahosts`" ] ; then
-                       echo "${host} ${amanda_user} amdump" >> "${AMANDAHOMEDIR}/.amandahosts" || exit 1
-               fi
-done
-chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.amandahosts || exit 1
-chmod 0600 ${AMANDAHOMEDIR}/.amandahosts || exit 1
-
-# Install amanda client configuration file
-echo "`date +'%b %e %Y %T'`: Checking '${SYSCONFDIR}/amanda/amanda-client.conf' file." 
-if [ ! -f ${SYSCONFDIR}/amanda/amanda-client.conf ] ; then
-       cp ${AMANDAHOMEDIR}/example/amanda-client.conf ${SYSCONFDIR}/amanda/amanda-client.conf || exit 1
-fi
-chown ${amanda_user}:${amanda_group} ${SYSCONFDIR}/amanda/amanda-client.conf || exit 1
-chmod 0600 ${SYSCONFDIR}/amanda/amanda-client.conf || exit 1
-
-# Install .gnupg directory
-echo "`date +'%b %e %Y %T'`: Installing '${AMANDAHOMEDIR}/.gnupg'." 
-if [ ! -d ${AMANDAHOMEDIR}/.gnupg ] ; then
-       echo "`date +'%b %e %Y %T'`: '${AMANDAHOMEDIR}/.gnupg' will be created." 
-       mkdir ${AMANDAHOMEDIR}/.gnupg || exit 1
-fi
-echo "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${AMANDAHOMEDIR}/.gnupg'." 
-chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.gnupg || exit 1
-chmod 700 ${AMANDAHOMEDIR}/.gnupg || exit 1
-
-# SSH RSA key generation on client for amrecover
-KEYDIR="${AMANDAHOMEDIR}/.ssh"
-KEYFILE="id_rsa_amrecover"
-COMMENT="root@client"
-if [ ! -d ${KEYDIR} ] ; then
-       if [ -f ${KEYDIR} ] ; then
-               echo "`date +'%b %e %Y %T'`: Directory '${KEYDIR}' exists as a file.  Renaming to '${KEYDIR}.save'." 
-               mv ${KEYDIR} ${KEYDIR}.save || exit 1
-       fi
-       echo "`date +'%b %e %Y %T'`: Creating directory '${KEYDIR}'." 
-       mkdir ${KEYDIR} || exit 1
-fi
-if [ ! -f ${KEYDIR}/${KEYFILE} ] ; then
-       echo "`date +'%b %e %Y %T'`: Creating ssh RSA key in '${KEYDIR}/${KEYFILE}'" 
-       ssh-keygen -q -C $COMMENT -t rsa -f ${KEYDIR}/${KEYFILE} -N '' || exit 1
-fi
-echo "`date +'%b %e %Y %T'`: Setting permissions for '${KEYDIR}' and '${KEYDIR}/${KEYFILE}*'" 
-chown ${amanda_user}:${amanda_group} ${KEYDIR} || exit 1
-chmod 0750 ${KEYDIR} || exit 1
-chmod 0600 ${KEYDIR}/${KEYFILE}* || exit 1
-
-# environment variables (~amandabackup/.profile)
-echo "`date +'%b %e %Y %T'`: Checking for '${AMANDAHOMEDIR}/.profile' and ensuring correct environment." 
-if [ ! -f ${AMANDAHOMEDIR}/.profile ] ; then
-       touch ${AMANDAHOMEDIR}/.profile || exit 1
-fi
-if [ -z "`grep PATH ${AMANDAHOMEDIR}/.profile | grep '/usr/sbin'`" ] ; then
-       echo "export PATH=\"\$PATH:/usr/sbin/\"" >> "${AMANDAHOMEDIR}/.profile" || exit 1
-fi
-echo "`date +'%b %e %Y %T'`: Setting ownership and permissions for '${AMANDAHOMEDIR}/.profile'" 
-chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.profile || exit 1
-chmod 0640 ${AMANDAHOMEDIR}/.profile || exit 1
-
-echo "`date +'%b %e %Y %T'`: === Amanda backup client installation complete. ===" 
+# Debian recommends this.  Script exits on simple command failure.
+# set -e
+pkg_type=client
+other_pkg_type=server