summarylogtreecommitdiffstats
path: root/ghost.install
blob: a805b0860be0b4d6602fb62f26d3d3abc6911bce (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
post_install() {
    getent group ghost &>/dev/null || \
        groupadd --system --gid 738 ghost &>/dev/null
    getent passwd ghost &>/dev/null || \
        useradd --system --gid ghost --uid 738 -d /var/lib/ghost -s /usr/bin/nologin ghost &>/dev/null
    chown -R ghost:ghost var/lib/ghost &>/dev/null

    systemctl daemon-reload

    cat <<-EOF
    You can now run Ghost as a Systemd Service
        systemctl enable --now ghost.service
    This also ensures that Ghost is started at boot.

    By default, Ghost can be accessed at http://localhost:2368/
    after it is started.
EOF
}

post_upgrade() {
    # Check if old version < 0.5.8
    _cmp_ver=0.5.8
    if [ "$2" = "$(echo -e "$2\n$_cmp_ver" | sort -V | head -n1)" ] \
            && [ "$2" != "$_cmp_ver" ]; then
        # 0.5.8 changes ghost UID/GID to a 738
        # In order to do so, remove old user/group first
        getent passwd ghost &>/dev/null && userdel -f ghost
        getent group ghost &>/dev/null && groupdel ghost

        echo "The UID/GID of the ghost user/group has changed"
        echo "as of ghost-0.5.8. Please update the ownership of"
        echo "the /var/lib/ghost directory by running (as root)"
        echo "    chown -R ghost:ghost /var/lib/ghost"
    fi
    # Check if old version < 0.11.3
    _cmp_ver=0.11.3
    if [ "$2" = "$(echo -e "$2\n$_cmp_ver" | sort -V | head -n1)" ] \
            && [ "$2" != "$_cmp_ver" ]; then
        # In 0.11.3 the directory organization of this package has changed

        echo "The directory structure of the ghost package has changed"
        echo "as of ghost-0.11.3. Please copy the content directory manually"
        echo "to /var/lib/ghost/content and move your configuration file"
        echo "to /etc/webapps/ghost/config.js"
        echo "You will also need to make sure that the paths in your config"
        echo "point to the new directories."
    fi

    post_install

    if systemctl is-enabled ghost &>/dev/null || \
            systemctl is-active ghost &>/dev/null ; then
        systemctl restart ghost
    fi
}

post_remove() {
    if systemctl is-enabled ghost &>/dev/null || \
            systemctl is-active ghost &>/dev/null ; then
        systemctl stop ghost
    fi

    getent passwd ghost &>/dev/null && userdel -f ghost
    getent group ghost &>/dev/null && groupdel ghost

    systemctl daemon-reload
}