Search
j0ke.net Open Build Service
>
Projects
>
home:jg
:
backup
>
amanda
> amanda.spec
Sign Up
|
Log In
Username
Password
Cancel
Overview
Repositories
Revisions
Requests
Users
Advanced
Attributes
Meta
File amanda.spec of Package amanda (Revision 1)
Currently displaying revision
1
,
show latest
# # Copyright (C) 2005-2013 Zmanda Incorporated. # All Rights Reserved. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300 # Sunnyvale, CA 94086, USA, or: http://www.zmanda.com # %define build_srpm 0 %{?srpm_only: %define build_srpm 1} # Pkg-config sometimes needs its own path set, and we need to allow users to # override our guess during detection. This macro takes care of that. # If no --define PKG_CONFIG_PATH was passed and env var $PKG_CONFIG_PATH is # set then use the env var. %{!?PKG_CONFIG_PATH: %{expand:%(echo ${PKG_CONFIG_PATH:+"%%define PKG_CONFIG_PATH $PKG_CONFIG_PATH"})}} %{?PKG_CONFIG_PATH:%{echo:PKG_CONFIG_PATH = %{PKG_CONFIG_PATH}\n}} # LDFLAGS: newer gnu linkers can use "-Wl,--as-needed", while older ones, # like rhel3 and sles9 can't. %define enable_as_needed --enable-as-needed # Define which Distribution we are building: # Try to detect the distribution we are building: %if %{_vendor} == redhat # Fedora symlinks /etc/fedora-release to /etc/redhat-release for at least # fc3-8. So RHEL and Fedora look at the same file. Different versions have # different numbers of spaces; hence the use of $3 vs. $4.. %if %(awk '$1 == "Fedora" { exit 1; }' /etc/redhat-release; echo $?) %define dist fedora %define disttag fc %define distver %(awk '{print $4}' /etc/redhat-release) %endif # if macro cannot have an empty test and we're just testing the existance %if %{?fedora:yes}%{!?fedora:no} == yes # In theory this should be more reliable than awking for distver. %define distver %{fedora} %endif %if "%{dist}" == "fedora" %if %{distver} <= 8 %define requires_libtermcap Requires: libtermcap.so.2 %define curl curl %endif %if %{distver} >= 9 %define curl libcurl %endif %if %{_host_cpu} == x86_64 && %{_target_cpu} == i686 # Do nothing if PKG_CONFIG_PATH was set by the user above. %{!?PKG_CONFIG_PATH: %define PKG_CONFIG_PATH /usr/lib/pkgconfig} %endif %endif %if %(awk '$1 == "Red" && $7 ~ /3.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 3 %define tarver 1.14 %define requires_libtermcap Requires: libtermcap.so.2 %define curl curl %define without_ipv6 --without-ipv6 %undefine enable_as_needed %define prereq_sharutils PreReq: sharutils %endif %if %(awk '$1 == "Red" && $7 ~ /4.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 4 %define tarver 1.14 %define requires_libtermcap Requires: libtermcap.so.2 %define curl curl %define prereq_sharutils PreReq: sharutils %endif %if %(awk '$1 == "CentOS" && $3 ~ /4.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 4 %define tarver 1.14 %define requires_libtermcap Requires: libtermcap.so.2 %define curl curl %define prereq_sharutils PreReq: sharutils %endif %if %(awk '$1 == "Red" && $7 ~ /5.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 5 %define curl curl %endif %if %(awk '$1 == "CentOS" && $3 ~ /5.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 5 %define curl curl %endif %if %(awk '$1 == "Red" && $7 ~ /6.*/ { exit 1; }' /etc/redhat-release; echo $?) %define dist redhat %define disttag rhel %define distver 6 %define curl libcurl %endif # If dist is undefined, we didn't detect. %{!?dist:%define dist unknown} %endif # Detect Suse variants. %if %{_vendor} == "suse" %define dist SuSE %define disttag %(awk '$1=="openSUSE" { print "suse"; } $1=="SUSE" {$3=="Enterprise" ? TAG="sles" : TAG="suse" ; print TAG}' /etc/SuSE-release) # use printf to be sure rpm gets a number type %define distver %(awk '$1=="openSUSE" { printf("%d", $2); } $1=="SUSE" {$3=="Enterprise" ? VER=$5 : VER=$3 ; printf("%d", VER)}' /etc/SuSE-release) %define curl curl %if %{distver} == 9 %undefine enable_as_needed %endif %if %{distver} < 11 %define prereq_sharutils PreReq: sharutils %endif %endif # Set options per distribution %if %{dist} == redhat || %{dist} == fedora %define rpm_group Applications/Archiving %define requires_initscripts Requires: initscripts %endif %if %{dist} == SuSE %define rpm_group Productivity/Archiving/Backup %endif # Let's die if we haven't detected the distro. This might save some frustration. # RPM does not provide a way to exit gracefully, hence the tag_to_cause_exit. %{!?distver: %{error:"Your distribution and its version were not detected."}; %tag_to_cause_exit } # Set minimum tar version if it wasn't set in the per-distro section %{!?tarver: %define tarver 1.15} # Define the native binary data encoder (for create_amkey) %define encoder %({ command -v base64 2>/dev/null; } || { command -v uuencode 2>/dev/null; }) %define packer %(%{__id_u} -n) # --- Definitions --- # Define amanda_version using the value determined by # packaging/common/substitute.pl. %{!?amanda_version: %define amanda_version 3.3.4 } %{!?amanda_release: %define amanda_release 1} %define amanda_version_info "Amanda Community Edition - version %{amanda_version}" %define amanda_user amandabackup %define amanda_group disk Summary: The Amanda Backup and Archiving System Name: amanda Version: %{amanda_version} %define rpm_release %{amanda_release}.%{disttag}%{distver} %if %{build_srpm} %define rpm_release %{amanda_release} %endif Release: %{rpm_release} Source: %{name}-%{version}.tar.gz License: http://wiki.zmanda.com/index.php/Amanda_Copyright Vendor: Zmanda, Inc. Packager: www.zmanda.com BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%{packer}-buildroot Group: %{rpm_group} # TODO - Need required versions for these: BuildRequires: autoconf BuildRequires: automake BuildRequires: binutils BuildRequires: bison BuildRequires: flex BuildRequires: gcc BuildRequires: glib2 >= 2.2.0 BuildRequires: glib2-devel BuildRequires: gettext BuildRequires: readline # Note: newer distros have changed most *-devel to lib*-devel, and added a # provides tag for backwards compat. BuildRequires: readline-devel BuildRequires: %{curl} >= 7.10.0 BuildRequires: %{curl}-devel >= 7.10.0 BuildRequires: openssl BuildRequires: openssl-devel BuildRequires: perl(ExtUtils::Embed) %{?prereq_sharutils} Requires: /bin/awk Requires: /bin/date Requires: /usr/bin/id Requires: /sbin/ldconfig Requires: /bin/sh Requires: /usr/sbin/useradd Requires: /usr/sbin/usermod Requires: fileutils Requires: gettext Requires: grep Requires: gnuplot Requires: %{curl} >= 7.10.0 Requires: openssl Requires: xinetd Requires: perl >= 5.6.0 Requires: tar >= %{tarver} Requires: readline %{?requires_libtermcap} %{?requires_initscripts} %package backup_client Summary: The Amanda Backup and Archiving Client Group: %{rpm_group} Requires: /bin/awk Requires: fileutils Requires: grep %{?requires_libtermcap} %{?requires_initscripts} Requires: xinetd Requires: perl >= 5.6.0 Requires: tar >= %{tarver} Requires: readline Provides: amanda-backup_client = %{amanda_version} Provides: libamclient-%{version}.so = %{amanda_version} Provides: libamanda-%{version}.so = %{amanda_version} Conflicts: amanda-backup_server # Native package names Obsoletes: amanda, amanda-client, amanda-server %package backup_server Summary: The Amanda Backup and Archiving Server Group: %{rpm_group} Requires: /bin/awk Requires: fileutils Requires: grep %{?requires_libtermcap} %{?requires_initscripts} Requires: xinetd Requires: perl >= 5.6.0 Requires: tar >= %{tarver} Provides: amanda-backup_server = %{amanda_version} Provides: libamclient-%{version}.so = %{amanda_version} Provides: libamanda-%{version}.so = %{amanda_version} Provides: libamserver-%{version}.so = %{amanda_version} Provides: libamtape-%{version}.so = %{amanda_version} Provides: libamdevice-%{version}.so = %{amanda_version} Conflicts: amanda-backup_client # Native package names Obsoletes: amanda, amanda-client, amanda-server # --- Package descriptions --- %description Amanda is the leading Open-Source Backup and Archiving software. The amanda-backup_server package should be installed on the Amanda server, i.e. the machine attached to backup media (such as a tape drive or disk drives) where backups will be written. The amanda-backup_server package includes Amanda client. The amanda-backup_client package needs to be installed on every system that is being backed up. Amanda Forums is located at: http://forums.zmanda.com/ Amanda Documentation is available at: http://wiki.zmanda.com/ %description backup_server Amanda is the leading Open-Source Backup and Archiving software. This package contains the Amanda server. The amanda-backup_server package should be installed on the Amanda server, i.e. the machine attached to backup media (such as a tape drive or disk drives) where backups will be written. The amanda-backup_server package includes Amanda client. Amanda Forums is located at: http://forums.zmanda.com/ Amanda Documentation is available at: http://wiki.zmanda.com/ %description backup_client Amanda is the leading Open-Source Backup and Archiving software. This package contains the Amanda client. The amanda-backup_client package needs to be installed on every system that is being backed up. Amanda Forums is located at: http://forums.zmanda.com/ Amanda Documentation is available at: http://wiki.zmanda.com/ # --- Directory setup --- # Configure directories: %define PREFIX /usr %define EPREFIX %{PREFIX} %define BINDIR %{EPREFIX}/bin %define SBINDIR %{EPREFIX}/sbin %define LIBEXECDIR %{EPREFIX}/libexec %define AMLIBEXECDIR %{LIBEXECDIR}/amanda %define DATADIR %{PREFIX}/share %define SYSCONFDIR /etc %define LOCALSTATEDIR /var %define AMANDATES %{AMANDAHOMEDIR}/amandates %define AMANDAHOMEDIR %{LOCALSTATEDIR}/lib/amanda %ifarch x86_64 %define LIBDIR %{EPREFIX}/lib64 %else %define LIBDIR %{EPREFIX}/lib %endif %define AMLIBDIR %{LIBDIR}/amanda %define INCLUDEDIR %{PREFIX}/include %define MANDIR %{DATADIR}/man %define LOGDIR /var/log/amanda %define PERLSITELIB %(eval "`perl -V:installsitelib`"; echo $installsitelib) %define AMDATADIR /var/lib/amanda # Installation directories: %define ROOT_SBINDIR %{buildroot}/%{SBINDIR} %define ROOT_LIBEXECDIR %{buildroot}/%{LIBEXECDIR} %define ROOT_DATADIR %{buildroot}/%{DATADIR} %define ROOT_LOCALSTATEDIR %{buildroot}/%{LOCALSTATEDIR} %define ROOT_SYSCONFDIR %{buildroot}/%{SYSCONFDIR} %define ROOT_AMANDAHOMEDIR %{buildroot}/%{AMANDAHOMEDIR} %define ROOT_LIBDIR %{buildroot}/%{LIBDIR} %define ROOT_MANDIR %{buildroot}/%{MANDIR} %define ROOT_LOGDIR %{buildroot}/%{LOGDIR} %define ROOT_AMDATADIR %{buildroot}/%{AMDATADIR} # --- Unpack --- %prep %setup -q # --- Configure and compile --- %build %define config_user %{amanda_user} %define config_group %{amanda_group} # Set PKG_CONFIG_PATH=some/path if some/path was set on the command line, or by # the platform detection bits. # without_ipv6 should only be defined on rhel3. # LDFLAGS macro is defined except on rhel3. # --enable-as-needed must be conditional until configure tests whether # ld can accept --as-needed. ./configure \ %{?PKG_CONFIG_PATH: PKG_CONFIG_PATH=%PKG_CONFIG_PATH} \ CFLAGS="%{optflags} -g -pipe" CXXFLAGS="%{optflags}" \ %{?LDFLAGS:LDFLAGS="${LDFLAGS} %{?LDFLAGS:%LDFLAGS}"} \ %{?enable_as_needed:%{enable_as_needed}} \ --quiet \ --prefix=%{PREFIX} \ --sysconfdir=%{SYSCONFDIR} \ --sharedstatedir=%{LOCALSTATEDIR} \ --localstatedir=%{LOCALSTATEDIR} \ --libdir=%{LIBDIR} \ --includedir=%{INCLUDEDIR} \ --mandir=%{MANDIR} \ --with-amdatadir=%{AMDATADIR} \ --with-gnuplot=/usr/bin/gnuplot \ --with-gnutar-listdir=%{AMANDAHOMEDIR}/gnutar-lists \ --with-index-server=localhost \ --with-tape-server=localhost \ --with-user=%{config_user} \ --with-group=%{config_group} \ --with-owner=%{packer} \ --with-fqdn \ --with-bsd-security \ --with-bsdtcp-security \ --with-bsdudp-security \ --with-ssh-security \ --with-debugging=%{LOGDIR} \ --with-assertions \ --disable-installperms \ %{?without_ipv6} make -s LIBTOOLFLAGS=--silent # --- Install to buildroot --- %install if [ "%{buildroot}" != "/" ]; then if [ -d "%{buildroot}" ] ; then rm -rf %{buildroot} fi else echo "BuildRoot was somehow set to / !" exit -1 fi make -s -j1 LIBTOOLFLAGS=--silent DESTDIR=%{buildroot} install rm -f %{ROOT_AMANDAHOMEDIR}/example/inetd.conf.amandaclient mkdir %{buildroot}/{etc,var/log} mkdir %{ROOT_LOCALSTATEDIR}/amanda mkdir %{ROOT_SYSCONFDIR}/amanda mkdir %{ROOT_AMANDAHOMEDIR}/gnutar-lists mkdir %{ROOT_LOGDIR} echo "%{amanda_version_info}" >%{ROOT_AMANDAHOMEDIR}/amanda-release # --- Clean up buildroot --- %clean if [ "%{buildroot}" != "/" ]; then if [ -d "%{buildroot}" ] ; then rm -rf %{buildroot} fi else echo "BuildRoot was somehow set to / !" exit -1 fi # --- Pre/post (un)installation scripts --- # Define script variables # Some versions of rpmbuild do not like multi-line macros in spec files. ugly. %define script_vars amanda_user=%{amanda_user}; amanda_group=%{amanda_group}; AMANDAHOMEDIR=%{AMANDAHOMEDIR}; os=Linux; wanted_shell=/bin/bash; dist=%{dist}; LOGDIR=%{LOGDIR}; INSTALL_LOG=$LOGDIR/install.log; SYSCONFDIR=%{SYSCONFDIR}; SBINDIR=%{SBINDIR}; encoder=%{encoder}; # --- Pre/post (un)installation scripts --- %pre backup_server ########################################## LOGFILE=`mktemp /tmp/amanda_server-preinst.log.XXXXXXXXXXX` if [ $? -ne 0 ]; then echo "Unable to create log file!" exit 1 fi %{script_vars} # See packaging/common/ for shell function libraries. # ---------- Common functions ------------ #!/bin/sh # Common Functions # Required variables: # LOGFILE # SYSCONFDIR # os logger() { # A non-annoying way to log stuff # ${@} is all the parameters, also known as the message. Quoting the input # preserves whitespace. msg="`date +'%b %d %Y %T'`: ${@}" echo "${msg}" >> ${LOGFILE} } log_output_of() { # A non-annoying way to log output of commands # ${@} is all the parameters supplied to the function. just execute it, # and capture the output in a variable. then log that. output=`"${@}" 2>&1` ret=$? if [ -n "${output}" ] ; then logger "${1}: ${output}" fi return ${ret} } check_superserver() { # Check for the superserver $1 for the config $2 case $1 in xinetd) check_xinetd $2; return $?;; inetd) check_inetd $2; return $?;; launchd) check_launchd $2; return $?;; smf) check_smf $2; return $?;; esac } check_xinetd() { # Checks for an xinetd install and a config name passed as the first # parameter. # Returns: # 0 if the file exists, # 1 if it does not, # 2 if xinetd.d/ does not exist or is a file if [ -d ${SYSCONFDIR}/xinetd.d ] ; then if [ -f ${SYSCONFDIR}/xinetd.d/${1} ] ; then logger "Found existing xinetd config: ${1}" return 0 else return 1 fi else # No xinetd installation. return 2 fi } check_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac if [ -e ${inetd_conf} ] ; then if grep "${1}" ${inetd_conf} > /dev/null ; then logger "Found existing inetd config: ${1}" return 0 else return 1 fi else # No inetd installation. return 2 fi } check_launchd() { # TODO: refactor OS X scripts. : } check_smf() { # Only for solaris! This check only notices if an amanda service is active, # it does not notice server vs client entries. log_output_of svcs -H "*amanda*" || { \ logger "No amanda service found."; return 1; } } check_superserver_running() { # Check for the given superserver, $1, in the output of ps -ef, or on # mac/bsd ps ax. # Return codes: # 0: $1 is running # 1: $1 is not running # 2: $1 is not valid for this system case $1 in # Linux or Solaris. This works despite sol10 using SMF. inetd) ps_flags='-e';; xinetd) ps_flags='-e';; # Mac OS X launchd) ps_flags='aux';; *) echo "Bad superserver."; return 2 ;; esac if [ "$1" = "launchd" ] && [ `uname` != 'Darwin' ]; then echo "Only darwin uses launchd" return 2 fi if [ "$1" = "xinetd" ] && [ "$os" = 'SunOS' ] && \ [ `uname -r` = "5.10" ]; then echo "Solaris 10 does not use xinetd." return 2 fi # Search for $1, PROC=`ps ${ps_flags} | grep -v 'grep'| grep "${1}"` if [ x"${PROC}" != x ]; then return 0 else return 1 fi } backup_xinetd() { log_output_of mv ${SYSCONFDIR}/xinetd.d/${1} ${AMANDAHOMEDIR}/example/xinetd.${1}.orig || \ { logger "WARNING: Could not back up existing xinetd configuration '${1}'"; return 1; } logger "Old xinetd config for '${1}' backed up to '${AMANDAHOMEDIR}/example/xinetd.${1}.orig'" } backup_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # Backs up any amanda configuration it finds log_output_of sed -n "/^amanda .* amandad/w ${AMANDAHOMEDIR}/example/inetd.orig" ${inetd_conf} || \ { logger "WARNING: could not write ${AMANDAHOMEDIR}/example/inetd.orig"; return 1; } log_output_of sed "/^amanda .* amandad/d" ${inetd_conf} > \ ${inetd_conf}.tmp || \ { logger "WARNING: could not write ${inetd_conf}.tmp"; return 1; } log_output_of mv ${inetd_conf}.tmp ${inetd_conf} || \ { logger "WARNING: could not overwrite ${inetd_conf}, old config not removed."; return 1; } logger "Old inetd config for amanda backed up to ${AMANDAHOMEDIR}/example/inetd.orig" } backup_smf() { # Solaris only. I *think* this should be consistent across all smf installs svccfg -s *amanda* > ${AMANDAHOMEDIR}/example/amanda_smf.xml.orig || {\ logger "Warning: export of existing amanda service failed."; return 1; } log_output_of inetadm -d *amanda* || { \ # Not critical, we don't need to return if this fails. logger "Warning: disabling existing amanda service failed."; } log_output_of svccfg delete -f *amanda* || { \ logger "Error: removing the old amanda service failed."; return 1; } } install_xinetd() { log_output_of install -m 0644 ${AMANDAHOMEDIR}/example/xinetd.${1} ${SYSCONFDIR}/xinetd.d/${1} || \ { logger "WARNING: Could not install xinetd configuration '${1}'" ; return 1; } logger "Installed xinetd config for ${1}." } install_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # This one is hard to log because we're just appending. logger "Appending ${AMANDAHOMEDIR}/example/inetd.conf.${1} to ${inetd_conf}" cat ${AMANDAHOMEDIR}/example/inetd.conf.${1} >> ${inetd_conf} } install_smf() { # First parameter should be the name of the service to install # (amandaserver, or amandaclient). ver=`uname -r` case $ver in 5.10) # Use inetadm and svcadm. log_output_of ${basedir}/usr/sbin/inetconv -f -i ${AMANDAHOMEDIR}/example/inetd.conf.${1} || { \ logger "Warning: Failed to create Amanda SMF manifest. Check the system log."; return 1; } log_output_of ${basedir}/usr/sbin/inetadm -e svc:/network/amanda/tcp || { \ logger "Warning: Failed to enable Amanda service. See system log for more information."; return 1; } log_output_of ${basedir}/usr/sbin/svcadm restart network/amanda/tcp || { \ logger "Warning: Failed to restart Amanda service. See system log for details."; return 1; } ;; 5.8|5.9) logger "Solaris 8 and 9 use inetd, not SMF tools." return 1 ;; *) # I don't know what to do... logger "ERROR: Unsupported and untested version of Solaris: $ver" return 1 ;; esac } reload_xinetd() { # Default action is to try reload. case $1 in reload|restart|start) action=$1 ;; "") action=reload ;; *) logger "WARNING: bad argument to reload_xinetd: $1" return 1 ;; esac if [ "$action" = "reload" ] ; then logger "Reloading xinetd configuration..." log_output_of ${SYSCONFDIR}/init.d/xinetd $action # Don't exit! if [ $? -ne 0 ] ; then logger "xinetd reload failed. Attempting restart..." action=restart fi fi if [ "$action" = "restart" ] || [ "$action" = "start" ]; then logger "${action}ing xinetd." log_output_of ${SYSCONFDIR}/init.d/xinetd $action || \ { logger "WARNING: $action failed." ; return 1; } fi } reload_inetd() { # Default action is to try reload. if [ "x$1" = "x" ]; then action="reload" elif [ "$1" = "reload" ] || [ "$1" = "restart" ]; then action="$1" else logger "WARNING: bad argument to reload_inetd: $1" return 1 fi if [ "$1" = "reload" ] ; then logger "Reloading inetd configuration..." log_output_of ${SYSCONFDIR}/init.d/inetd $1 # Don't exit! if [ $? -ne 0 ] ; then logger "inetd reload failed. Attempting restart..." log_output_of ${SYSCONFDIR}/init.d/inetd restart || \ { logger "WARNING: restart failed." ; return 1; } fi else # Must be restart... logger "Restarting inetd." log_output_of ${SYSCONFDIR}/init.d/inetd $1 || \ { logger "WARNING: ${1} failed." ; return 1; } fi } # End Common functions #!/bin/sh # These functions are included by various different installers. # We assume that the following variables are defined in the main script: # amanda_user: the amanda account username # amanda_group: the amanda account's group # amandahomedir: a directory to use as amanda's home # deb_uid: sepecific uid amanda_user should get on deb style systems. # dist: used on linux for the distro. # LOGFILE: a log file we append to # os: Linux, Darwin, SunOS, `uname`... # wanted_shell: Linux/SunOS/OSX all keep them in different places # SYSCONFDIR: location of system config files (ie, /etc) # LOGDIR: logging directory for amanda # These variables are defined, but null to allow checking names checked_uid= export checked_uid # PreInstall Functions create_user() { case $os in Linux|SunOS) # Create the amanda user with a specific uid on deb systems if [ "x${dist}" = "xDebian" ] || [ "x${dist}" = "xUbuntu" ] ; then uid_flag="-u ${deb_uid}" else uid_flag= fi logger "Checking for user: ${amanda_user}" # we want the output of id, but if the user doesn't exist, # sterr output just confuses things ID=`id ${amanda_user} 2> /dev/null | sed 's/uid=\([0-9]*\).*/\1/'` if [ "${ID}x" = "x" ] ; then logger "Adding ${amanda_user}." log_output_of useradd -c "Amanda" \ -g ${amanda_group} \ ${uid_flag} \ -d ${AMANDAHOMEDIR} \ -s ${wanted_shell} ${amanda_user} || \ { logger "WARNING: Could not create user ${amanda_user}. Installation will fail." ; return 1 ; } logger "Created ${amanda_user} with blank password." if [ "x$os" = "xLinux" ] && [ "x${dist}" != "xSuSE" ]; then # Lock the amanda account until admin sets password log_output_of passwd -l ${amanda_user} && { \ logger "${info_create_user_success}" logger "${info_unlock_account}" } || { \ logger "${warning_user_passwd}"; } fi if [ "x$os" = "xSunOS" ]; then r=`uname -r` case $r in 5.8|5.9) log_output_of passwd -l ${amanda_user} ;; 5.10) # Special login-lock, while allowing execution. log_output_of passwd -N ${amanda_user} && { \ logger "${info_create_user_success_sol}" logger "${info_unlock_account}" } || { \ logger "${warning_user_passwd}"; } ;; esac fi else # The user already existed logger "The Amanda user '${amanda_user}' exists on this system." fi ;; Darwin) : #TODO ;; esac } add_profiles() { # Solaris only: Add a comma separated list of rights profiles to the # $amanda_user. Replaces any existing profiles listed on the account. log_output_of usermod -P "\"$*\"" ${amanda_user} || { logger "Warning: Rights profiles were not added. Some types of backup may not work until these rights profiles are givent to ${amanda_backup}: '$*'" return 1; } } add_group() { # First, try to add the group, detect via return code if it # already exists. Then add ${amanda_user} to the group without # checking if account is already a member. (check_user should # already have been called). # # Works on linux and solaris. OSX has different tools. [ "x${1}" = "x" ] && { logger "Error: first argument was not a group to add." ; return 1 ; } group_to_add=${1} log_output_of groupadd ${group_to_add} rc=$? # return of 0 means group was added; 9 means group existed. if [ $rc -eq 0 ] || [ $rc -eq 9 ]; then logger "Adding ${amanda_user} to ${group_to_add}" # Generate a comma separated list of existing supplemental groups. # Linux prefaces output with '<username> : '. existing_sup_groups=`groups ${amanda_user}|sed 's/.*: //;s/ /,/g'` # usermod append is -A on Suse, all other linux use -a, and # -A means something else entirely on solaris. So we just use # -G, and append a list of the current groups from id. # So far, all linux distros have usermod log_output_of usermod -G ${existing_sup_groups},${group_to_add} ${amanda_user} || { \ logger "Nonfatal ERROR: Failed to add ${group_to_add}." logger "${error_group_member}" ; return 1 ; } else logger "Error: groupadd failed in an unexpected way. return code='$rc'" return 1 fi } # All check_user_* functions check various parameters of ${amanda_user}'s # account. Return codes: # 0 = success # 1 = error # 2 = usage or other error. more info will be logged check_user_group() { # checks the system group file for ${amanda_user}'s membership in # the group named $1. err=0 [ "x" = "x$1" ] && { logger "check_user_group: no group given"; return 1; } logger "Verify ${amanda_user}'s primary group = $1 " # Check if the group exists, disregarding membership. group_entry=`grep "^${2}" ${SYSCONFDIR}/group 2> /dev/null` if [ ! "x" = "x${group_entry}" ]; then # Assume the user exists, and check the user's primary group. GROUP=`id ${amanda_user} 2> /dev/null |\ cut -d " " -f 2 |\ sed 's/.*gid=[0-9]*(\([^ ()]*\))/\1/'` if [ ! "x${GROUP}" = "x${1}" ] ; then logger "${amanda_user} not a member of ${1}" err=1 fi else logger "User's primary group '${1}' does not exist" err=1 fi return $err } check_user_supplemental_group() { # Checks for the group ${1}, and adds ${amanda_user} if missing. # Other groups are preserved. err=0 [ "x" = "x$1" ] && { logger "check_user_supplemental_group: no supplemental group given"; return 1; } sup_group=${1} logger "Verify ${amanda_user} is a member of ${sup_group}." # First, check if the supplementary group exists. sup_group_entry=`grep "${sup_group}" ${SYSCONFDIR}/group 2>/dev/null` if [ ! "x" = "x${sup_group_entry}" ]; then SUP_MEM=`echo ${sup_group_entry} | cut -d: -f4` # Check if our user is a member. case ${SUP_MEM} in *${amanda_user}*) : ;; *) logger "${amanda_user} is not a member of supplemental group ${sup_group}." err=1 ;; esac else logger "Supplemental group ${sup_group} does not exist" err=1 fi return $err } check_user_shell() { # Confirms the passwd file's shell field for ${amanda_user} is $1 [ "x" = "x$1" ] && { logger "check_user_shell: no shell given"; return 1; } wanted_shell=$1; export wanted_shell logger "Verify ${amanda_user}'s shell is ${wanted_shell}." real_shell=`grep "^${amanda_user}" ${SYSCONFDIR}/passwd | cut -d: -f7` export real_shell if [ ! "x${real_shell}" = "x${wanted_shell}" ] ; then logger "WARNING: ${amanda_user} default shell= ${wanted_shell}" logger "WARNING: ${amanda_user} existing shell: ${real_shell}" logger "${warning_user_shell}" return 1 fi } check_user_homedir() { # Confirm the passwd file's homedir field for ${amanda_user} is $1 [ "x" = "x$1" ] && { logger "check_user_homedir: no homedir given"; return 1; } HOMEDIR=`grep "^${amanda_user}" ${SYSCONFDIR}/passwd | cut -d: -f6` if [ ! "x${HOMEDIR}" = "x${1}" ] ; then logger "${warning_user_homedir}" return 1 fi } check_user_uid() { # Confirm that ${amanda_user}'s UID is $1. # Debian systems must use a specific UID [ "x" = "x$1" ] && { logger "check_user_uid: no uid given"; return 1; } ID=`id ${amanda_user} 2> /dev/null | sed 's/uid=\([0-9]*\).*/\1/'` if [ ! ${ID} -eq ${1} ] ; then checked_uid=${1}; export checked_uid logger "${warning_user_uid_debian}" return 1 fi } check_homedir() { # Checks that the homedir has correct permissions and belongs to correct # user. Uses $amanda_user and $amanda_group. if [ -d ${AMANDAHOMEDIR} ] ; then OWNER_GROUP=`ls -dl ${AMANDAHOMEDIR} | awk '{ print $3" "$4; }'` [ "x$OWNER_GROUP" = "x${amanda_user} ${amanda_group}" ] || \ logger "${warning_homedir_owner}" return $? else logger "homedir ${AMANDAHOMEDIR} does not exist." return 1 fi } create_homedir() { # Creates the homedir, if necessary, and fixes ownership. if [ ! -d ${AMANDAHOMEDIR} ] ; then logger "Creating ${AMANDAHOMEDIR}" log_output_of mkdir -p -m 0750 ${AMANDAHOMEDIR} || { logger "WARNING: Could not create ${AMANDAHOMEDIR}" ; return 1 ; } fi log_output_of chown -R ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR} || { logger "WARNING: Could not chown ${AMANDAHOMEDIR}" ; return 1 ; } } create_logdir() { if [ -d ${LOGDIR} ] || [ -f ${LOGDIR} ] ; then logger "Found existing ${LOGDIR}" log_output_of mv ${LOGDIR} ${LOGDIR}.save || \ { logger "WARNING: Could not backup existing log directory: ${LOGDIR}" ; return 1 ; } fi logger "Creating ${LOGDIR}." log_output_of mkdir -p -m 0750 ${LOGDIR} || \ { logger "WARNING: Could not create ${LOGDIR}" ; return 1 ; } if [ -d ${LOGDIR}.save ] || [ -f ${LOGDIR}.save ] ; then # Move the saved log into the logdir. log_output_of mv ${LOGDIR}.save ${LOGDIR} fi log_output_of chown -R ${amanda_user}:${amanda_group} ${LOGDIR} || \ { logger "WARNING: Could not chown ${LOGDIR}" ; return 1 ; } } # Info, Warning, and Error strings used by the installer info_create_user_success="NOTE: Set a password and unlock the ${amanda_user} account before running Amanda." info_create_user_success_sol="NOTE: Account is set as non-login. If interactive login is required: a password must be set, and the account activated for login." info_unlock_account=" The superuser can unlock the account by running: # passwd -u ${amanda_user} " info_existing_installs="Pre-existing Amanda installations must confirm: -${SYSCONFDIR}/amanda/* should have 'dumpuser' set to '${amanda_user}'. -${AMANDAHOMEDIR}/.amandahosts on client systems should allow connections by '${amanda_user}'." warning_user_password="WARNING: '${amanda_user}' no password. An error occured when locking the account. SET A PASSWORD NOW: # passwd ${amanda_user}" error_group_member="Nonfatal ERROR: Amanda will not run until '${amanda_user}' is a member the preceeding group. Install will continue..." warning_user_shell="WARNING: The user '${amanda_user}' has a non-default shell. Other shells have not been tested." warning_user_homedir="WARNING: The user '${amanda_user}' must have its home directory set to '${AMANDAHOMEDIR}' Please correct before using Amanda." warning_user_uid_debian="WARNING: Debian packages were built assuming that ${amanda_user} uid = ${checked_uid}. The uid of ${amanda_user} is different on this system. Files owned by ${checked_uid} must be chowned to ${amanda_user}." warning_homedir_owner="WARNING: The ${amanda_user}'s home directory,'${AMANDAHOMEDIR}' ownership must be changed to '${amanda_user}:${amanda_group}'. " # --------------- End included Functions ----------------- # -------- End Common functions ---------- logger "Preparing to install: Amanda Server 3.3.4" create_user check_user_group "${amanda_group}" || add_group "${amanda_group}" check_user_supplemental_group "tape" || add_group "tape" check_user_shell "${wanted_shell}" check_user_homedir "${AMANDAHOMEDIR}" check_homedir || create_homedir create_logdir logger "Preinstall done." cat $LOGFILE > $INSTALL_LOG && rm $LOGFILE || \ echo "Amanda preinstall logs can be found in '$LOGFILE'." %post backup_server ########################################## LOGFILE=`mktemp /tmp/amanda_server-postinst.log.XXXXXXXXXXX` if [ $? -ne 0 ]; then echo "Unable to create log file!" exit 1 fi %{script_vars} AMANDATES=%{AMANDATES} # ---------- Common functions ------------ #!/bin/sh # Common Functions # Required variables: # LOGFILE # SYSCONFDIR # os logger() { # A non-annoying way to log stuff # ${@} is all the parameters, also known as the message. Quoting the input # preserves whitespace. msg="`date +'%b %d %Y %T'`: ${@}" echo "${msg}" >> ${LOGFILE} } log_output_of() { # A non-annoying way to log output of commands # ${@} is all the parameters supplied to the function. just execute it, # and capture the output in a variable. then log that. output=`"${@}" 2>&1` ret=$? if [ -n "${output}" ] ; then logger "${1}: ${output}" fi return ${ret} } check_superserver() { # Check for the superserver $1 for the config $2 case $1 in xinetd) check_xinetd $2; return $?;; inetd) check_inetd $2; return $?;; launchd) check_launchd $2; return $?;; smf) check_smf $2; return $?;; esac } check_xinetd() { # Checks for an xinetd install and a config name passed as the first # parameter. # Returns: # 0 if the file exists, # 1 if it does not, # 2 if xinetd.d/ does not exist or is a file if [ -d ${SYSCONFDIR}/xinetd.d ] ; then if [ -f ${SYSCONFDIR}/xinetd.d/${1} ] ; then logger "Found existing xinetd config: ${1}" return 0 else return 1 fi else # No xinetd installation. return 2 fi } check_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac if [ -e ${inetd_conf} ] ; then if grep "${1}" ${inetd_conf} > /dev/null ; then logger "Found existing inetd config: ${1}" return 0 else return 1 fi else # No inetd installation. return 2 fi } check_launchd() { # TODO: refactor OS X scripts. : } check_smf() { # Only for solaris! This check only notices if an amanda service is active, # it does not notice server vs client entries. log_output_of svcs -H "*amanda*" || { \ logger "No amanda service found."; return 1; } } check_superserver_running() { # Check for the given superserver, $1, in the output of ps -ef, or on # mac/bsd ps ax. # Return codes: # 0: $1 is running # 1: $1 is not running # 2: $1 is not valid for this system case $1 in # Linux or Solaris. This works despite sol10 using SMF. inetd) ps_flags='-e';; xinetd) ps_flags='-e';; # Mac OS X launchd) ps_flags='aux';; *) echo "Bad superserver."; return 2 ;; esac if [ "$1" = "launchd" ] && [ `uname` != 'Darwin' ]; then echo "Only darwin uses launchd" return 2 fi if [ "$1" = "xinetd" ] && [ "$os" = 'SunOS' ] && \ [ `uname -r` = "5.10" ]; then echo "Solaris 10 does not use xinetd." return 2 fi # Search for $1, PROC=`ps ${ps_flags} | grep -v 'grep'| grep "${1}"` if [ x"${PROC}" != x ]; then return 0 else return 1 fi } backup_xinetd() { log_output_of mv ${SYSCONFDIR}/xinetd.d/${1} ${AMANDAHOMEDIR}/example/xinetd.${1}.orig || \ { logger "WARNING: Could not back up existing xinetd configuration '${1}'"; return 1; } logger "Old xinetd config for '${1}' backed up to '${AMANDAHOMEDIR}/example/xinetd.${1}.orig'" } backup_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # Backs up any amanda configuration it finds log_output_of sed -n "/^amanda .* amandad/w ${AMANDAHOMEDIR}/example/inetd.orig" ${inetd_conf} || \ { logger "WARNING: could not write ${AMANDAHOMEDIR}/example/inetd.orig"; return 1; } log_output_of sed "/^amanda .* amandad/d" ${inetd_conf} > \ ${inetd_conf}.tmp || \ { logger "WARNING: could not write ${inetd_conf}.tmp"; return 1; } log_output_of mv ${inetd_conf}.tmp ${inetd_conf} || \ { logger "WARNING: could not overwrite ${inetd_conf}, old config not removed."; return 1; } logger "Old inetd config for amanda backed up to ${AMANDAHOMEDIR}/example/inetd.orig" } backup_smf() { # Solaris only. I *think* this should be consistent across all smf installs svccfg -s *amanda* > ${AMANDAHOMEDIR}/example/amanda_smf.xml.orig || {\ logger "Warning: export of existing amanda service failed."; return 1; } log_output_of inetadm -d *amanda* || { \ # Not critical, we don't need to return if this fails. logger "Warning: disabling existing amanda service failed."; } log_output_of svccfg delete -f *amanda* || { \ logger "Error: removing the old amanda service failed."; return 1; } } install_xinetd() { log_output_of install -m 0644 ${AMANDAHOMEDIR}/example/xinetd.${1} ${SYSCONFDIR}/xinetd.d/${1} || \ { logger "WARNING: Could not install xinetd configuration '${1}'" ; return 1; } logger "Installed xinetd config for ${1}." } install_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # This one is hard to log because we're just appending. logger "Appending ${AMANDAHOMEDIR}/example/inetd.conf.${1} to ${inetd_conf}" cat ${AMANDAHOMEDIR}/example/inetd.conf.${1} >> ${inetd_conf} } install_smf() { # First parameter should be the name of the service to install # (amandaserver, or amandaclient). ver=`uname -r` case $ver in 5.10) # Use inetadm and svcadm. log_output_of ${basedir}/usr/sbin/inetconv -f -i ${AMANDAHOMEDIR}/example/inetd.conf.${1} || { \ logger "Warning: Failed to create Amanda SMF manifest. Check the system log."; return 1; } log_output_of ${basedir}/usr/sbin/inetadm -e svc:/network/amanda/tcp || { \ logger "Warning: Failed to enable Amanda service. See system log for more information."; return 1; } log_output_of ${basedir}/usr/sbin/svcadm restart network/amanda/tcp || { \ logger "Warning: Failed to restart Amanda service. See system log for details."; return 1; } ;; 5.8|5.9) logger "Solaris 8 and 9 use inetd, not SMF tools." return 1 ;; *) # I don't know what to do... logger "ERROR: Unsupported and untested version of Solaris: $ver" return 1 ;; esac } reload_xinetd() { # Default action is to try reload. case $1 in reload|restart|start) action=$1 ;; "") action=reload ;; *) logger "WARNING: bad argument to reload_xinetd: $1" return 1 ;; esac if [ "$action" = "reload" ] ; then logger "Reloading xinetd configuration..." log_output_of ${SYSCONFDIR}/init.d/xinetd $action # Don't exit! if [ $? -ne 0 ] ; then logger "xinetd reload failed. Attempting restart..." action=restart fi fi if [ "$action" = "restart" ] || [ "$action" = "start" ]; then logger "${action}ing xinetd." log_output_of ${SYSCONFDIR}/init.d/xinetd $action || \ { logger "WARNING: $action failed." ; return 1; } fi } reload_inetd() { # Default action is to try reload. if [ "x$1" = "x" ]; then action="reload" elif [ "$1" = "reload" ] || [ "$1" = "restart" ]; then action="$1" else logger "WARNING: bad argument to reload_inetd: $1" return 1 fi if [ "$1" = "reload" ] ; then logger "Reloading inetd configuration..." log_output_of ${SYSCONFDIR}/init.d/inetd $1 # Don't exit! if [ $? -ne 0 ] ; then logger "inetd reload failed. Attempting restart..." log_output_of ${SYSCONFDIR}/init.d/inetd restart || \ { logger "WARNING: restart failed." ; return 1; } fi else # Must be restart... logger "Restarting inetd." log_output_of ${SYSCONFDIR}/init.d/inetd $1 || \ { logger "WARNING: ${1} failed." ; return 1; } fi } # End Common functions #!/bin/sh # ------------- Begin Post Install Functions ----------------- # These functions are included by various different installers. # We assume that the following variables are defined in the main script: # amanda_user: the amanda account username # amanda_group: the amanda account's group # AMANDAHOMEDIR: a directory to use as amanda's home # dist: used on linux for the distro. # install_log: a log file we append to # os: Linux, Mac, Solaris, etc... # SYSCONFDIR: location of system config files (ie, /etc) # LOGDIR: logging directory for amanda # encoder: either base64 or uuencode depending on the default for this platform #TODO: gnutar-lists dir for solaris?? add_service() { # Only needed on Solaris! entry="amanda 10080/tcp # amanda backup services" # make sure amanda is in /etc/services if [ -z "`grep 'amanda' ${SYSCONFDIR}/services |grep '10080/tcp'`" ] ; then logger "Adding amanda entry to ${SYSCONFDIR}/services." echo "${entry}" >> ${SYSCONFDIR}/services fi # make sure kamanda is in /etc/services entry_2="amanda 10081/tcp famdc # amanda backup services (kerberos)" if [ -z "`grep 'kamanda' /etc/services |grep '10081/tcp'`" ] ; then logger "Adding kamanda entry to ${SYSCONFDIR}/services." echo "${entry_2}" >> ${SYSCONFDIR}/services fi } create_amandates() { logger "Creating ${AMANDATES}." if [ ! -f ${AMANDATES} ] ; then touch ${AMANDATES} || { logger "WARNING: Could not create Amandates." ; return 1; } fi } check_amandates() { logger "Ensuring correct permissions for '${AMANDATES}'." log_output_of chown ${amanda_user}:${amanda_group} ${AMANDATES} || \ { logger "WARNING: Could not chown ${AMANDATES}" ; return 1; } log_output_of chmod 0640 ${AMANDATES} || \ { logger "WARNING: Could not fix perms on ${AMANDATES}" ; return 1; } if [ -x /sbin/restorecon ] ; then log_output_of /sbin/restorecon ${AMANDATES} || \ { logger "WARNING: restorecon execution failed." ; return 1; } fi } create_gnupg() { # Install .gnupg directory if [ ! -d ${AMANDAHOMEDIR}/.gnupg ] ; then logger "Creating '${AMANDAHOMEDIR}/.gnupg'" log_output_of mkdir ${AMANDAHOMEDIR}/.gnupg || \ { logger "WARNING: Could not create .gnupg dir" ; return 1; } fi } get_random_lines() { # Print $1 lines of random strings to stdout. [ "$1" ] && [ $1 -gt 0 ] || \ { logger "Error: '$1' not valid number of lines" ; return 1 ; } lines=$1 [ -f "${encoder}" ] || \ { logger "Warning: Encoder '${encoder}' was not found. Random passwords cannot be generated." ; return 1; } case ${encoder} in # "foo" is a required parameter that we throw away. *uuencode*) enc_cmd="${encoder} foo" ;; *base64*) enc_cmd="${encoder}" ;; esac # Uuencode leaves a header (and footer) line, but base64 does not. # So we pad output with an extra line, and strip any trailing lines over # $lines pad_lines=`expr $lines + 1` # Increasing bs= is substantially faster than increasing count=. # The number of bytes needed to start line wrapping is implementation # specific. base64. 60b > 1 base64 encoded line for all versions tested. block_size=`expr $pad_lines \* 60` # Head -c is not portable. dd bs=${block_size} count=1 if=/dev/urandom 2>/dev/null | \ ${enc_cmd} | \ head -$pad_lines | \ tail -$lines || \ { logger "Warning: Error generating random passphrase."; return 1; } } create_ampassphrase() { # install am_passphrase file to server logger "Checking '${AMANDAHOMEDIR}/.am_passphrase' file." if [ ! -f ${AMANDAHOMEDIR}/.am_passphrase ] ; then # Separate file creation from password creation to ease debugging. logger "Creating '${AMANDAHOMEDIR}/.am_passphrase' file." log_output_of touch ${AMANDAHOMEDIR}/.am_passphrase || \ { logger "WARNING: Could not create .am_passphrase." ; return 1; } phrase=`get_random_lines 1` || return 1 # Error already logged echo ${phrase} >>${AMANDAHOMEDIR}/.am_passphrase else logger "Info: ${AMANDAHOMEDIR}/.am_passphrase already exists." fi # Fix permissions for both new or existing installations. log_output_of chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.am_passphrase || \ { logger "WARNING: Could not chown .am_passphrase" ; return 1; } log_output_of chmod 0600 ${AMANDAHOMEDIR}/.am_passphrase || \ { logger "WARNING: Could not fix permissions on .am_passphrase" ; return 1; } } create_amkey() { [ -f ${AMANDAHOMEDIR}/.am_passphrase ] || \ { logger "Error: ${AMANDAHOMEDIR}/.am_passphrase is missing, can't create amcrypt key."; return 1; } logger "Creating encryption key for amcrypt" if [ ! -f ${AMANDAHOMEDIR}/.gnupg/am_key.gpg ]; then # TODO: don't write this stuff to disk! get_random_lines 50 >${AMANDAHOMEDIR}/.gnupg/am_key || return 1 exec 3<${AMANDAHOMEDIR}/.am_passphrase # setting homedir prevents some errors, but creates a permissions # warning. perms are fixed in check_gnupg. log_output_of gpg --homedir ${AMANDAHOMEDIR}/.gnupg \ --no-permission-warning \ --no-use-agent \ --armor \ --batch \ --symmetric \ --passphrase-fd 3 \ --output ${AMANDAHOMEDIR}/.gnupg/am_key.gpg \ ${AMANDAHOMEDIR}/.gnupg/am_key || \ { logger "WARNING: Error encrypting keys." ; rm ${AMANDAHOMEDIR}/.gnupg/am_key; return 1; } # Be nice and clean up. exec 3<&- else logger "Info: Encryption key '${AMANDAHOMEDIR}/.gnupg/am_key.gpg' already exists." fi # Always try to delete unencrypted keys rm -f ${AMANDAHOMEDIR}/.gnupg/am_key } check_gnupg() { logger "Ensuring correct permissions for '${AMANDAHOMEDIR}/.gnupg'." log_output_of chown -R ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.gnupg || \ { logger "WARNING: Could not chown .gnupg dir." ; return 1; } log_output_of chmod -R u=rwX,go= ${AMANDAHOMEDIR}/.gnupg || \ { logger "WARNING: Could not set permissions on .gnupg dir." ; return 1; } # If am_key.gpg and .am_passphrase already existed, we should check # if they match! if [ -f ${AMANDAHOMEDIR}/.gnupg/am_key.gpg ] && [ -f ${AMANDAHOMEDIR}/.am_passphrase ]; then exec 3<${AMANDAHOMEDIR}/.am_passphrase # Perms warning will persist because we are not running as ${amanda_user} log_output_of gpg --homedir ${AMANDAHOMEDIR}/.gnupg \ --no-permission-warning \ --no-use-agent\ --batch \ --decrypt \ --passphrase-fd 3 \ --output /dev/null \ ${AMANDAHOMEDIR}/.gnupg/am_key.gpg || \ { logger "WARNING: .am_passphrase does not decrypt .gnupg/am_key.gpg."; return 1; } # Be nice and clean up. exec 3<&- fi } create_amandahosts() { # Install .amandahosts to server if [ ! -f ${AMANDAHOMEDIR}/.amandahosts ] ; then logger "Creating ${AMANDAHOMEDIR}/.amandahosts" log_output_of touch ${AMANDAHOMEDIR}/.amandahosts || \ { logger "WARNING: Could not create .amandahosts file." ; return 1; } fi } check_amandahosts_entry() { # Entries for client and server differ slightly # $1 username (root, ${amanda_user}) # subsequent parameters are a list of programs to check (amindexd # amidxtaped, or amdump) logger "Checking '${AMANDAHOMEDIR}/.amandahosts' for '${@}' entries." # Generate our grep expression expr="" for prog in ${@} ; do expr=${expr}"[[:blank:]]\+${prog}" done for host in localhost localhost.localdomain ; do logger "Searching .amandahosts for ^${host}${expr}" if `grep "^${host}${expr}" ${AMANDAHOMEDIR}/.amandahosts >> /dev/null` ; then continue else add_amandahosts_entry ${host} ${@} fi done } add_amandahosts_entry() { # Add entries to amandahosts. # $@ is a fully formatted entry for amandahosts logger "Appending '${@}' to amandahosts" echo "${@}" >>${AMANDAHOMEDIR}/.amandahosts || \ { logger "WARNING: Could not append to .amandahosts" ; return 1; } } check_amandahosts_perms() { logger "Ensuring correct permissions on .amandahosts" log_output_of chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.amandahosts || \ { logger "WARNING: Could not chown .amandahosts." ; return 1; } log_output_of chmod 0600 ${AMANDAHOMEDIR}/.amandahosts || \ { logger "WARNING: Could not fix permissions on .amandahosts" ; return 1; } } create_ssh_key() { # SSH RSA key generation for amdump and amrecover # $1 must be "server" or "client" KEYDIR="${AMANDAHOMEDIR}/.ssh" if [ $1 = "server" ] ; then KEYFILE="id_rsa_amdump" elif [ $1 = "client" ] ; then KEYFILE="id_rsa_amrecover" else logger "Bad parameter to create_ssh_key" ; return 1 fi COMMENT="${amanda_user}@$1" if [ ! -d ${KEYDIR} ] ; then if [ -f ${KEYDIR} ] ; then logger "Directory '${KEYDIR}' exists as a file. Renaming to '${KEYDIR}.save'." log_output_of mv ${KEYDIR} ${KEYDIR}.save || \ { logger "WARNING: Could not backup old .ssh directory." ; return 1; } fi logger "Creating directory '${KEYDIR}'." log_output_of mkdir ${KEYDIR} || \ { logger "WARNING: Could not create .ssh dir." ; return 1; } fi if [ ! -f ${KEYDIR}/${KEYFILE} ] ; then logger "Creating ssh RSA key in '${KEYDIR}/${KEYFILE}'" log_output_of ssh-keygen -q -C $COMMENT -t rsa -f ${KEYDIR}/${KEYFILE} -N '' || \ { logger "WARNING: Error generating ssh key" ; return 1; } fi logger "Setting ownership and permissions for '${KEYDIR}' and '${KEYDIR}/${KEYFILE}*'" log_output_of chown ${amanda_user}:${amanda_group} ${KEYDIR} ${KEYDIR}/${KEYFILE}* || \ { logger "WARNING: Could not chown one of ${KEYDIR} or ${KEYFILE}"; return 1; } log_output_of chmod 0750 ${KEYDIR} || \ { logger "WARNING: Could not fix permissions on ${KEYDIR}"; return 1; } log_output_of chmod 0600 ${KEYDIR}/${KEYFILE}* || \ { logger "WARNING: Could not fix permissions on ${KEYFILE}"; return 1; } } create_profile() { # environment variables (~${amanda_user}/.profile) logger "Checking for '${AMANDAHOMEDIR}/.profile'." if [ ! -f ${AMANDAHOMEDIR}/.profile ] ; then log_output_of touch ${AMANDAHOMEDIR}/.profile || \ { logger "WARNING: Could not create .profile" ; return 1; } fi } check_profile(){ logger "Checking for ${SBINDIR} in path statement." if [ -z "`grep PATH.*${SBINDIR} ${AMANDAHOMEDIR}/.profile`" ] ; then echo "PATH=\"\$PATH:${SBINDIR}\"" >>${AMANDAHOMEDIR}/.profile || \ { logger "WARNING: Could not append to .profile" ; return 1; } echo "export PATH" >>${AMANDAHOMEDIR}/.profile fi case $os in SunOS) sun_paths=/opt/csw/bin:/usr/ucb if [ -z "`grep PATH ${AMANDAHOMEDIR}/.profile | grep ${sun_paths}`" ] ; then echo "PATH=\"$PATH:${SBINDIR}:${sun_paths}\"" >>${AMANDAHOMEDIR}/.profile fi ;; esac logger "Setting ownership and permissions for '${AMANDAHOMEDIR}/.profile'" log_output_of chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.profile || \ { logger "WARNING: Could not chown .profile." ; return 1; } log_output_of chmod 0640 ${AMANDAHOMEDIR}/.profile || \ { logger "WARNING: Could not fix permissions on .profile" ; return 1; } } install_client_conf() { # Install client config if [ "$os" = "SunOS" ] ; then install="install -m 0600 -u ${amanda_user} -g ${amanda_group}" else install="install -m 0600 -o ${amanda_user} -g ${amanda_group}" fi logger "Checking '${SYSCONFDIR}/amanda/amanda-client.conf' file." if [ ! -f ${SYSCONFDIR}/amanda/amanda-client.conf ] ; then logger "Installing amanda-client.conf." log_output_of ${install} ${AMANDAHOMEDIR}/example/amanda-client.conf \ ${SYSCONFDIR}/amanda/ || \ { logger "WARNING: Could not install amanda-client.conf" ; return 1; } else logger "Note: ${SYSCONFDIR}/amanda/amanda-client.conf exists. Please check ${AMANDAHOMEDIR}/example/amanda-client.conf for updates." fi } create_amtmp() { # Check for existence of and permissions on ${AMTMP} logger "Checking for '${AMTMP}' dir." if [ ! -d ${AMTMP} ]; then logger "Create '${AMTMP}' dir." log_output_of mkdir ${AMTMP} || \ { logger "WARNING: Could not create ${AMTMP}." ; return 1; } log_output_of chown ${amanda_user}:${amanda_group} ${AMTMP} || \ { logger "WARNING: Could not chown ${AMTMP}" ; return 1; } fi } # ------------- End Post Install Functions ----------------- # -------- End Common functions ---------- /sbin/ldconfig check_xinetd "amandaserver" case $? in 0) backup_xinetd "amandaserver" install_xinetd "amandaserver" ;; 1) install_xinetd "amandaserver" ;; 2) logger "Xinetd config not installed: either xinetd config is not present or xinetd.d is a file." ;; *) logger "bad return from check_xinetd"; exit 1 ;; esac # Amanda servers should not have the client xinetd installed. check_xinetd "amandaclient" case $? in 0) backup_xinetd "amandaclient" ;; esac check_superserver_running "xinetd" [ "$?" = "0" ] && action=restart || action=start reload_xinetd $action create_amandates check_amandates create_ampassphrase || \ logger "Info: amcryptsimple and amcrpyt will not work until .am_passphrase is created" create_gnupg create_amkey || \ logger "Info: amcrypt will not work until keys are created." # Checks permissions, but only tries decrypting if both .am_passphrase # and .gnupg/am_key.gpg exist. check_gnupg create_amandahosts check_amandahosts_entry root amindexd amidxtaped check_amandahosts_entry ${amanda_user} amdump check_amandahosts_perms create_ssh_key server create_ssh_key client create_profile check_profile install_client_conf logger "Amanda installation complete." cat $LOGFILE >> $INSTALL_LOG && { rm $LOGFILE; echo "Amanda installation log can be found in '${INSTALL_LOG}'."; } || \ echo "Amanda postinstall logs can be found in '$LOGFILE'." %postun backup_server ########################################## LOGFILE=`mktemp /tmp/amanda_server-remove.log.XXXXXXXXXXX` if [ $? -ne 0 ]; then echo "Unable to create log file!" exit 1 fi %{script_vars} # ---------- Common functions ------------ #!/bin/sh # Common Functions # Required variables: # LOGFILE # SYSCONFDIR # os logger() { # A non-annoying way to log stuff # ${@} is all the parameters, also known as the message. Quoting the input # preserves whitespace. msg="`date +'%b %d %Y %T'`: ${@}" echo "${msg}" >> ${LOGFILE} } log_output_of() { # A non-annoying way to log output of commands # ${@} is all the parameters supplied to the function. just execute it, # and capture the output in a variable. then log that. output=`"${@}" 2>&1` ret=$? if [ -n "${output}" ] ; then logger "${1}: ${output}" fi return ${ret} } check_superserver() { # Check for the superserver $1 for the config $2 case $1 in xinetd) check_xinetd $2; return $?;; inetd) check_inetd $2; return $?;; launchd) check_launchd $2; return $?;; smf) check_smf $2; return $?;; esac } check_xinetd() { # Checks for an xinetd install and a config name passed as the first # parameter. # Returns: # 0 if the file exists, # 1 if it does not, # 2 if xinetd.d/ does not exist or is a file if [ -d ${SYSCONFDIR}/xinetd.d ] ; then if [ -f ${SYSCONFDIR}/xinetd.d/${1} ] ; then logger "Found existing xinetd config: ${1}" return 0 else return 1 fi else # No xinetd installation. return 2 fi } check_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac if [ -e ${inetd_conf} ] ; then if grep "${1}" ${inetd_conf} > /dev/null ; then logger "Found existing inetd config: ${1}" return 0 else return 1 fi else # No inetd installation. return 2 fi } check_launchd() { # TODO: refactor OS X scripts. : } check_smf() { # Only for solaris! This check only notices if an amanda service is active, # it does not notice server vs client entries. log_output_of svcs -H "*amanda*" || { \ logger "No amanda service found."; return 1; } } check_superserver_running() { # Check for the given superserver, $1, in the output of ps -ef, or on # mac/bsd ps ax. # Return codes: # 0: $1 is running # 1: $1 is not running # 2: $1 is not valid for this system case $1 in # Linux or Solaris. This works despite sol10 using SMF. inetd) ps_flags='-e';; xinetd) ps_flags='-e';; # Mac OS X launchd) ps_flags='aux';; *) echo "Bad superserver."; return 2 ;; esac if [ "$1" = "launchd" ] && [ `uname` != 'Darwin' ]; then echo "Only darwin uses launchd" return 2 fi if [ "$1" = "xinetd" ] && [ "$os" = 'SunOS' ] && \ [ `uname -r` = "5.10" ]; then echo "Solaris 10 does not use xinetd." return 2 fi # Search for $1, PROC=`ps ${ps_flags} | grep -v 'grep'| grep "${1}"` if [ x"${PROC}" != x ]; then return 0 else return 1 fi } backup_xinetd() { log_output_of mv ${SYSCONFDIR}/xinetd.d/${1} ${AMANDAHOMEDIR}/example/xinetd.${1}.orig || \ { logger "WARNING: Could not back up existing xinetd configuration '${1}'"; return 1; } logger "Old xinetd config for '${1}' backed up to '${AMANDAHOMEDIR}/example/xinetd.${1}.orig'" } backup_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # Backs up any amanda configuration it finds log_output_of sed -n "/^amanda .* amandad/w ${AMANDAHOMEDIR}/example/inetd.orig" ${inetd_conf} || \ { logger "WARNING: could not write ${AMANDAHOMEDIR}/example/inetd.orig"; return 1; } log_output_of sed "/^amanda .* amandad/d" ${inetd_conf} > \ ${inetd_conf}.tmp || \ { logger "WARNING: could not write ${inetd_conf}.tmp"; return 1; } log_output_of mv ${inetd_conf}.tmp ${inetd_conf} || \ { logger "WARNING: could not overwrite ${inetd_conf}, old config not removed."; return 1; } logger "Old inetd config for amanda backed up to ${AMANDAHOMEDIR}/example/inetd.orig" } backup_smf() { # Solaris only. I *think* this should be consistent across all smf installs svccfg -s *amanda* > ${AMANDAHOMEDIR}/example/amanda_smf.xml.orig || {\ logger "Warning: export of existing amanda service failed."; return 1; } log_output_of inetadm -d *amanda* || { \ # Not critical, we don't need to return if this fails. logger "Warning: disabling existing amanda service failed."; } log_output_of svccfg delete -f *amanda* || { \ logger "Error: removing the old amanda service failed."; return 1; } } install_xinetd() { log_output_of install -m 0644 ${AMANDAHOMEDIR}/example/xinetd.${1} ${SYSCONFDIR}/xinetd.d/${1} || \ { logger "WARNING: Could not install xinetd configuration '${1}'" ; return 1; } logger "Installed xinetd config for ${1}." } install_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # This one is hard to log because we're just appending. logger "Appending ${AMANDAHOMEDIR}/example/inetd.conf.${1} to ${inetd_conf}" cat ${AMANDAHOMEDIR}/example/inetd.conf.${1} >> ${inetd_conf} } install_smf() { # First parameter should be the name of the service to install # (amandaserver, or amandaclient). ver=`uname -r` case $ver in 5.10) # Use inetadm and svcadm. log_output_of ${basedir}/usr/sbin/inetconv -f -i ${AMANDAHOMEDIR}/example/inetd.conf.${1} || { \ logger "Warning: Failed to create Amanda SMF manifest. Check the system log."; return 1; } log_output_of ${basedir}/usr/sbin/inetadm -e svc:/network/amanda/tcp || { \ logger "Warning: Failed to enable Amanda service. See system log for more information."; return 1; } log_output_of ${basedir}/usr/sbin/svcadm restart network/amanda/tcp || { \ logger "Warning: Failed to restart Amanda service. See system log for details."; return 1; } ;; 5.8|5.9) logger "Solaris 8 and 9 use inetd, not SMF tools." return 1 ;; *) # I don't know what to do... logger "ERROR: Unsupported and untested version of Solaris: $ver" return 1 ;; esac } reload_xinetd() { # Default action is to try reload. case $1 in reload|restart|start) action=$1 ;; "") action=reload ;; *) logger "WARNING: bad argument to reload_xinetd: $1" return 1 ;; esac if [ "$action" = "reload" ] ; then logger "Reloading xinetd configuration..." log_output_of ${SYSCONFDIR}/init.d/xinetd $action # Don't exit! if [ $? -ne 0 ] ; then logger "xinetd reload failed. Attempting restart..." action=restart fi fi if [ "$action" = "restart" ] || [ "$action" = "start" ]; then logger "${action}ing xinetd." log_output_of ${SYSCONFDIR}/init.d/xinetd $action || \ { logger "WARNING: $action failed." ; return 1; } fi } reload_inetd() { # Default action is to try reload. if [ "x$1" = "x" ]; then action="reload" elif [ "$1" = "reload" ] || [ "$1" = "restart" ]; then action="$1" else logger "WARNING: bad argument to reload_inetd: $1" return 1 fi if [ "$1" = "reload" ] ; then logger "Reloading inetd configuration..." log_output_of ${SYSCONFDIR}/init.d/inetd $1 # Don't exit! if [ $? -ne 0 ] ; then logger "inetd reload failed. Attempting restart..." log_output_of ${SYSCONFDIR}/init.d/inetd restart || \ { logger "WARNING: restart failed." ; return 1; } fi else # Must be restart... logger "Restarting inetd." log_output_of ${SYSCONFDIR}/init.d/inetd $1 || \ { logger "WARNING: ${1} failed." ; return 1; } fi } # End Common functions #!/bin/sh # ------------- Begin Post Removal Functions ----------------- # Functions used for post removal actions rm_xinetd() { # Remove the xinetd configuration file $1. check_xinetd should be # executed first. logger "Removing xinetd configuration $1" log_output_of rm ${SYSCONFDIR}/xinetd.d/$1 } rm_inetd() { # Remove amanda entries from inetd.conf logger "Removing amanda's inetd.conf entries" log_output_of sed -i "/^amanda .* amandad/d" } rm_smf() { # Remove the amanda service from solaris style service framework. ret=0; export ret logger "Removing amanda's smf entry" log_output_of svcadm disable $1 || { ret=1; } log_output_of svccfg delete $1 || { ret=1; } return $ret } rm_user() { # Delete the user provided as first parameter ($1) logger "Deleting user: $1" log_output_of userdel $1 } # ------------- End Post Removal Functions ----------------- # -------- End Common functions ---------- /sbin/ldconfig # Check for parameter to script (are we upgrading?) if [ $1 -gt 0 ]; then # We're upgrading action="upgrade" else # We're uninstalling action="uninstall" fi # See http://fedoraproject.org/wiki/Packaging/ScriptletSnippets for the reason # we only remove xinetd on uninstall. if [ "$action" = "uninstall" ]; then # Check for and remove existing xinetd configs check_xinetd "amandaserver" if [ $? -eq 0 ] ; then rm_xinetd "amandaserver" check_superserver_running "xinetd" && reload_xinetd fi check_inetd "amandaserver" if [ $? -eq 0 ] ; then rm_inetd "amandaserver" check_superserver_running "inetd" && reload_inetd fi if [ -f ${SYSCONFDIR}/amandates ]; then logger "Removing ${SYSCONFDIR}/amandates..." rm -rf ${SYSCONFDIR}/amandates fi if [ -d ${SYSCONFDIR}/amanda ]; then logger "Removing ${SYSCONFDIR}/amanda if empty..." rmdir ${SYSCONFDIR}/amanda 2> /dev/null || true fi if [ -d /var/lib/amanda/gnutar-lists ]; then rm -rf /var/lib/amanda/gnutar-lists # Remove ${amanda_user} from sensitive groups. if which deluser >/dev/null 2>&1 ; then for group in tape; do # only call deluser when amandabackup is in $group if getent group "$group" | awk -F: '{ print $4 }' | awk -F, '{ for (i=1; i <= NF; i++ ) print $i }' | grep "^${amanda_user}$" > /dev/null; then deluser ${amanda_user} $group || true fi done fi echo "Amanda removal log can be found in '$LOGFILE'." fi %pre backup_client ########################################## LOGFILE=`mktemp /tmp/amanda_client-preinst.log.XXXXXXXXXXX` if [ $? -ne 0 ]; then echo "Unable to create log file!" exit 1 fi %{script_vars} # ---------- Common functions ------------ #!/bin/sh # Common Functions # Required variables: # LOGFILE # SYSCONFDIR # os logger() { # A non-annoying way to log stuff # ${@} is all the parameters, also known as the message. Quoting the input # preserves whitespace. msg="`date +'%b %d %Y %T'`: ${@}" echo "${msg}" >> ${LOGFILE} } log_output_of() { # A non-annoying way to log output of commands # ${@} is all the parameters supplied to the function. just execute it, # and capture the output in a variable. then log that. output=`"${@}" 2>&1` ret=$? if [ -n "${output}" ] ; then logger "${1}: ${output}" fi return ${ret} } check_superserver() { # Check for the superserver $1 for the config $2 case $1 in xinetd) check_xinetd $2; return $?;; inetd) check_inetd $2; return $?;; launchd) check_launchd $2; return $?;; smf) check_smf $2; return $?;; esac } check_xinetd() { # Checks for an xinetd install and a config name passed as the first # parameter. # Returns: # 0 if the file exists, # 1 if it does not, # 2 if xinetd.d/ does not exist or is a file if [ -d ${SYSCONFDIR}/xinetd.d ] ; then if [ -f ${SYSCONFDIR}/xinetd.d/${1} ] ; then logger "Found existing xinetd config: ${1}" return 0 else return 1 fi else # No xinetd installation. return 2 fi } check_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac if [ -e ${inetd_conf} ] ; then if grep "${1}" ${inetd_conf} > /dev/null ; then logger "Found existing inetd config: ${1}" return 0 else return 1 fi else # No inetd installation. return 2 fi } check_launchd() { # TODO: refactor OS X scripts. : } check_smf() { # Only for solaris! This check only notices if an amanda service is active, # it does not notice server vs client entries. log_output_of svcs -H "*amanda*" || { \ logger "No amanda service found."; return 1; } } check_superserver_running() { # Check for the given superserver, $1, in the output of ps -ef, or on # mac/bsd ps ax. # Return codes: # 0: $1 is running # 1: $1 is not running # 2: $1 is not valid for this system case $1 in # Linux or Solaris. This works despite sol10 using SMF. inetd) ps_flags='-e';; xinetd) ps_flags='-e';; # Mac OS X launchd) ps_flags='aux';; *) echo "Bad superserver."; return 2 ;; esac if [ "$1" = "launchd" ] && [ `uname` != 'Darwin' ]; then echo "Only darwin uses launchd" return 2 fi if [ "$1" = "xinetd" ] && [ "$os" = 'SunOS' ] && \ [ `uname -r` = "5.10" ]; then echo "Solaris 10 does not use xinetd." return 2 fi # Search for $1, PROC=`ps ${ps_flags} | grep -v 'grep'| grep "${1}"` if [ x"${PROC}" != x ]; then return 0 else return 1 fi } backup_xinetd() { log_output_of mv ${SYSCONFDIR}/xinetd.d/${1} ${AMANDAHOMEDIR}/example/xinetd.${1}.orig || \ { logger "WARNING: Could not back up existing xinetd configuration '${1}'"; return 1; } logger "Old xinetd config for '${1}' backed up to '${AMANDAHOMEDIR}/example/xinetd.${1}.orig'" } backup_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # Backs up any amanda configuration it finds log_output_of sed -n "/^amanda .* amandad/w ${AMANDAHOMEDIR}/example/inetd.orig" ${inetd_conf} || \ { logger "WARNING: could not write ${AMANDAHOMEDIR}/example/inetd.orig"; return 1; } log_output_of sed "/^amanda .* amandad/d" ${inetd_conf} > \ ${inetd_conf}.tmp || \ { logger "WARNING: could not write ${inetd_conf}.tmp"; return 1; } log_output_of mv ${inetd_conf}.tmp ${inetd_conf} || \ { logger "WARNING: could not overwrite ${inetd_conf}, old config not removed."; return 1; } logger "Old inetd config for amanda backed up to ${AMANDAHOMEDIR}/example/inetd.orig" } backup_smf() { # Solaris only. I *think* this should be consistent across all smf installs svccfg -s *amanda* > ${AMANDAHOMEDIR}/example/amanda_smf.xml.orig || {\ logger "Warning: export of existing amanda service failed."; return 1; } log_output_of inetadm -d *amanda* || { \ # Not critical, we don't need to return if this fails. logger "Warning: disabling existing amanda service failed."; } log_output_of svccfg delete -f *amanda* || { \ logger "Error: removing the old amanda service failed."; return 1; } } install_xinetd() { log_output_of install -m 0644 ${AMANDAHOMEDIR}/example/xinetd.${1} ${SYSCONFDIR}/xinetd.d/${1} || \ { logger "WARNING: Could not install xinetd configuration '${1}'" ; return 1; } logger "Installed xinetd config for ${1}." } install_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # This one is hard to log because we're just appending. logger "Appending ${AMANDAHOMEDIR}/example/inetd.conf.${1} to ${inetd_conf}" cat ${AMANDAHOMEDIR}/example/inetd.conf.${1} >> ${inetd_conf} } install_smf() { # First parameter should be the name of the service to install # (amandaserver, or amandaclient). ver=`uname -r` case $ver in 5.10) # Use inetadm and svcadm. log_output_of ${basedir}/usr/sbin/inetconv -f -i ${AMANDAHOMEDIR}/example/inetd.conf.${1} || { \ logger "Warning: Failed to create Amanda SMF manifest. Check the system log."; return 1; } log_output_of ${basedir}/usr/sbin/inetadm -e svc:/network/amanda/tcp || { \ logger "Warning: Failed to enable Amanda service. See system log for more information."; return 1; } log_output_of ${basedir}/usr/sbin/svcadm restart network/amanda/tcp || { \ logger "Warning: Failed to restart Amanda service. See system log for details."; return 1; } ;; 5.8|5.9) logger "Solaris 8 and 9 use inetd, not SMF tools." return 1 ;; *) # I don't know what to do... logger "ERROR: Unsupported and untested version of Solaris: $ver" return 1 ;; esac } reload_xinetd() { # Default action is to try reload. case $1 in reload|restart|start) action=$1 ;; "") action=reload ;; *) logger "WARNING: bad argument to reload_xinetd: $1" return 1 ;; esac if [ "$action" = "reload" ] ; then logger "Reloading xinetd configuration..." log_output_of ${SYSCONFDIR}/init.d/xinetd $action # Don't exit! if [ $? -ne 0 ] ; then logger "xinetd reload failed. Attempting restart..." action=restart fi fi if [ "$action" = "restart" ] || [ "$action" = "start" ]; then logger "${action}ing xinetd." log_output_of ${SYSCONFDIR}/init.d/xinetd $action || \ { logger "WARNING: $action failed." ; return 1; } fi } reload_inetd() { # Default action is to try reload. if [ "x$1" = "x" ]; then action="reload" elif [ "$1" = "reload" ] || [ "$1" = "restart" ]; then action="$1" else logger "WARNING: bad argument to reload_inetd: $1" return 1 fi if [ "$1" = "reload" ] ; then logger "Reloading inetd configuration..." log_output_of ${SYSCONFDIR}/init.d/inetd $1 # Don't exit! if [ $? -ne 0 ] ; then logger "inetd reload failed. Attempting restart..." log_output_of ${SYSCONFDIR}/init.d/inetd restart || \ { logger "WARNING: restart failed." ; return 1; } fi else # Must be restart... logger "Restarting inetd." log_output_of ${SYSCONFDIR}/init.d/inetd $1 || \ { logger "WARNING: ${1} failed." ; return 1; } fi } # End Common functions #!/bin/sh # These functions are included by various different installers. # We assume that the following variables are defined in the main script: # amanda_user: the amanda account username # amanda_group: the amanda account's group # amandahomedir: a directory to use as amanda's home # deb_uid: sepecific uid amanda_user should get on deb style systems. # dist: used on linux for the distro. # LOGFILE: a log file we append to # os: Linux, Darwin, SunOS, `uname`... # wanted_shell: Linux/SunOS/OSX all keep them in different places # SYSCONFDIR: location of system config files (ie, /etc) # LOGDIR: logging directory for amanda # These variables are defined, but null to allow checking names checked_uid= export checked_uid # PreInstall Functions create_user() { case $os in Linux|SunOS) # Create the amanda user with a specific uid on deb systems if [ "x${dist}" = "xDebian" ] || [ "x${dist}" = "xUbuntu" ] ; then uid_flag="-u ${deb_uid}" else uid_flag= fi logger "Checking for user: ${amanda_user}" # we want the output of id, but if the user doesn't exist, # sterr output just confuses things ID=`id ${amanda_user} 2> /dev/null | sed 's/uid=\([0-9]*\).*/\1/'` if [ "${ID}x" = "x" ] ; then logger "Adding ${amanda_user}." log_output_of useradd -c "Amanda" \ -g ${amanda_group} \ ${uid_flag} \ -d ${AMANDAHOMEDIR} \ -s ${wanted_shell} ${amanda_user} || \ { logger "WARNING: Could not create user ${amanda_user}. Installation will fail." ; return 1 ; } logger "Created ${amanda_user} with blank password." if [ "x$os" = "xLinux" ] && [ "x${dist}" != "xSuSE" ]; then # Lock the amanda account until admin sets password log_output_of passwd -l ${amanda_user} && { \ logger "${info_create_user_success}" logger "${info_unlock_account}" } || { \ logger "${warning_user_passwd}"; } fi if [ "x$os" = "xSunOS" ]; then r=`uname -r` case $r in 5.8|5.9) log_output_of passwd -l ${amanda_user} ;; 5.10) # Special login-lock, while allowing execution. log_output_of passwd -N ${amanda_user} && { \ logger "${info_create_user_success_sol}" logger "${info_unlock_account}" } || { \ logger "${warning_user_passwd}"; } ;; esac fi else # The user already existed logger "The Amanda user '${amanda_user}' exists on this system." fi ;; Darwin) : #TODO ;; esac } add_profiles() { # Solaris only: Add a comma separated list of rights profiles to the # $amanda_user. Replaces any existing profiles listed on the account. log_output_of usermod -P "\"$*\"" ${amanda_user} || { logger "Warning: Rights profiles were not added. Some types of backup may not work until these rights profiles are givent to ${amanda_backup}: '$*'" return 1; } } add_group() { # First, try to add the group, detect via return code if it # already exists. Then add ${amanda_user} to the group without # checking if account is already a member. (check_user should # already have been called). # # Works on linux and solaris. OSX has different tools. [ "x${1}" = "x" ] && { logger "Error: first argument was not a group to add." ; return 1 ; } group_to_add=${1} log_output_of groupadd ${group_to_add} rc=$? # return of 0 means group was added; 9 means group existed. if [ $rc -eq 0 ] || [ $rc -eq 9 ]; then logger "Adding ${amanda_user} to ${group_to_add}" # Generate a comma separated list of existing supplemental groups. # Linux prefaces output with '<username> : '. existing_sup_groups=`groups ${amanda_user}|sed 's/.*: //;s/ /,/g'` # usermod append is -A on Suse, all other linux use -a, and # -A means something else entirely on solaris. So we just use # -G, and append a list of the current groups from id. # So far, all linux distros have usermod log_output_of usermod -G ${existing_sup_groups},${group_to_add} ${amanda_user} || { \ logger "Nonfatal ERROR: Failed to add ${group_to_add}." logger "${error_group_member}" ; return 1 ; } else logger "Error: groupadd failed in an unexpected way. return code='$rc'" return 1 fi } # All check_user_* functions check various parameters of ${amanda_user}'s # account. Return codes: # 0 = success # 1 = error # 2 = usage or other error. more info will be logged check_user_group() { # checks the system group file for ${amanda_user}'s membership in # the group named $1. err=0 [ "x" = "x$1" ] && { logger "check_user_group: no group given"; return 1; } logger "Verify ${amanda_user}'s primary group = $1 " # Check if the group exists, disregarding membership. group_entry=`grep "^${2}" ${SYSCONFDIR}/group 2> /dev/null` if [ ! "x" = "x${group_entry}" ]; then # Assume the user exists, and check the user's primary group. GROUP=`id ${amanda_user} 2> /dev/null |\ cut -d " " -f 2 |\ sed 's/.*gid=[0-9]*(\([^ ()]*\))/\1/'` if [ ! "x${GROUP}" = "x${1}" ] ; then logger "${amanda_user} not a member of ${1}" err=1 fi else logger "User's primary group '${1}' does not exist" err=1 fi return $err } check_user_supplemental_group() { # Checks for the group ${1}, and adds ${amanda_user} if missing. # Other groups are preserved. err=0 [ "x" = "x$1" ] && { logger "check_user_supplemental_group: no supplemental group given"; return 1; } sup_group=${1} logger "Verify ${amanda_user} is a member of ${sup_group}." # First, check if the supplementary group exists. sup_group_entry=`grep "${sup_group}" ${SYSCONFDIR}/group 2>/dev/null` if [ ! "x" = "x${sup_group_entry}" ]; then SUP_MEM=`echo ${sup_group_entry} | cut -d: -f4` # Check if our user is a member. case ${SUP_MEM} in *${amanda_user}*) : ;; *) logger "${amanda_user} is not a member of supplemental group ${sup_group}." err=1 ;; esac else logger "Supplemental group ${sup_group} does not exist" err=1 fi return $err } check_user_shell() { # Confirms the passwd file's shell field for ${amanda_user} is $1 [ "x" = "x$1" ] && { logger "check_user_shell: no shell given"; return 1; } wanted_shell=$1; export wanted_shell logger "Verify ${amanda_user}'s shell is ${wanted_shell}." real_shell=`grep "^${amanda_user}" ${SYSCONFDIR}/passwd | cut -d: -f7` export real_shell if [ ! "x${real_shell}" = "x${wanted_shell}" ] ; then logger "WARNING: ${amanda_user} default shell= ${wanted_shell}" logger "WARNING: ${amanda_user} existing shell: ${real_shell}" logger "${warning_user_shell}" return 1 fi } check_user_homedir() { # Confirm the passwd file's homedir field for ${amanda_user} is $1 [ "x" = "x$1" ] && { logger "check_user_homedir: no homedir given"; return 1; } HOMEDIR=`grep "^${amanda_user}" ${SYSCONFDIR}/passwd | cut -d: -f6` if [ ! "x${HOMEDIR}" = "x${1}" ] ; then logger "${warning_user_homedir}" return 1 fi } check_user_uid() { # Confirm that ${amanda_user}'s UID is $1. # Debian systems must use a specific UID [ "x" = "x$1" ] && { logger "check_user_uid: no uid given"; return 1; } ID=`id ${amanda_user} 2> /dev/null | sed 's/uid=\([0-9]*\).*/\1/'` if [ ! ${ID} -eq ${1} ] ; then checked_uid=${1}; export checked_uid logger "${warning_user_uid_debian}" return 1 fi } check_homedir() { # Checks that the homedir has correct permissions and belongs to correct # user. Uses $amanda_user and $amanda_group. if [ -d ${AMANDAHOMEDIR} ] ; then OWNER_GROUP=`ls -dl ${AMANDAHOMEDIR} | awk '{ print $3" "$4; }'` [ "x$OWNER_GROUP" = "x${amanda_user} ${amanda_group}" ] || \ logger "${warning_homedir_owner}" return $? else logger "homedir ${AMANDAHOMEDIR} does not exist." return 1 fi } create_homedir() { # Creates the homedir, if necessary, and fixes ownership. if [ ! -d ${AMANDAHOMEDIR} ] ; then logger "Creating ${AMANDAHOMEDIR}" log_output_of mkdir -p -m 0750 ${AMANDAHOMEDIR} || { logger "WARNING: Could not create ${AMANDAHOMEDIR}" ; return 1 ; } fi log_output_of chown -R ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR} || { logger "WARNING: Could not chown ${AMANDAHOMEDIR}" ; return 1 ; } } create_logdir() { if [ -d ${LOGDIR} ] || [ -f ${LOGDIR} ] ; then logger "Found existing ${LOGDIR}" log_output_of mv ${LOGDIR} ${LOGDIR}.save || \ { logger "WARNING: Could not backup existing log directory: ${LOGDIR}" ; return 1 ; } fi logger "Creating ${LOGDIR}." log_output_of mkdir -p -m 0750 ${LOGDIR} || \ { logger "WARNING: Could not create ${LOGDIR}" ; return 1 ; } if [ -d ${LOGDIR}.save ] || [ -f ${LOGDIR}.save ] ; then # Move the saved log into the logdir. log_output_of mv ${LOGDIR}.save ${LOGDIR} fi log_output_of chown -R ${amanda_user}:${amanda_group} ${LOGDIR} || \ { logger "WARNING: Could not chown ${LOGDIR}" ; return 1 ; } } # Info, Warning, and Error strings used by the installer info_create_user_success="NOTE: Set a password and unlock the ${amanda_user} account before running Amanda." info_create_user_success_sol="NOTE: Account is set as non-login. If interactive login is required: a password must be set, and the account activated for login." info_unlock_account=" The superuser can unlock the account by running: # passwd -u ${amanda_user} " info_existing_installs="Pre-existing Amanda installations must confirm: -${SYSCONFDIR}/amanda/* should have 'dumpuser' set to '${amanda_user}'. -${AMANDAHOMEDIR}/.amandahosts on client systems should allow connections by '${amanda_user}'." warning_user_password="WARNING: '${amanda_user}' no password. An error occured when locking the account. SET A PASSWORD NOW: # passwd ${amanda_user}" error_group_member="Nonfatal ERROR: Amanda will not run until '${amanda_user}' is a member the preceeding group. Install will continue..." warning_user_shell="WARNING: The user '${amanda_user}' has a non-default shell. Other shells have not been tested." warning_user_homedir="WARNING: The user '${amanda_user}' must have its home directory set to '${AMANDAHOMEDIR}' Please correct before using Amanda." warning_user_uid_debian="WARNING: Debian packages were built assuming that ${amanda_user} uid = ${checked_uid}. The uid of ${amanda_user} is different on this system. Files owned by ${checked_uid} must be chowned to ${amanda_user}." warning_homedir_owner="WARNING: The ${amanda_user}'s home directory,'${AMANDAHOMEDIR}' ownership must be changed to '${amanda_user}:${amanda_group}'. " # --------------- End included Functions ----------------- # -------- End Common functions ---------- logger "Preparing to install: %{amanda_version_info}" create_user check_user_group "${amanda_group}" || add_group "${amanda_group}" check_user_shell "${wanted_shell}" check_user_homedir "${AMANDAHOMEDIR}" check_homedir || create_homedir create_logdir logger "Preinstall done." cat $LOGFILE >> $INSTALL_LOG && rm $LOGFILE || \ echo "Amanda preinstall logs can be found in '$LOGFILE'." %post backup_client ########################################## LOGFILE=`mktemp /tmp/amanda_client-postinst.log.XXXXXXXXXXX` if [ $? -ne 0 ]; then echo "Unable to create log file!" exit 1 fi %{script_vars} AMANDATES=%{AMANDATES} # ---------- Common functions ------------ #!/bin/sh # Common Functions # Required variables: # LOGFILE # SYSCONFDIR # os logger() { # A non-annoying way to log stuff # ${@} is all the parameters, also known as the message. Quoting the input # preserves whitespace. msg="`date +'%b %d %Y %T'`: ${@}" echo "${msg}" >> ${LOGFILE} } log_output_of() { # A non-annoying way to log output of commands # ${@} is all the parameters supplied to the function. just execute it, # and capture the output in a variable. then log that. output=`"${@}" 2>&1` ret=$? if [ -n "${output}" ] ; then logger "${1}: ${output}" fi return ${ret} } check_superserver() { # Check for the superserver $1 for the config $2 case $1 in xinetd) check_xinetd $2; return $?;; inetd) check_inetd $2; return $?;; launchd) check_launchd $2; return $?;; smf) check_smf $2; return $?;; esac } check_xinetd() { # Checks for an xinetd install and a config name passed as the first # parameter. # Returns: # 0 if the file exists, # 1 if it does not, # 2 if xinetd.d/ does not exist or is a file if [ -d ${SYSCONFDIR}/xinetd.d ] ; then if [ -f ${SYSCONFDIR}/xinetd.d/${1} ] ; then logger "Found existing xinetd config: ${1}" return 0 else return 1 fi else # No xinetd installation. return 2 fi } check_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac if [ -e ${inetd_conf} ] ; then if grep "${1}" ${inetd_conf} > /dev/null ; then logger "Found existing inetd config: ${1}" return 0 else return 1 fi else # No inetd installation. return 2 fi } check_launchd() { # TODO: refactor OS X scripts. : } check_smf() { # Only for solaris! This check only notices if an amanda service is active, # it does not notice server vs client entries. log_output_of svcs -H "*amanda*" || { \ logger "No amanda service found."; return 1; } } check_superserver_running() { # Check for the given superserver, $1, in the output of ps -ef, or on # mac/bsd ps ax. # Return codes: # 0: $1 is running # 1: $1 is not running # 2: $1 is not valid for this system case $1 in # Linux or Solaris. This works despite sol10 using SMF. inetd) ps_flags='-e';; xinetd) ps_flags='-e';; # Mac OS X launchd) ps_flags='aux';; *) echo "Bad superserver."; return 2 ;; esac if [ "$1" = "launchd" ] && [ `uname` != 'Darwin' ]; then echo "Only darwin uses launchd" return 2 fi if [ "$1" = "xinetd" ] && [ "$os" = 'SunOS' ] && \ [ `uname -r` = "5.10" ]; then echo "Solaris 10 does not use xinetd." return 2 fi # Search for $1, PROC=`ps ${ps_flags} | grep -v 'grep'| grep "${1}"` if [ x"${PROC}" != x ]; then return 0 else return 1 fi } backup_xinetd() { log_output_of mv ${SYSCONFDIR}/xinetd.d/${1} ${AMANDAHOMEDIR}/example/xinetd.${1}.orig || \ { logger "WARNING: Could not back up existing xinetd configuration '${1}'"; return 1; } logger "Old xinetd config for '${1}' backed up to '${AMANDAHOMEDIR}/example/xinetd.${1}.orig'" } backup_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # Backs up any amanda configuration it finds log_output_of sed -n "/^amanda .* amandad/w ${AMANDAHOMEDIR}/example/inetd.orig" ${inetd_conf} || \ { logger "WARNING: could not write ${AMANDAHOMEDIR}/example/inetd.orig"; return 1; } log_output_of sed "/^amanda .* amandad/d" ${inetd_conf} > \ ${inetd_conf}.tmp || \ { logger "WARNING: could not write ${inetd_conf}.tmp"; return 1; } log_output_of mv ${inetd_conf}.tmp ${inetd_conf} || \ { logger "WARNING: could not overwrite ${inetd_conf}, old config not removed."; return 1; } logger "Old inetd config for amanda backed up to ${AMANDAHOMEDIR}/example/inetd.orig" } backup_smf() { # Solaris only. I *think* this should be consistent across all smf installs svccfg -s *amanda* > ${AMANDAHOMEDIR}/example/amanda_smf.xml.orig || {\ logger "Warning: export of existing amanda service failed."; return 1; } log_output_of inetadm -d *amanda* || { \ # Not critical, we don't need to return if this fails. logger "Warning: disabling existing amanda service failed."; } log_output_of svccfg delete -f *amanda* || { \ logger "Error: removing the old amanda service failed."; return 1; } } install_xinetd() { log_output_of install -m 0644 ${AMANDAHOMEDIR}/example/xinetd.${1} ${SYSCONFDIR}/xinetd.d/${1} || \ { logger "WARNING: Could not install xinetd configuration '${1}'" ; return 1; } logger "Installed xinetd config for ${1}." } install_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # This one is hard to log because we're just appending. logger "Appending ${AMANDAHOMEDIR}/example/inetd.conf.${1} to ${inetd_conf}" cat ${AMANDAHOMEDIR}/example/inetd.conf.${1} >> ${inetd_conf} } install_smf() { # First parameter should be the name of the service to install # (amandaserver, or amandaclient). ver=`uname -r` case $ver in 5.10) # Use inetadm and svcadm. log_output_of ${basedir}/usr/sbin/inetconv -f -i ${AMANDAHOMEDIR}/example/inetd.conf.${1} || { \ logger "Warning: Failed to create Amanda SMF manifest. Check the system log."; return 1; } log_output_of ${basedir}/usr/sbin/inetadm -e svc:/network/amanda/tcp || { \ logger "Warning: Failed to enable Amanda service. See system log for more information."; return 1; } log_output_of ${basedir}/usr/sbin/svcadm restart network/amanda/tcp || { \ logger "Warning: Failed to restart Amanda service. See system log for details."; return 1; } ;; 5.8|5.9) logger "Solaris 8 and 9 use inetd, not SMF tools." return 1 ;; *) # I don't know what to do... logger "ERROR: Unsupported and untested version of Solaris: $ver" return 1 ;; esac } reload_xinetd() { # Default action is to try reload. case $1 in reload|restart|start) action=$1 ;; "") action=reload ;; *) logger "WARNING: bad argument to reload_xinetd: $1" return 1 ;; esac if [ "$action" = "reload" ] ; then logger "Reloading xinetd configuration..." log_output_of ${SYSCONFDIR}/init.d/xinetd $action # Don't exit! if [ $? -ne 0 ] ; then logger "xinetd reload failed. Attempting restart..." action=restart fi fi if [ "$action" = "restart" ] || [ "$action" = "start" ]; then logger "${action}ing xinetd." log_output_of ${SYSCONFDIR}/init.d/xinetd $action || \ { logger "WARNING: $action failed." ; return 1; } fi } reload_inetd() { # Default action is to try reload. if [ "x$1" = "x" ]; then action="reload" elif [ "$1" = "reload" ] || [ "$1" = "restart" ]; then action="$1" else logger "WARNING: bad argument to reload_inetd: $1" return 1 fi if [ "$1" = "reload" ] ; then logger "Reloading inetd configuration..." log_output_of ${SYSCONFDIR}/init.d/inetd $1 # Don't exit! if [ $? -ne 0 ] ; then logger "inetd reload failed. Attempting restart..." log_output_of ${SYSCONFDIR}/init.d/inetd restart || \ { logger "WARNING: restart failed." ; return 1; } fi else # Must be restart... logger "Restarting inetd." log_output_of ${SYSCONFDIR}/init.d/inetd $1 || \ { logger "WARNING: ${1} failed." ; return 1; } fi } # End Common functions #!/bin/sh # ------------- Begin Post Install Functions ----------------- # These functions are included by various different installers. # We assume that the following variables are defined in the main script: # amanda_user: the amanda account username # amanda_group: the amanda account's group # AMANDAHOMEDIR: a directory to use as amanda's home # dist: used on linux for the distro. # install_log: a log file we append to # os: Linux, Mac, Solaris, etc... # SYSCONFDIR: location of system config files (ie, /etc) # LOGDIR: logging directory for amanda # encoder: either base64 or uuencode depending on the default for this platform #TODO: gnutar-lists dir for solaris?? add_service() { # Only needed on Solaris! entry="amanda 10080/tcp # amanda backup services" # make sure amanda is in /etc/services if [ -z "`grep 'amanda' ${SYSCONFDIR}/services |grep '10080/tcp'`" ] ; then logger "Adding amanda entry to ${SYSCONFDIR}/services." echo "${entry}" >> ${SYSCONFDIR}/services fi # make sure kamanda is in /etc/services entry_2="amanda 10081/tcp famdc # amanda backup services (kerberos)" if [ -z "`grep 'kamanda' /etc/services |grep '10081/tcp'`" ] ; then logger "Adding kamanda entry to ${SYSCONFDIR}/services." echo "${entry_2}" >> ${SYSCONFDIR}/services fi } create_amandates() { logger "Creating ${AMANDATES}." if [ ! -f ${AMANDATES} ] ; then touch ${AMANDATES} || { logger "WARNING: Could not create Amandates." ; return 1; } fi } check_amandates() { logger "Ensuring correct permissions for '${AMANDATES}'." log_output_of chown ${amanda_user}:${amanda_group} ${AMANDATES} || \ { logger "WARNING: Could not chown ${AMANDATES}" ; return 1; } log_output_of chmod 0640 ${AMANDATES} || \ { logger "WARNING: Could not fix perms on ${AMANDATES}" ; return 1; } if [ -x /sbin/restorecon ] ; then log_output_of /sbin/restorecon ${AMANDATES} || \ { logger "WARNING: restorecon execution failed." ; return 1; } fi } create_gnupg() { # Install .gnupg directory if [ ! -d ${AMANDAHOMEDIR}/.gnupg ] ; then logger "Creating '${AMANDAHOMEDIR}/.gnupg'" log_output_of mkdir ${AMANDAHOMEDIR}/.gnupg || \ { logger "WARNING: Could not create .gnupg dir" ; return 1; } fi } get_random_lines() { # Print $1 lines of random strings to stdout. [ "$1" ] && [ $1 -gt 0 ] || \ { logger "Error: '$1' not valid number of lines" ; return 1 ; } lines=$1 [ -f "${encoder}" ] || \ { logger "Warning: Encoder '${encoder}' was not found. Random passwords cannot be generated." ; return 1; } case ${encoder} in # "foo" is a required parameter that we throw away. *uuencode*) enc_cmd="${encoder} foo" ;; *base64*) enc_cmd="${encoder}" ;; esac # Uuencode leaves a header (and footer) line, but base64 does not. # So we pad output with an extra line, and strip any trailing lines over # $lines pad_lines=`expr $lines + 1` # Increasing bs= is substantially faster than increasing count=. # The number of bytes needed to start line wrapping is implementation # specific. base64. 60b > 1 base64 encoded line for all versions tested. block_size=`expr $pad_lines \* 60` # Head -c is not portable. dd bs=${block_size} count=1 if=/dev/urandom 2>/dev/null | \ ${enc_cmd} | \ head -$pad_lines | \ tail -$lines || \ { logger "Warning: Error generating random passphrase."; return 1; } } create_ampassphrase() { # install am_passphrase file to server logger "Checking '${AMANDAHOMEDIR}/.am_passphrase' file." if [ ! -f ${AMANDAHOMEDIR}/.am_passphrase ] ; then # Separate file creation from password creation to ease debugging. logger "Creating '${AMANDAHOMEDIR}/.am_passphrase' file." log_output_of touch ${AMANDAHOMEDIR}/.am_passphrase || \ { logger "WARNING: Could not create .am_passphrase." ; return 1; } phrase=`get_random_lines 1` || return 1 # Error already logged echo ${phrase} >>${AMANDAHOMEDIR}/.am_passphrase else logger "Info: ${AMANDAHOMEDIR}/.am_passphrase already exists." fi # Fix permissions for both new or existing installations. log_output_of chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.am_passphrase || \ { logger "WARNING: Could not chown .am_passphrase" ; return 1; } log_output_of chmod 0600 ${AMANDAHOMEDIR}/.am_passphrase || \ { logger "WARNING: Could not fix permissions on .am_passphrase" ; return 1; } } create_amkey() { [ -f ${AMANDAHOMEDIR}/.am_passphrase ] || \ { logger "Error: ${AMANDAHOMEDIR}/.am_passphrase is missing, can't create amcrypt key."; return 1; } logger "Creating encryption key for amcrypt" if [ ! -f ${AMANDAHOMEDIR}/.gnupg/am_key.gpg ]; then # TODO: don't write this stuff to disk! get_random_lines 50 >${AMANDAHOMEDIR}/.gnupg/am_key || return 1 exec 3<${AMANDAHOMEDIR}/.am_passphrase # setting homedir prevents some errors, but creates a permissions # warning. perms are fixed in check_gnupg. log_output_of gpg --homedir ${AMANDAHOMEDIR}/.gnupg \ --no-permission-warning \ --no-use-agent \ --armor \ --batch \ --symmetric \ --passphrase-fd 3 \ --output ${AMANDAHOMEDIR}/.gnupg/am_key.gpg \ ${AMANDAHOMEDIR}/.gnupg/am_key || \ { logger "WARNING: Error encrypting keys." ; rm ${AMANDAHOMEDIR}/.gnupg/am_key; return 1; } # Be nice and clean up. exec 3<&- else logger "Info: Encryption key '${AMANDAHOMEDIR}/.gnupg/am_key.gpg' already exists." fi # Always try to delete unencrypted keys rm -f ${AMANDAHOMEDIR}/.gnupg/am_key } check_gnupg() { logger "Ensuring correct permissions for '${AMANDAHOMEDIR}/.gnupg'." log_output_of chown -R ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.gnupg || \ { logger "WARNING: Could not chown .gnupg dir." ; return 1; } log_output_of chmod -R u=rwX,go= ${AMANDAHOMEDIR}/.gnupg || \ { logger "WARNING: Could not set permissions on .gnupg dir." ; return 1; } # If am_key.gpg and .am_passphrase already existed, we should check # if they match! if [ -f ${AMANDAHOMEDIR}/.gnupg/am_key.gpg ] && [ -f ${AMANDAHOMEDIR}/.am_passphrase ]; then exec 3<${AMANDAHOMEDIR}/.am_passphrase # Perms warning will persist because we are not running as ${amanda_user} log_output_of gpg --homedir ${AMANDAHOMEDIR}/.gnupg \ --no-permission-warning \ --no-use-agent\ --batch \ --decrypt \ --passphrase-fd 3 \ --output /dev/null \ ${AMANDAHOMEDIR}/.gnupg/am_key.gpg || \ { logger "WARNING: .am_passphrase does not decrypt .gnupg/am_key.gpg."; return 1; } # Be nice and clean up. exec 3<&- fi } create_amandahosts() { # Install .amandahosts to server if [ ! -f ${AMANDAHOMEDIR}/.amandahosts ] ; then logger "Creating ${AMANDAHOMEDIR}/.amandahosts" log_output_of touch ${AMANDAHOMEDIR}/.amandahosts || \ { logger "WARNING: Could not create .amandahosts file." ; return 1; } fi } check_amandahosts_entry() { # Entries for client and server differ slightly # $1 username (root, ${amanda_user}) # subsequent parameters are a list of programs to check (amindexd # amidxtaped, or amdump) logger "Checking '${AMANDAHOMEDIR}/.amandahosts' for '${@}' entries." # Generate our grep expression expr="" for prog in ${@} ; do expr=${expr}"[[:blank:]]\+${prog}" done for host in localhost localhost.localdomain ; do logger "Searching .amandahosts for ^${host}${expr}" if `grep "^${host}${expr}" ${AMANDAHOMEDIR}/.amandahosts >> /dev/null` ; then continue else add_amandahosts_entry ${host} ${@} fi done } add_amandahosts_entry() { # Add entries to amandahosts. # $@ is a fully formatted entry for amandahosts logger "Appending '${@}' to amandahosts" echo "${@}" >>${AMANDAHOMEDIR}/.amandahosts || \ { logger "WARNING: Could not append to .amandahosts" ; return 1; } } check_amandahosts_perms() { logger "Ensuring correct permissions on .amandahosts" log_output_of chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.amandahosts || \ { logger "WARNING: Could not chown .amandahosts." ; return 1; } log_output_of chmod 0600 ${AMANDAHOMEDIR}/.amandahosts || \ { logger "WARNING: Could not fix permissions on .amandahosts" ; return 1; } } create_ssh_key() { # SSH RSA key generation for amdump and amrecover # $1 must be "server" or "client" KEYDIR="${AMANDAHOMEDIR}/.ssh" if [ $1 = "server" ] ; then KEYFILE="id_rsa_amdump" elif [ $1 = "client" ] ; then KEYFILE="id_rsa_amrecover" else logger "Bad parameter to create_ssh_key" ; return 1 fi COMMENT="${amanda_user}@$1" if [ ! -d ${KEYDIR} ] ; then if [ -f ${KEYDIR} ] ; then logger "Directory '${KEYDIR}' exists as a file. Renaming to '${KEYDIR}.save'." log_output_of mv ${KEYDIR} ${KEYDIR}.save || \ { logger "WARNING: Could not backup old .ssh directory." ; return 1; } fi logger "Creating directory '${KEYDIR}'." log_output_of mkdir ${KEYDIR} || \ { logger "WARNING: Could not create .ssh dir." ; return 1; } fi if [ ! -f ${KEYDIR}/${KEYFILE} ] ; then logger "Creating ssh RSA key in '${KEYDIR}/${KEYFILE}'" log_output_of ssh-keygen -q -C $COMMENT -t rsa -f ${KEYDIR}/${KEYFILE} -N '' || \ { logger "WARNING: Error generating ssh key" ; return 1; } fi logger "Setting ownership and permissions for '${KEYDIR}' and '${KEYDIR}/${KEYFILE}*'" log_output_of chown ${amanda_user}:${amanda_group} ${KEYDIR} ${KEYDIR}/${KEYFILE}* || \ { logger "WARNING: Could not chown one of ${KEYDIR} or ${KEYFILE}"; return 1; } log_output_of chmod 0750 ${KEYDIR} || \ { logger "WARNING: Could not fix permissions on ${KEYDIR}"; return 1; } log_output_of chmod 0600 ${KEYDIR}/${KEYFILE}* || \ { logger "WARNING: Could not fix permissions on ${KEYFILE}"; return 1; } } create_profile() { # environment variables (~${amanda_user}/.profile) logger "Checking for '${AMANDAHOMEDIR}/.profile'." if [ ! -f ${AMANDAHOMEDIR}/.profile ] ; then log_output_of touch ${AMANDAHOMEDIR}/.profile || \ { logger "WARNING: Could not create .profile" ; return 1; } fi } check_profile(){ logger "Checking for ${SBINDIR} in path statement." if [ -z "`grep PATH.*${SBINDIR} ${AMANDAHOMEDIR}/.profile`" ] ; then echo "PATH=\"\$PATH:${SBINDIR}\"" >>${AMANDAHOMEDIR}/.profile || \ { logger "WARNING: Could not append to .profile" ; return 1; } echo "export PATH" >>${AMANDAHOMEDIR}/.profile fi case $os in SunOS) sun_paths=/opt/csw/bin:/usr/ucb if [ -z "`grep PATH ${AMANDAHOMEDIR}/.profile | grep ${sun_paths}`" ] ; then echo "PATH=\"$PATH:${SBINDIR}:${sun_paths}\"" >>${AMANDAHOMEDIR}/.profile fi ;; esac logger "Setting ownership and permissions for '${AMANDAHOMEDIR}/.profile'" log_output_of chown ${amanda_user}:${amanda_group} ${AMANDAHOMEDIR}/.profile || \ { logger "WARNING: Could not chown .profile." ; return 1; } log_output_of chmod 0640 ${AMANDAHOMEDIR}/.profile || \ { logger "WARNING: Could not fix permissions on .profile" ; return 1; } } install_client_conf() { # Install client config if [ "$os" = "SunOS" ] ; then install="install -m 0600 -u ${amanda_user} -g ${amanda_group}" else install="install -m 0600 -o ${amanda_user} -g ${amanda_group}" fi logger "Checking '${SYSCONFDIR}/amanda/amanda-client.conf' file." if [ ! -f ${SYSCONFDIR}/amanda/amanda-client.conf ] ; then logger "Installing amanda-client.conf." log_output_of ${install} ${AMANDAHOMEDIR}/example/amanda-client.conf \ ${SYSCONFDIR}/amanda/ || \ { logger "WARNING: Could not install amanda-client.conf" ; return 1; } else logger "Note: ${SYSCONFDIR}/amanda/amanda-client.conf exists. Please check ${AMANDAHOMEDIR}/example/amanda-client.conf for updates." fi } create_amtmp() { # Check for existence of and permissions on ${AMTMP} logger "Checking for '${AMTMP}' dir." if [ ! -d ${AMTMP} ]; then logger "Create '${AMTMP}' dir." log_output_of mkdir ${AMTMP} || \ { logger "WARNING: Could not create ${AMTMP}." ; return 1; } log_output_of chown ${amanda_user}:${amanda_group} ${AMTMP} || \ { logger "WARNING: Could not chown ${AMTMP}" ; return 1; } fi } # ------------- End Post Install Functions ----------------- # -------- End Common functions ---------- /sbin/ldconfig check_xinetd "amandaclient" case $? in 0) backup_xinetd "amandaclient" install_xinetd "amandaclient" ;; 1) install_xinetd "amandaclient" ;; 2) logger "Xinetd config not installed: either xinetd config is not present or xinetd.d is a file." ;; *) logger "bad return from check_xinetd"; exit 1 ;; esac # Amanda clients should not have the server xinetd installed. check_xinetd "amandaserver" case $? in 0) backup_xinetd "amandaserver" ;; esac reload_xinetd create_amandates check_amandates create_ampassphrase || \ logger "Info: amcryptsimple and amcrpyt will not work until .am_passphrase is created" create_gnupg create_amkey || \ logger "Info: amcrypt will not work until keys are created." # Checks permissions, but only tries decrypting if both .am_passphrase # and .gnupg/am_key.gpg exist. check_gnupg create_amandahosts check_amandahosts_entry ${amanda_user} amdump check_amandahosts_perms create_ssh_key server create_ssh_key client create_profile check_profile install_client_conf logger "Amanda installation complete." cat $LOGFILE >> $INSTALL_LOG && { rm $LOGFILE; echo "Amanda installation log can be found in '${INSTALL_LOG}'."; } || \ echo "Amanda postinstall logs can be found in '$LOGFILE'." echo "`date +'%b %e %Y %T'`: Sending anonymous distribution and version information to Zmanda" >> ${INSTALL_LOG} if [ -x /usr/bin/wget ]; then /usr/bin/wget -q -o /dev/null -O - --timeout=5 http://www.zmanda.com/amanda-tips.php\?version=%{amanda_version}\&os=%{disttag}%{distver}\&type=client fi %postun backup_client ########################################## LOGFILE=`mktemp /tmp/amanda_client-remove.log.XXXXXXXXXXX` if [ $? -ne 0 ]; then echo "Unable to create log file!" exit 1 fi %{script_vars} # ---------- Common functions ------------ #!/bin/sh # Common Functions # Required variables: # LOGFILE # SYSCONFDIR # os logger() { # A non-annoying way to log stuff # ${@} is all the parameters, also known as the message. Quoting the input # preserves whitespace. msg="`date +'%b %d %Y %T'`: ${@}" echo "${msg}" >> ${LOGFILE} } log_output_of() { # A non-annoying way to log output of commands # ${@} is all the parameters supplied to the function. just execute it, # and capture the output in a variable. then log that. output=`"${@}" 2>&1` ret=$? if [ -n "${output}" ] ; then logger "${1}: ${output}" fi return ${ret} } check_superserver() { # Check for the superserver $1 for the config $2 case $1 in xinetd) check_xinetd $2; return $?;; inetd) check_inetd $2; return $?;; launchd) check_launchd $2; return $?;; smf) check_smf $2; return $?;; esac } check_xinetd() { # Checks for an xinetd install and a config name passed as the first # parameter. # Returns: # 0 if the file exists, # 1 if it does not, # 2 if xinetd.d/ does not exist or is a file if [ -d ${SYSCONFDIR}/xinetd.d ] ; then if [ -f ${SYSCONFDIR}/xinetd.d/${1} ] ; then logger "Found existing xinetd config: ${1}" return 0 else return 1 fi else # No xinetd installation. return 2 fi } check_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac if [ -e ${inetd_conf} ] ; then if grep "${1}" ${inetd_conf} > /dev/null ; then logger "Found existing inetd config: ${1}" return 0 else return 1 fi else # No inetd installation. return 2 fi } check_launchd() { # TODO: refactor OS X scripts. : } check_smf() { # Only for solaris! This check only notices if an amanda service is active, # it does not notice server vs client entries. log_output_of svcs -H "*amanda*" || { \ logger "No amanda service found."; return 1; } } check_superserver_running() { # Check for the given superserver, $1, in the output of ps -ef, or on # mac/bsd ps ax. # Return codes: # 0: $1 is running # 1: $1 is not running # 2: $1 is not valid for this system case $1 in # Linux or Solaris. This works despite sol10 using SMF. inetd) ps_flags='-e';; xinetd) ps_flags='-e';; # Mac OS X launchd) ps_flags='aux';; *) echo "Bad superserver."; return 2 ;; esac if [ "$1" = "launchd" ] && [ `uname` != 'Darwin' ]; then echo "Only darwin uses launchd" return 2 fi if [ "$1" = "xinetd" ] && [ "$os" = 'SunOS' ] && \ [ `uname -r` = "5.10" ]; then echo "Solaris 10 does not use xinetd." return 2 fi # Search for $1, PROC=`ps ${ps_flags} | grep -v 'grep'| grep "${1}"` if [ x"${PROC}" != x ]; then return 0 else return 1 fi } backup_xinetd() { log_output_of mv ${SYSCONFDIR}/xinetd.d/${1} ${AMANDAHOMEDIR}/example/xinetd.${1}.orig || \ { logger "WARNING: Could not back up existing xinetd configuration '${1}'"; return 1; } logger "Old xinetd config for '${1}' backed up to '${AMANDAHOMEDIR}/example/xinetd.${1}.orig'" } backup_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # Backs up any amanda configuration it finds log_output_of sed -n "/^amanda .* amandad/w ${AMANDAHOMEDIR}/example/inetd.orig" ${inetd_conf} || \ { logger "WARNING: could not write ${AMANDAHOMEDIR}/example/inetd.orig"; return 1; } log_output_of sed "/^amanda .* amandad/d" ${inetd_conf} > \ ${inetd_conf}.tmp || \ { logger "WARNING: could not write ${inetd_conf}.tmp"; return 1; } log_output_of mv ${inetd_conf}.tmp ${inetd_conf} || \ { logger "WARNING: could not overwrite ${inetd_conf}, old config not removed."; return 1; } logger "Old inetd config for amanda backed up to ${AMANDAHOMEDIR}/example/inetd.orig" } backup_smf() { # Solaris only. I *think* this should be consistent across all smf installs svccfg -s *amanda* > ${AMANDAHOMEDIR}/example/amanda_smf.xml.orig || {\ logger "Warning: export of existing amanda service failed."; return 1; } log_output_of inetadm -d *amanda* || { \ # Not critical, we don't need to return if this fails. logger "Warning: disabling existing amanda service failed."; } log_output_of svccfg delete -f *amanda* || { \ logger "Error: removing the old amanda service failed."; return 1; } } install_xinetd() { log_output_of install -m 0644 ${AMANDAHOMEDIR}/example/xinetd.${1} ${SYSCONFDIR}/xinetd.d/${1} || \ { logger "WARNING: Could not install xinetd configuration '${1}'" ; return 1; } logger "Installed xinetd config for ${1}." } install_inetd() { case $os in SunOS) inetd_conf=${SYSCONFDIR}/inet/inetd.conf ;; *) inetd_conf=${SYSCONFDIR}/inetd.conf ;; esac # This one is hard to log because we're just appending. logger "Appending ${AMANDAHOMEDIR}/example/inetd.conf.${1} to ${inetd_conf}" cat ${AMANDAHOMEDIR}/example/inetd.conf.${1} >> ${inetd_conf} } install_smf() { # First parameter should be the name of the service to install # (amandaserver, or amandaclient). ver=`uname -r` case $ver in 5.10) # Use inetadm and svcadm. log_output_of ${basedir}/usr/sbin/inetconv -f -i ${AMANDAHOMEDIR}/example/inetd.conf.${1} || { \ logger "Warning: Failed to create Amanda SMF manifest. Check the system log."; return 1; } log_output_of ${basedir}/usr/sbin/inetadm -e svc:/network/amanda/tcp || { \ logger "Warning: Failed to enable Amanda service. See system log for more information."; return 1; } log_output_of ${basedir}/usr/sbin/svcadm restart network/amanda/tcp || { \ logger "Warning: Failed to restart Amanda service. See system log for details."; return 1; } ;; 5.8|5.9) logger "Solaris 8 and 9 use inetd, not SMF tools." return 1 ;; *) # I don't know what to do... logger "ERROR: Unsupported and untested version of Solaris: $ver" return 1 ;; esac } reload_xinetd() { # Default action is to try reload. case $1 in reload|restart|start) action=$1 ;; "") action=reload ;; *) logger "WARNING: bad argument to reload_xinetd: $1" return 1 ;; esac if [ "$action" = "reload" ] ; then logger "Reloading xinetd configuration..." log_output_of ${SYSCONFDIR}/init.d/xinetd $action # Don't exit! if [ $? -ne 0 ] ; then logger "xinetd reload failed. Attempting restart..." action=restart fi fi if [ "$action" = "restart" ] || [ "$action" = "start" ]; then logger "${action}ing xinetd." log_output_of ${SYSCONFDIR}/init.d/xinetd $action || \ { logger "WARNING: $action failed." ; return 1; } fi } reload_inetd() { # Default action is to try reload. if [ "x$1" = "x" ]; then action="reload" elif [ "$1" = "reload" ] || [ "$1" = "restart" ]; then action="$1" else logger "WARNING: bad argument to reload_inetd: $1" return 1 fi if [ "$1" = "reload" ] ; then logger "Reloading inetd configuration..." log_output_of ${SYSCONFDIR}/init.d/inetd $1 # Don't exit! if [ $? -ne 0 ] ; then logger "inetd reload failed. Attempting restart..." log_output_of ${SYSCONFDIR}/init.d/inetd restart || \ { logger "WARNING: restart failed." ; return 1; } fi else # Must be restart... logger "Restarting inetd." log_output_of ${SYSCONFDIR}/init.d/inetd $1 || \ { logger "WARNING: ${1} failed." ; return 1; } fi } # End Common functions #!/bin/sh # ------------- Begin Post Removal Functions ----------------- # Functions used for post removal actions rm_xinetd() { # Remove the xinetd configuration file $1. check_xinetd should be # executed first. logger "Removing xinetd configuration $1" log_output_of rm ${SYSCONFDIR}/xinetd.d/$1 } rm_inetd() { # Remove amanda entries from inetd.conf logger "Removing amanda's inetd.conf entries" log_output_of sed -i "/^amanda .* amandad/d" } rm_smf() { # Remove the amanda service from solaris style service framework. ret=0; export ret logger "Removing amanda's smf entry" log_output_of svcadm disable $1 || { ret=1; } log_output_of svccfg delete $1 || { ret=1; } return $ret } rm_user() { # Delete the user provided as first parameter ($1) logger "Deleting user: $1" log_output_of userdel $1 } # ------------- End Post Removal Functions ----------------- # -------- End Common functions ---------- /sbin/ldconfig # Check for parameter to script (are we upgrading?) if [ $1 -gt 0 ]; then # We're upgrading action="upgrade" else # We're uninstalling action="uninstall" fi # See http://fedoraproject.org/wiki/Packaging/ScriptletSnippets for the reason # we only remove xinetd on uninstall. if [ "$action" = "uninstall" ]; then # Check for and remove existing xinetd configs check_xinetd "amandaclient" if [ $? -eq 0 ] ; then rm_xinetd "amandaclient" reload_xinetd fi check_inetd "amandaclient" if [ $? -eq 0 ] ; then rm_inetd "amandaclient" reload_inetd fi if [ -f ${SYSCONFDIR}/amandates ]; then logger "Removing ${SYSCONFDIR}/amandates..." rm -rf ${SYSCONFDIR}/amandates fi if [ -d ${SYSCONFDIR}/amanda ]; then logger "Removing ${SYSCONFDIR}/amanda if empty..." rmdir ${SYSCONFDIR}/amanda 2> /dev/null || true fi if [ -d ${AMANDAHOMEDIR} ]; then logger "Removing ${AMANDAHOMEDIR}..." rm -rf ${AMANDAHOMEDIR} fi # Remove ${amanda_user} from sensitive groups. if which deluser >/dev/null 2>&1 ; then for group in tape; do # only call deluser when amandabackup is in $group if getent group "$group" | awk -F: '{ print $4 }' | awk -F, '{ for (i=1; i <= NF; i++ ) print $i }' | grep "^${amanda_user}$" > /dev/null; then deluser ${amanda_user} $group || true fi done fi echo "Amanda removal log can be found in '$LOGFILE'." fi %files backup_client # --- Files to install --- # Notes: Do not use wildcards on directories not wholly owned by amanda. An # uninstall of the software will attempt to delete whatever matches here. %defattr(0755,%{amanda_user},%{amanda_group},0755) %{AMLIBEXECDIR} %{AMLIBDIR} %{PERLSITELIB}/auto/Amanda %defattr(4750,root,disk) %{AMLIBEXECDIR}/application/amgtar %{AMLIBEXECDIR}/application/amstar %{AMLIBEXECDIR}/calcsize %{AMLIBEXECDIR}/killpgrp %{AMLIBEXECDIR}/rundump %{AMLIBEXECDIR}/runtar %defattr(0750,%{amanda_user},%{amanda_group},0750) %{LOGDIR} %{SBINDIR}/amaespipe %{SBINDIR}/amcryp* %{SBINDIR}/amgpgcrypt %{SBINDIR}/amoldrecover %{SBINDIR}/amrecover %{SYSCONFDIR}/amanda %defattr(0644,%{amanda_user},%{amanda_group},0755) %{LOCALSTATEDIR}/amanda %{PERLSITELIB}/Amanda %{AMLIBEXECDIR}/amcat.awk %{AMANDAHOMEDIR}/gnutar-lists %doc %{AMANDAHOMEDIR}/amanda-release %doc %{AMANDAHOMEDIR}/example/xinetd.amandaclient %doc %{AMANDAHOMEDIR}/example/xinetd.amandaserver %doc %{AMANDAHOMEDIR}/example/amanda-client.conf %doc %{AMANDAHOMEDIR}/template.d/README %doc %{AMANDAHOMEDIR}/template.d/dumptypes %defattr(0644,root,root,0755) %docdir %{MANDIR} %{MANDIR}/man5/amanda.conf.5.gz %{MANDIR}/man5/amanda-client.conf.5.gz %{MANDIR}/man7/amanda-devices.7.gz %{MANDIR}/man7/amanda-applications.7.gz %{MANDIR}/man7/amanda-scripts.7.gz %{MANDIR}/man8/amaespipe.8.gz %{MANDIR}/man8/amanda.8.gz %{MANDIR}/man8/amcheckdump.8.gz %{MANDIR}/man8/amcrypt* %{MANDIR}/man8/amgpgcrypt.8.gz %{MANDIR}/man8/amrecover.8.gz %doc %{DATADIR}/amanda %files backup_server %defattr(0755,%{amanda_user},%{amanda_group}) %{AMLIBEXECDIR} %{AMLIBDIR} %{PERLSITELIB}/Amanda %{PERLSITELIB}/auto/Amanda %{AMANDAHOMEDIR} %{LOCALSTATEDIR}/amanda %{SBINDIR}/am* %defattr(4750,root,disk) %{AMLIBEXECDIR}/application/amgtar %{AMLIBEXECDIR}/application/amstar %{AMLIBEXECDIR}/calcsize %{AMLIBEXECDIR}/killpgrp %{AMLIBEXECDIR}/rundump %{AMLIBEXECDIR}/runtar %{AMLIBEXECDIR}/dumper %{AMLIBEXECDIR}/planner %{SBINDIR}/amcheck %{SBINDIR}/amservice %defattr(0750,%{amanda_user},%{amanda_group},0750) %{LOGDIR} %{SYSCONFDIR}/amanda # Files in standard dirs must be listed explicitly %{SBINDIR}/activate-devpay %{SBINDIR}/amaespipe %{SBINDIR}/amcrypt %{SBINDIR}/amcrypt-ossl %{SBINDIR}/amcrypt-ossl-asym %{SBINDIR}/amcryptsimple %{SBINDIR}/amgpgcrypt %{SBINDIR}/amoldrecover %{SBINDIR}/amrecover %defattr(0644,%{amanda_user},%{amanda_group}) %{AMLIBEXECDIR}/amcat.awk %{AMLIBEXECDIR}/amplot.awk %{AMLIBEXECDIR}/amplot.g %{AMLIBEXECDIR}/amplot.gp %doc %{AMANDAHOMEDIR}/amanda-release %docdir %{AMANDAHOMEDIR}/example %docdir %{AMANDAHOMEDIR}/template.d %defattr(0644,root,root,0755) %docdir %{MANDIR} %{MANDIR}/man5/am* %{MANDIR}/man5/disklist.5.gz %{MANDIR}/man5/tapelist.5.gz %{MANDIR}/man7/am* %{MANDIR}/man8/am* %{MANDIR}/man8/script-email.8.gz %doc %{DATADIR}/amanda # --- ChangeLog %changelog * Wed Jul 03 2013 Dan Locks <dwlocks at zmanda dot com> %{version} - Package created * Fri Aug 20 2010 Dan Locks <dwlocks at zmanda dot com> 3.2.0alpha - use %%VERSION% macro instead of reading a file. error reported by ssgelm * Thu Aug 19 2010 Dan Locks <dwlocks at zmanda dot com> 3.2.0alpha - Added detection of openSuSE 11 as suggested by ssgelm