5 LOGDIR="${LOCALSTATEDIR}/log/amanda/"
6 AMANDAHOMEDIR="${LOCALSTATEDIR}/lib/amanda"
7 amanda_user=amandabackup
9 xinetd_reload="restart"
12 # Installing xinetd config and make it active.
13 if [ -e /etc/xinetd.d ] && [ -d /etc/xinetd.d ] ; then
14 if [ ! -f /etc/xinetd.d/amandaclient ] ; then
15 cp ${AMANDAHOMEDIR}/example/xinetd.amandaclient /etc/xinetd.d/amandaclient || exit 1
16 echo -n "`date +'%b %e %Y %T'`: Reloading xinetd configuration..."
17 if [ "${xinetd_reload}" = "reload" ] ; then
18 /usr/sbin/invoke-rc.d xinetd ${xinetd_reload} # don't exit yet...
19 if [ $? -ne 0 ] ; then
20 echo -n "reload failed. Attempting restart..."
21 /usr/sbin/invoke-rc.d xinetd restart || exit 1
24 /usr/sbin/invoke-rc.d xinetd ${xinetd_reload} || exit 1
29 echo "`date +'%b %e %Y %T'`: Installing '${LOCALSTATEDIR}/amanda/amandates'."
30 if [ ! -f ${LOCALSTATEDIR}/amanda/amandates ] ; then
31 touch ${LOCALSTATEDIR}/amanda/amandates || exit 1
33 echo "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${LOCALSTATEDIR}/amanda/amandates'."
34 chown ${amanda_user}:${amanda_group} ${LOCALSTATEDIR}/amanda/amandates || exit 1
35 chmod 0640 ${LOCALSTATEDIR}/amanda/amandates || exit 1
36 if [ -x /sbin/restorecon ] ; then
37 /sbin/restorecon ${LOCALSTATEDIR}/amanda/amandates || exit 1
40 # Install .amandahosts to client
41 echo "`date +'%b %e %Y %T'`: Checking '${AMANDAHOMEDIR}/.amandahosts' file."
42 if [ ! -f ${AMANDAHOMEDIR}/.amandahosts ] ; then
43 touch ${AMANDAHOMEDIR}/.amandahosts || exit 1
45 for host in localhost localhost.localdomain ; do
46 if [ -z "`grep \"^${host}[[:blank:]]\+${amanda_user}[[:blank:]]\+amdump\" ${AMANDAHOMEDIR}/.amandahosts`" ] ; then
47 echo "${host} ${amanda_user} amdump" >> "${AMANDAHOMEDIR}/.amandahosts" || exit 1
50 chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.amandahosts || exit 1
51 chmod 0600 ${AMANDAHOMEDIR}/.amandahosts || exit 1
53 # Install amanda client configuration file
54 echo "`date +'%b %e %Y %T'`: Checking '${SYSCONFDIR}/amanda/amanda-client.conf' file."
55 if [ ! -f ${SYSCONFDIR}/amanda/amanda-client.conf ] ; then
56 cp ${AMANDAHOMEDIR}/example/amanda-client.conf ${SYSCONFDIR}/amanda/amanda-client.conf || exit 1
58 chown ${amanda_user}:${amanda_group} ${SYSCONFDIR}/amanda/amanda-client.conf || exit 1
59 chmod 0600 ${SYSCONFDIR}/amanda/amanda-client.conf || exit 1
61 # Install .gnupg directory
62 echo "`date +'%b %e %Y %T'`: Installing '${AMANDAHOMEDIR}/.gnupg'."
63 if [ ! -d ${AMANDAHOMEDIR}/.gnupg ] ; then
64 echo "`date +'%b %e %Y %T'`: '${AMANDAHOMEDIR}/.gnupg' will be created."
65 mkdir ${AMANDAHOMEDIR}/.gnupg || exit 1
67 echo "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${AMANDAHOMEDIR}/.gnupg'."
68 chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.gnupg || exit 1
69 chmod 700 ${AMANDAHOMEDIR}/.gnupg || exit 1
71 # SSH RSA key generation on client for amrecover
72 KEYDIR="${AMANDAHOMEDIR}/.ssh"
73 KEYFILE="id_rsa_amrecover"
75 if [ ! -d ${KEYDIR} ] ; then
76 if [ -f ${KEYDIR} ] ; then
77 echo "`date +'%b %e %Y %T'`: Directory '${KEYDIR}' exists as a file. Renaming to '${KEYDIR}.save'."
78 mv ${KEYDIR} ${KEYDIR}.save || exit 1
80 echo "`date +'%b %e %Y %T'`: Creating directory '${KEYDIR}'."
81 mkdir ${KEYDIR} || exit 1
83 if [ ! -f ${KEYDIR}/${KEYFILE} ] ; then
84 echo "`date +'%b %e %Y %T'`: Creating ssh RSA key in '${KEYDIR}/${KEYFILE}'"
85 ssh-keygen -q -C $COMMENT -t rsa -f ${KEYDIR}/${KEYFILE} -N '' || exit 1
87 echo "`date +'%b %e %Y %T'`: Setting permissions for '${KEYDIR}' and '${KEYDIR}/${KEYFILE}*'"
88 chown ${amanda_user}:${amanda_group} ${KEYDIR} || exit 1
89 chmod 0750 ${KEYDIR} || exit 1
90 chmod 0600 ${KEYDIR}/${KEYFILE}* || exit 1
92 # environment variables (~amandabackup/.profile)
93 echo "`date +'%b %e %Y %T'`: Checking for '${AMANDAHOMEDIR}/.profile' and ensuring correct environment."
94 if [ ! -f ${AMANDAHOMEDIR}/.profile ] ; then
95 touch ${AMANDAHOMEDIR}/.profile || exit 1
97 if [ -z "`grep PATH ${AMANDAHOMEDIR}/.profile | grep '/usr/sbin'`" ] ; then
98 echo "export PATH=\"\$PATH:/usr/sbin/\"" >> "${AMANDAHOMEDIR}/.profile" || exit 1
100 echo "`date +'%b %e %Y %T'`: Setting ownership and permissions for '${AMANDAHOMEDIR}/.profile'"
101 chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.profile || exit 1
102 chmod 0640 ${AMANDAHOMEDIR}/.profile || exit 1
104 echo "`date +'%b %e %Y %T'`: === Amanda backup client installation complete. ==="