2 # Debian recommends this. Script exits on simple command failure.
4 LOGDIR="/var/log/amanda/"
7 AMHOMEDIR="${LOCALSTATEDIR}/lib/amanda"
9 amanda_user=amandabackup
11 xinetd_reload="restart"
13 if [ -d /etc/xinetd.d ] ; then
14 if [ ! -f /etc/xinetd.d/amandaserver ] ; then
15 cp ${AMHOMEDIR}/example/xinetd.amandaserver /etc/xinetd.d/amandaserver || exit 1
16 chmod 0644 /etc/xinetd.d/amandaserver || exit 1
17 if [ -f /etc/xinetd.d/amandaclient ] ; then
18 rm /etc/xinetd.d/amandaclient || exit 1
20 echo -n "`date +'%b %e %Y %T'`: Reloading xinetd configuration..."
21 if [ "${xinetd_reload}" = "reload" ] ; then
22 /usr/sbin/invoke-rc.d xinetd ${xinetd_reload} # don't exit yet!
23 if [ $? -ne 0 ] ; then
24 echo -n "reload failed. Attempting restart..."
25 /usr/sbin/invoke-rc.d xinetd restart || exit 1
28 /usr/sbin/invoke-rc.d xinetd ${xinetd_reload} || exit 1
33 echo "`date +'%b %e %Y %T'`: Installing '${LOCALSTATEDIR}/amanda/amandates'."
34 if [ ! -f ${LOCALSTATEDIR}/amanda/amandates ] ; then
35 touch ${LOCALSTATEDIR}/amanda/amandates || exit 1
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
44 # Check for existence of and permissions on ${AMTMP}
45 if [ ! -d ${AMTMP} ]; then
46 mkdir ${AMTMP} || exit 1
48 echo "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${AMTMP}'."
49 chown ${amanda_user}:${amanda_group} ${AMTMP} || exit 1
50 chmod 0640 ${AMTMP} || exit 1
52 # Install .gnupg directory
53 echo "`date +'%b %e %Y %T'`: Installing '${AMHOMEDIR}/.gnupg'."
54 if [ ! -d ${AMHOMEDIR}/.gnupg ] ; then
55 echo "`date +'%b %e %Y %T'`: '${AMHOMEDIR}/.gnupg' will be created."
56 mkdir ${AMHOMEDIR}/.gnupg || exit 1
58 echo "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${AMHOMEDIR}/.gnupg'."
59 chown ${amanda_user}:${amanda_group} ${AMHOMEDIR}/.gnupg || exit 1
60 chmod 700 ${AMHOMEDIR}/.gnupg || exit 1
62 # Install .amandahosts to server
63 echo "`date +'%b %e %Y %T'`: Checking '${AMHOMEDIR}/.amandahosts' file."
64 if [ ! -f ${AMHOMEDIR}/.amandahosts ] ; then
65 touch ${AMHOMEDIR}/.amandahosts || exit 1
67 for host in localhost localhost.localdomain ; do
68 if [ -z "`grep \"^${host}[[:blank:]]\+root[[:blank:]]\+amindexd[[:blank:]]\+amidxtaped\" ${AMHOMEDIR}/.amandahosts`" ] ; then
69 echo "${host} root amindexd amidxtaped" >>${AMHOMEDIR}/.amandahosts || exit 1
71 if [ -z "`grep \"^${host}[[:blank:]]\+${amanda_user}[[:blank:]]\+amdump\" ${AMHOMEDIR}/.amandahosts`" ] ; then
72 echo "${host} ${amanda_user} amdump" >>${AMHOMEDIR}/.amandahosts || exit 1
75 chown ${amanda_user}:${amanda_group} ${AMHOMEDIR}/.amandahosts || exit 1
76 chmod 0600 ${AMHOMEDIR}/.amandahosts || exit 1
78 # SSH RSA key generation for amdump
79 KEYDIR="${AMHOMEDIR}/.ssh"
80 KEYFILE="id_rsa_amdump"
81 COMMENT="${amanda_user}@server"
82 if [ ! -d ${KEYDIR} ] ; then
83 if [ -f ${KEYDIR} ] ; then
84 echo "`date +'%b %e %Y %T'`: Directory '${KEYDIR}' exists as a file. Renaming to '${KEYDIR}.save'."
85 mv ${KEYDIR} ${KEYDIR}.save || exit 1
87 echo "`date +'%b %e %Y %T'`: Creating directory '${KEYDIR}'."
88 mkdir ${KEYDIR} || exit 1
90 if [ ! -f ${KEYDIR}/${KEYFILE} ] ; then
91 echo "`date +'%b %e %Y %T'`: Creating ssh RSA key in '${KEYDIR}/${KEYFILE}'"
92 ssh-keygen -q -C $COMMENT -t rsa -f ${KEYDIR}/${KEYFILE} -N '' || exit 1
94 echo "`date +'%b %e %Y %T'`: Setting ownership and permissions for '${KEYDIR}' and '${KEYDIR}/${KEYFILE}*'"
95 chown ${amanda_user}:${amanda_group} ${KEYDIR} ${KEYDIR}/${KEYFILE}* || exit 1
96 chmod 0750 ${KEYDIR} || exit 1
97 chmod 0600 ${KEYDIR}/${KEYFILE}* || exit 1
99 # SSH RSA key generation on client for amrecover
100 KEYDIR="${AMHOMEDIR}/.ssh"
101 KEYFILE="id_rsa_amrecover"
102 COMMENT="root@client"
103 if [ ! -d ${KEYDIR} ] ; then
104 if [ -f ${KEYDIR} ] ; then
105 echo "`date +'%b %e %Y %T'`: Directory '${KEYDIR}' exists as a file. Renaming to '${KEYDIR}.save'."
106 mv ${KEYDIR} ${KEYDIR}.save || exit 1
108 echo "`date +'%b %e %Y %T'`: Creating directory '${KEYDIR}'."
109 mkdir ${KEYDIR} || exit 1
111 if [ ! -f ${KEYDIR}/${KEYFILE} ] ; then
112 echo "`date +'%b %e %Y %T'`: Creating ssh RSA key in '${KEYDIR}/${KEYFILE}'"
113 ssh-keygen -q -C $COMMENT -t rsa -f ${KEYDIR}/${KEYFILE} -N '' || exit 1
115 echo "`date +'%b %e %Y %T'`: Setting permissions for '${KEYDIR}'"
116 chown ${amanda_user}:${amanda_group} ${KEYDIR} || exit 1
117 chmod 0750 ${KEYDIR} || exit 1
118 chmod 0600 ${KEYDIR}/${KEYFILE}* || exit 1
120 # environment variables (~amandabackup/.profile)
121 echo "`date +'%b %e %Y %T'`: Checking for '${AMHOMEDIR}/.profile' and ensuring correct environment."
122 if [ ! -f ${AMHOMEDIR}/.profile ] ; then
123 touch ${AMHOMEDIR}/.profile || exit 1
125 if [ -z "`grep PATH ${AMHOMEDIR}/.profile | grep '/usr/sbin'`" ] ; then
126 echo "export PATH=\"\$PATH:/usr/sbin/\"" >> "${AMHOMEDIR}/.profile" || exit 1
128 echo "`date +'%b %e %Y %T'`: Setting ownership and permissions for '${AMHOMEDIR}/.profile'"
129 chown ${amanda_user}:${amanda_group} ${AMHOMEDIR}/.profile || exit 1
130 chmod 0640 ${AMHOMEDIR}/.profile || exit 1
132 echo "`date +'%b %e %Y %T'`: === Amanda backup server installation complete. ==="