2 # Debian recommends this. Script exits on simple command failure.
4 LOGDIR="/var/log/amanda/"
7 AMHOMEDIR="${LOCALSTATEDIR}/lib/amanda"
8 amanda_user=amandabackup
10 xinetd_reload="restart"
12 if [ -d /etc/xinetd.d ] ; then
13 if [ ! -f /etc/xinetd.d/amandaserver ] ; then
14 cp ${AMHOMEDIR}/example/xinetd.amandaserver /etc/xinetd.d/amandaserver || exit 1
15 chmod 0644 /etc/xinetd.d/amandaserver || exit 1
16 if [ -f /etc/xinetd.d/amandaclient ] ; then
17 rm /etc/xinetd.d/amandaclient || exit 1
19 echo -n "`date +'%b %e %Y %T'`: Reloading xinetd configuration..."
20 if [ "${xinetd_reload}" = "reload" ] ; then
21 /usr/sbin/invoke-rc.d xinetd ${xinetd_reload} # don't exit yet!
22 if [ $? -ne 0 ] ; then
23 echo -n "reload failed. Attempting restart..."
24 /usr/sbin/invoke-rc.d xinetd restart || exit 1
27 /usr/sbin/invoke-rc.d xinetd ${xinetd_reload} || exit 1
32 echo "`date +'%b %e %Y %T'`: Installing '${LOCALSTATEDIR}/amanda/amandates'."
33 if [ ! -f ${LOCALSTATEDIR}/amanda/amandates ] ; then
34 touch ${LOCALSTATEDIR}/amanda/amandates || exit 1
36 if [ ${ret_val} -eq 0 ]; then
37 echo "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${LOCALSTATEDIR}/amanda/amandates'."
38 chown ${amanda_user}:${amanda_group} ${LOCALSTATEDIR}/amanda/amandates || exit 1
39 chmod 0640 ${LOCALSTATEDIR}/amanda/amandates || exit 1
40 if [ -x /sbin/restorecon ] ; then
41 /sbin/restorecon ${LOCALSTATEDIR}/amanda/amandates || exit 1
45 # Install .gnupg directory
46 echo "`date +'%b %e %Y %T'`: Installing '${AMHOMEDIR}/.gnupg'."
47 if [ ! -d ${AMHOMEDIR}/.gnupg ] ; then
48 echo "`date +'%b %e %Y %T'`: '${AMHOMEDIR}/.gnupg' will be created."
49 mkdir ${AMHOMEDIR}/.gnupg || exit 1
51 echo "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${AMHOMEDIR}/.gnupg'."
52 chown ${amanda_user}:${amanda_group} ${AMHOMEDIR}/.gnupg || exit 1
53 chmod 700 ${AMHOMEDIR}/.gnupg || exit 1
55 # Install .amandahosts to server
56 echo "`date +'%b %e %Y %T'`: Checking '${AMHOMEDIR}/.amandahosts' file."
57 if [ ! -f ${AMHOMEDIR}/.amandahosts ] ; then
58 touch ${AMHOMEDIR}/.amandahosts || exit 1
60 for host in localhost localhost.localdomain ; do
61 if [ -z "`grep \"^${host}[[:blank:]]\+root[[:blank:]]\+amindexd[[:blank:]]\+amidxtaped\" ${AMHOMEDIR}/.amandahosts`" ] ; then
62 echo "${host} root amindexd amidxtaped" >>${AMHOMEDIR}/.amandahosts || exit 1
64 if [ -z "`grep \"^${host}[[:blank:]]\+${amanda_user}[[:blank:]]\+amdump\" ${AMHOMEDIR}/.amandahosts`" ] ; then
65 echo "${host} ${amanda_user} amdump" >>${AMHOMEDIR}/.amandahosts || exit 1
68 chown ${amanda_user}:${amanda_group} ${AMHOMEDIR}/.amandahosts || exit 1
69 chmod 0600 ${AMHOMEDIR}/.amandahosts || exit 1
71 # SSH RSA key generation for amdump
72 KEYDIR="${AMHOMEDIR}/.ssh"
73 KEYFILE="id_rsa_amdump"
74 COMMENT="${amanda_user}@server"
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 ownership and permissions for '${KEYDIR}' and '${KEYDIR}/${KEYFILE}*'"
88 chown ${amanda_user}:${amanda_group} ${KEYDIR} ${KEYDIR}/${KEYFILE}* || exit 1
89 chmod 0750 ${KEYDIR} || exit 1
90 chmod 0600 ${KEYDIR}/${KEYFILE}* || exit 1
92 # SSH RSA key generation on client for amrecover
93 KEYDIR="${AMHOMEDIR}/.ssh"
94 KEYFILE="id_rsa_amrecover"
96 if [ ! -d ${KEYDIR} ] ; then
97 if [ -f ${KEYDIR} ] ; then
98 echo "`date +'%b %e %Y %T'`: Directory '${KEYDIR}' exists as a file. Renaming to '${KEYDIR}.save'."
99 mv ${KEYDIR} ${KEYDIR}.save || exit 1
101 echo "`date +'%b %e %Y %T'`: Creating directory '${KEYDIR}'."
102 mkdir ${KEYDIR} || exit 1
104 if [ ! -f ${KEYDIR}/${KEYFILE} ] ; then
105 echo "`date +'%b %e %Y %T'`: Creating ssh RSA key in '${KEYDIR}/${KEYFILE}'"
106 ssh-keygen -q -C $COMMENT -t rsa -f ${KEYDIR}/${KEYFILE} -N '' || exit 1
108 echo "`date +'%b %e %Y %T'`: Setting permissions for '${KEYDIR}'"
109 chown ${amanda_user}:${amanda_group} ${KEYDIR} || exit 1
110 chmod 0750 ${KEYDIR} || exit 1
111 chmod 0600 ${KEYDIR}/${KEYFILE}* || exit 1
113 # environment variables (~amandabackup/.profile)
114 echo "`date +'%b %e %Y %T'`: Checking for '${AMHOMEDIR}/.profile' and ensuring correct environment."
115 if [ ! -f ${AMHOMEDIR}/.profile ] ; then
116 touch ${AMHOMEDIR}/.profile || exit 1
118 if [ -z "`grep PATH ${AMHOMEDIR}/.profile | grep '/usr/sbin'`" ] ; then
119 echo "export PATH=\"\$PATH:/usr/sbin/\"" >> "${AMHOMEDIR}/.profile" || exit 1
121 echo "`date +'%b %e %Y %T'`: Setting ownership and permissions for '${AMHOMEDIR}/.profile'"
122 chown ${amanda_user}:${amanda_group} ${AMHOMEDIR}/.profile || exit 1
123 chmod 0640 ${AMHOMEDIR}/.profile || exit 1
125 echo "`date +'%b %e %Y %T'`: === Amanda backup server installation complete. ==="