summarylogtreecommitdiffstats
path: root/install
blob: dcab4bd38508b39967bc7ad42cc07d2acb5981e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/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
}