#!/bin/bash function zarafa_cfg_set() { # 1: field / 2: value / 3: file # Replaces optional comments and spaces # "# name = value" => "name = newvalue" # sed -i "s|^#*\s*\($1\)\s*\=.*|\1 = $2|" $3 } # care about existing files function installdir() { local owner="$1" local moddir="$2" local modfile="$3" local directory="$4" mkdir -p "$directory" find $directory -exec chown "$owner" {} \; find $directory -type f -exec chmod "$modfile" {} \; find $directory -type d -exec chmod "$moddir" {} \; } function installbasics() { # create tempdirs and users from /usr/lib/*.d systemd-sysusers systemd-tmpfiles --create installdir zarafa:zarafa 0700 0600 /var/log/zarafa installdir zarafa:zarafa 0700 0600 /var/lib/zarafa installdir zarafa:zarafa 0700 0600 /var/lib/zarafa/search installdir zarafa:zarafa 0700 0600 /var/lib/zarafa/presence # due to a bug/exception it's impossible to execute phps mapi modul without browsable dir installdir zarafa:zarafa 0755 0600 /etc/zarafa # fix missing python symlink for presence if [[ ! -e "/usr/bin/python" ]]; then ln -s /usr/bin/python2 /usr/bin/python fi } post_install() { installbasics # CONFIG # => defaults for cfg in /usr/share/doc/zarafa/example-config/*.cfg; do install --backup=simple --suffix .pacsave -o zarafa -g zarafa -m 0600 ${cfg} /etc/zarafa done echo echo "Please install Zarafa:" echo echo " $ /usr/share/doc/zarafa/pietma/install.sh" echo echo "Read More" echo echo " https://pietma.com/run-and-access-zarafa/" echo return 0 } post_upgrade() { local newPackageVersion="$1" local oldPackageVersion="$2" case "$oldPackageVersion" in 7.2.1*) installbasics # CONFIG # => defaults for cfg in /usr/share/doc/zarafa/example-config/*.cfg; do install --backup=simple -o zarafa -g zarafa -m 0600 ${cfg} /etc/zarafa done echo "Please check /etc/zarafa for new configuration values!" ;; *) ;; esac # don't run gateway and ical as zarafa user - zarafa would grand access to all stores for cfg in /etc/zarafa/{gateway,ical}.cfg; do zarafa_cfg_set "run_as_user" "nobody" "${cfg}" zarafa_cfg_set "run_as_group" "nobody" "${cfg}" done echo echo "Please restart zarafa gateway and ical services" echo echo " $ systemctl restart zarafa-gateway" echo " $ systemctl restart zarafa-ical" echo return 0 } pre_remove() { return 0 }