summarylogtreecommitdiffstats
path: root/subsonic-beta.install
blob: 17140ffa32c09d7925320983c78cc2a4e7ec1944 (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
_homedir=/var/lib/subsonic
_playlistdir=/var/playlists

post_install() {

    getent group subsonic &>/dev/null || groupadd --system subsonic > /dev/null
    getent passwd subsonic &>/dev/null || useradd --system \
                                                  --home-dir /var/lib/subsonic \
                                                  --shell /usr/bin/nologin \
                                                  --gid subsonic \
                                                  --groups audio \
                                                  --comment "Subsonic user" \
                                                  subsonic > /dev/null
    passwd --lock subsonic > /dev/null

    fix_permissions
    echo "*************************************************"
    echo "* Edit /etc/subsonic.conf to configure subsonic *"
    echo "*************************************************"

    systemctl daemon-reload
}

post_remove() {
    getent passwd subsonic &>/dev/null && userdel subsonic >/dev/null
    getent group subsonic &>/dev/null && groupdel subsonic >/dev/null
}

fix_permissions() {
    chown -R subsonic:subsonic ${_homedir}
    chown subsonic:subsonic ${_playlistdir}
}

pre_upgrade() {
    rm -f /tmp/subsonic-was-active
    if [[ `systemctl is-active subsonic` == 'active' ]]; then
        touch /tmp/subsonic-was-active
        echo "Stopping subsonic"
        systemctl stop subsonic
    fi
}

post_upgrade() {
    post_install

    if [[ $(vercmp 5.0.beta1 $2) == "1" ]]; then
        echo "!! Subsonics home dir is now located in /var/lib/subsonic."
        echo "   You will have to move the database located in "
        echo "   /var/subsonic/db to this new location."
        echo ""
        echo "!! This package now runs subsonic as the user 'subsonic'."
        echo "   You mightneed to edit permissions for your media folders."
        rm -f /tmp/subsonic-was-active
        echo ""
        echo "!! Not restarting subsonic automatically."
        echo "   You might need to change configs"
    fi

    if [ -e /tmp/subsonic-was-active ]; then
        echo "Starting subsonic"
        systemctl start subsonic
        rm /tmp/subsonic-was-active
    fi
}