⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amanda-backup-server.postinst

📁 开源备份软件源码 AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system that a
💻 POSTINST
字号:
#!/bin/sh# Debian recommends this.  Script exits on simple command failure.# set -eLOGDIR="/var/log/amanda/"SYSCONFDIR="/etc"LOCALSTATEDIR="/var"AMHOMEDIR="${LOCALSTATEDIR}/lib/amanda"AMTMP="/tmp/amanda"amanda_user=amandabackupamanda_group=diskxinetd_reload="restart"if [ -d /etc/xinetd.d ] ; then	if [ ! -f /etc/xinetd.d/amandaserver ] ; then		cp ${AMHOMEDIR}/example/xinetd.amandaserver /etc/xinetd.d/amandaserver || exit 1		chmod 0644 /etc/xinetd.d/amandaserver || exit 1		if [ -f /etc/xinetd.d/amandaclient ] ; then			rm /etc/xinetd.d/amandaclient || exit 1		fi		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	fifiecho "`date +'%b %e %Y %T'`: Installing '${LOCALSTATEDIR}/amanda/amandates'." if [ ! -f ${LOCALSTATEDIR}/amanda/amandates ] ; then	touch ${LOCALSTATEDIR}/amanda/amandates || exit 1fiecho "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${LOCALSTATEDIR}/amanda/amandates'." chown ${amanda_user}:${amanda_group} ${LOCALSTATEDIR}/amanda/amandates || exit 1chmod 0640 ${LOCALSTATEDIR}/amanda/amandates || exit 1if [ -x /sbin/restorecon ] ; then      /sbin/restorecon ${LOCALSTATEDIR}/amanda/amandates  || exit 1fi# Check for existence of and permissions on ${AMTMP}if [ ! -d ${AMTMP} ]; then       mkdir ${AMTMP} || exit 1fiecho "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${AMTMP}'." chown ${amanda_user}:${amanda_group} ${AMTMP} || exit 1chmod 0640 ${AMTMP} || exit 1# Install .gnupg directoryecho "`date +'%b %e %Y %T'`: Installing '${AMHOMEDIR}/.gnupg'." if [ ! -d ${AMHOMEDIR}/.gnupg ] ; then	echo "`date +'%b %e %Y %T'`: '${AMHOMEDIR}/.gnupg' will be created." 	mkdir ${AMHOMEDIR}/.gnupg || exit 1fiecho "`date +'%b %e %Y %T'`: Ensuring correct permissions for '${AMHOMEDIR}/.gnupg'." chown ${amanda_user}:${amanda_group} ${AMHOMEDIR}/.gnupg || exit 1chmod 700 ${AMHOMEDIR}/.gnupg || exit 1# Install .amandahosts to serverecho "`date +'%b %e %Y %T'`: Checking '${AMHOMEDIR}/.amandahosts' file." if [ ! -f ${AMHOMEDIR}/.amandahosts ] ; then	touch ${AMHOMEDIR}/.amandahosts || exit 1fifor host in localhost localhost.localdomain ; do	if [ -z "`grep \"^${host}[[:blank:]]\+root[[:blank:]]\+amindexd[[:blank:]]\+amidxtaped\" ${AMHOMEDIR}/.amandahosts`" ] ; then	        echo "${host}   root amindexd amidxtaped" >>${AMHOMEDIR}/.amandahosts || exit 1	fi	if [ -z "`grep \"^${host}[[:blank:]]\+${amanda_user}[[:blank:]]\+amdump\" ${AMHOMEDIR}/.amandahosts`" ] ; then                echo "${host} ${amanda_user} amdump" >>${AMHOMEDIR}/.amandahosts || exit 1	fidonechown ${amanda_user}:${amanda_group} ${AMHOMEDIR}/.amandahosts || exit 1chmod 0600 ${AMHOMEDIR}/.amandahosts || exit 1# SSH RSA key generation for amdumpKEYDIR="${AMHOMEDIR}/.ssh"KEYFILE="id_rsa_amdump"COMMENT="${amanda_user}@server"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 1fiif [ ! -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 1fiecho "`date +'%b %e %Y %T'`: Setting ownership and permissions for '${KEYDIR}' and '${KEYDIR}/${KEYFILE}*'" chown ${amanda_user}:${amanda_group} ${KEYDIR} ${KEYDIR}/${KEYFILE}* || exit 1chmod 0750 ${KEYDIR} || exit 1chmod 0600 ${KEYDIR}/${KEYFILE}* || exit 1# SSH RSA key generation on client for amrecoverKEYDIR="${AMHOMEDIR}/.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 1fiif [ ! -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 1fiecho "`date +'%b %e %Y %T'`: Setting permissions for '${KEYDIR}'" chown ${amanda_user}:${amanda_group} ${KEYDIR} || exit 1chmod 0750 ${KEYDIR} || exit 1chmod 0600 ${KEYDIR}/${KEYFILE}* || exit 1# environment variables (~amandabackup/.profile)echo "`date +'%b %e %Y %T'`: Checking for '${AMHOMEDIR}/.profile' and ensuring correct environment." if [ ! -f ${AMHOMEDIR}/.profile ] ; then	touch ${AMHOMEDIR}/.profile || exit 1fiif [ -z "`grep PATH ${AMHOMEDIR}/.profile | grep '/usr/sbin'`" ] ; then	echo "export PATH=\"\$PATH:/usr/sbin/\"" >> "${AMHOMEDIR}/.profile" || exit 1fiecho "`date +'%b %e %Y %T'`: Setting ownership and permissions for '${AMHOMEDIR}/.profile'" chown ${amanda_user}:${amanda_group} ${AMHOMEDIR}/.profile || exit 1chmod 0640 ${AMHOMEDIR}/.profile || exit 1echo "`date +'%b %e %Y %T'`: === Amanda backup server installation complete. ===" 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -