Imported Upstream version 3.3.3
[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 encoder=`{ command -v base64 2>/dev/null; } || { command -v uuencode 2>/dev/null; }`
25
26 # ---------- Common functions ------------
27 %%COMMON_FUNCTIONS%%
28 %%POST_INST_FUNCTIONS%%
29
30 # -------- End Common functions ----------
31
32 check_xinetd "amanda${pkg_type}"
33 case $? in
34         0) backup_xinetd "amanda${pkg_type}"
35            install_xinetd "amanda${pkg_type}"
36         ;;
37         1) install_xinetd "amanda${pkg_type}" ;;
38         2) logger "Xinetd config not installed: either xinetd config is not present or xinetd.d is a file." ;;
39         *) logger "bad return from check_xinetd"
40            cat ${LOGFILE} >> ${INSTALL_LOG}
41            exit 1
42         ;;
43 esac
44
45 # amanda${pkg_type} should not have the amanda${other_pkg_type} xinetd installed.
46 check_xinetd "amanda${other_pkg_type}"
47 case $? in
48         0) backup_xinetd "amanda${other_pkg_type}" ;;
49 esac
50
51 check_superserver_running "xinetd"
52 [ "$?" = "0" ] && action=restart || action=start
53 reload_xinetd $action
54 create_amandates
55 check_amandates
56 create_ampassphrase || \
57     logger "Info: amcryptsimple and amcrpyt will not work until .am_passphrase is created"
58 create_gnupg
59 create_amkey || \
60     logger "Info: amcrypt will not work until keys are created."
61 # Checks permissions, but only tries decrypting if both .am_passphrase
62 # and .gnupg/am_key.gpg exist.
63 check_gnupg
64 create_amandahosts
65 check_amandahosts_entry root amindexd amidxtaped
66 check_amandahosts_entry ${amanda_user} amdump
67 check_amandahosts_perms
68 create_ssh_key ${pkg_type}
69 if [ "${pkg_type}" = "server" ]; then
70     create_ssh_key ${other_pkg_type}
71 fi
72 create_profile
73 check_profile
74 install_client_conf
75 create_amtmp
76
77 logger "Amanda ${pkg_type} installation complete."
78 cat $LOGFILE >> $INSTALL_LOG && {
79     rm $LOGFILE;
80     echo "Amanda installation log can be found in '${INSTALL_LOG}'.";
81 } || \
82     echo "Amanda installation log can be found in '${LOGFILE}'.";
83