Imported Upstream version 3.3.3
[debian/amanda] / packaging / sun-pkg / client / postinstall.src
1 #!/bin/sh
2
3 LOGFILE=`mktemp /tmp/amanda-client-postinstall.log.XXXXXXXXXXX`
4 if [ $? -ne 0 ]; then
5     echo "Unable to mktemp!" 1>&2
6     exit 1
7 fi
8 amanda_user=amandabackup; export amanda_user
9 amanda_group=disk; export amanda_group
10 # BASEDIR is set by either in pkginfo, or if not set, by pkgadd at installtime.
11 # Unfortunately, it messes things up to have basedir="/".
12 [ "x${BASEDIR}" = "x/" ] && basedir="" || basedir=${BASEDIR}
13 AMANDAHOMEDIR="${basedir}%%AMANDAHOMEDIR%%"; export AMANDAHOMEDIR
14 os=SunOS; export os
15 arch=%%ARCH%%; export arch
16 LOGDIR="${basedir}%%LOGDIR%%"; export LOGDIR
17 INSTALL_LOG="${LOGDIR}/install.log"; export INSTALL_LOG
18 SYSCONFDIR="${basedir}/etc"; export SYSCONFDIR
19 SBINDIR="${basedir}/usr/sbin"; export SBINDIR
20 AMTMP="/tmp/amanda"
21
22 AMANDATES=${SYSCONFDIR}/amandates; export AMANDATES
23 # uuencode is still standard on sol10, but haven't checked sol 11.
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 add_service
33 rel=`uname -r`
34 if [ "$rel" = "5.8" ]; then
35     check_inetd "amandaclient"
36     case $? in
37       0) backup_inetd "amandaclient"
38            install_inetd "amandaclient"
39       ;;
40       1) install_inetd "amandaclient" ;;
41       2) logger "Error: Amanda service not installed because inetd config was not found: either inetd config is not present or inetd is a directory." ;;
42     esac
43     # Amanda clients should not have the server xinetd installed.
44     check_inetd "amandaserver"
45     case $? in
46       0) backup_inetd "amandaserver" ;;
47     esac
48     reload_inetd
49 else
50     # Solaris 10+ uses smf, but we can't differentiate server from client, all
51     # entries end up named "amanda"
52     check_smf "amanda"
53     case $? in
54       0) backup_smf || logger "Warning: Backup of existing service failed. continuing..."
55          install_smf "amandaclient" || \
56             logger "Warning: Amanda service not installed."
57       ;;
58       1) install_smf "amandaclient" ;;
59     esac
60 fi
61
62 create_amandates
63 check_amandates
64 create_ampassphrase || \
65     logger "Info: amcryptsimple and amcrpyt will not work until .am_passphrase is created"
66 create_gnupg
67 create_amkey || \
68     logger "Info: amcrypt will not work until keys are created."
69 # Checks permissions, but only tries decrypting if both .am_passphrase
70 # and .gnupg/am_key.gpg exist.
71 check_gnupg
72 create_amandahosts
73 check_amandahosts_entry root amindexd amidxtaped
74 check_amandahosts_entry ${amanda_user} amdump
75 check_amandahosts_perms
76 create_ssh_key client
77 create_profile
78 check_profile
79 install_client_conf
80 create_amtmp
81
82 logger "Amanda installation complete."
83 exit_msg="Amanda installation log can be found in '${INSTALL_LOG}'."
84 cat $LOGFILE >> $INSTALL_LOG && {
85     rm $LOGFILE
86     echo "${exit_msg} '${INSTALL_LOG}'."
87 } || \
88     echo "${exit_msg} $LOGFILE."