2 # simple helper, mainly for testing the provided Systemd units.
8 : ${EXIM_LOGDIR=/var/log/exim}
9 : ${EXIM_SPOOLDIR=/var/spool/exim}
11 # Packagers should install to $(systemd-path systemd-system-unit)
12 # which mostly is something like /lib/systemd/system
15 usage="$0 [OPTIONS] variant...
16 This simple script installs Systemd unit files to the desired destination, replacing
19 VARIANT: one of daemon, inet, socket, maintainance, queuerunner
22 --help print this help and exit cleanly
23 --uninstall|-u uninstall the installed files
24 --dstdir|-d DIR the destination directory (mandatory, use 'DEFAULT'
25 to use Systemd's default location (`systemd-path systemd-system-conf`)
28 {{exim}} from \$EXIM ($EXIM)
29 {{logdir}} from \$EXIM_LOGDIR ($EXIM_LOGDIR)
30 {{spooldir}} from \$EXIM_SPOOLDIR ($EXIM_SPOOLDIR)
34 tmp=$(getopt -n $0 -o d:n --long dstdir:,help,uninstall -- "$@")
40 -d|--dstdir) dstdir=$1; shift;;
41 --help) echo "$usage"; exit;;
42 -n|--uninstall) uninstall=1;;
49 if ! [[ -r .installed ]]
51 echo "$0: noting to uninstall (.installed is empty or isn't readable)" >&2
61 DEFAULT) dstdir=$(systemd-path systemd-system-conf);;
62 "") echo "$0: --dstdir is mandatory" >&2; exit 1;;
67 then echo "$0: need variant" >&2; exit 1;
71 sed -e "s|{{exim}}|${EXIM:?}|g" \
72 -e "s|{{logdir}}|${EXIM_LOGDIR:?}|g" \
73 -e "s|{{spooldir}}|${EXIM_SPOOLDIR:?}|g"
76 for dir in ${@:?need source dir(s)}
81 dst="$dstdir/${src##*/}"
82 echo "installing $dst"
84 echo $dst >> .installed
88 if [[ $dstdir == $(systemd-path systemd-system-conf) ]]
90 echo "# reloading systemd configuration"
91 systemctl daemon-reload