Imported Upstream version 3.3.2
[debian/amanda] / packaging / deb / postinst.src
1 # This is appended to packaging/deb/amanda-backup-*.postinst
2 # vim: ft=sh
3
4 # Note: this script needs to do the same things in all maintainer
5 # script cases: configure, abort-remove, abort-upgrade.
6
7 LOGFILE=`mktemp /tmp/amanda-postinst.log.XXXXXXXXXXX`
8 if [ $? -ne 0 ]; then
9         echo "Unable to create log file!"
10         exit 1
11 fi
12 amanda_user=amandabackup
13 amanda_group=disk
14 AMANDAHOMEDIR=%%AMANDAHOMEDIR%%
15 os=Linux
16 dist=%%DISTRO%%
17 LOGDIR=%%LOGDIR%%
18 INSTALL_LOG="${LOGDIR}/install.log"
19 SYSCONFDIR=/etc
20 SBINDIR=/usr/sbin
21 AMTMP="/tmp/amanda"
22
23 AMANDATES=${SYSCONFDIR}/amandates
24
25 # ---------- Common functions ------------
26 %%COMMON_FUNCTIONS%%
27 %%POST_INST_FUNCTIONS%%
28
29 # -------- End Common functions ----------
30
31 check_xinetd "amanda${pkg_type}"
32 case $? in
33         0) backup_xinetd "amanda${pkg_type}"
34            install_xinetd "amanda${pkg_type}"
35         ;;
36         1) install_xinetd "amanda${pkg_type}" ;;
37         2) logger "Xinetd config not installed: either xinetd config is not present or xinetd.d is a file." ;;
38         *) logger "bad return from check_xinetd"
39            cat ${LOGFILE} >> ${INSTALL_LOG}
40            exit 1
41         ;;
42 esac
43
44 # amanda${pkg_type} should not have the amanda${other_pkg_type} xinetd installed.
45 check_xinetd "amanda${other_pkg_type}"
46 case $? in
47         0) backup_xinetd "amanda${other_pkg_type}" ;;
48 esac
49
50 reload_xinetd
51 create_amandates
52 check_amandates
53 create_gnupg
54 check_gnupg
55 create_amandahosts
56 check_amandahosts_entry root amindexd amidxtaped
57 check_amandahosts_entry ${amanda_user} amdump
58 check_amandahosts_perms
59 create_ssh_key ${pkg_type}
60 if [ "${pkg_type}" = "server" ]; then
61     create_ssh_key ${other_pkg_type}
62 fi
63 create_profile
64 check_profile
65 install_client_conf
66 create_ampassphrase
67 create_amtmp
68
69 logger "Amanda ${pkg_type} installation complete."
70 cat $LOGFILE >> $INSTALL_LOG && {
71     rm $LOGFILE;
72     echo "Amanda installation log can be found in '${INSTALL_LOG}'.";
73 } || \
74     echo "Amanda installation log can be found in '${LOGFILE}'.";
75