summarylogtreecommitdiffstats
path: root/blynk-server-bin.install
blob: b87ded006d31515ff244eb0c85078254fc591070 (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
_user="blynk"

post_install() {
    getent group "${_user}" &>/dev/null
    if [ $? -ne 0 ]; then
        echo -e "\e[34;1m==>\e[39;1m Adding ${_user} system group... \e[0m"
        groupadd -r ${_user} 1>/dev/null
    fi
    getent passwd "${_user}" &>/dev/null
    if [ $? -ne 0 ]; then
        echo -e "\e[34;1m==>\e[39;1m Adding ${_user} system user... \e[0m"
        useradd -r -g ${_user} -d /usr/share/blynk ${_user} 1>/dev/null
    fi
    chown -R ${_user}:${_user} /var/lib/blynk
    chown -R ${_user}:${_user} /var/log/blynk
    chown -R ${_user}:${_user} /usr/share/blynk
}

post_upgrade() {
    echo -e "\e[34;1m==>\e[39;1m NOTE: Please restart blynk service to take the update into account. \e[0m"
}

pre_remove() {
    systemctl stop blynk.service
    rm -rf /usr/share/blynk/static
}

post_remove() {
    echo -e "\e[34;1m==>\e[39;1m Removing ${_user} user and group... \e[0m"
    userdel ${_user}
    if [ -d /var/lib/blynk ]; then
        echo -e "\e[34;1m==>\e[39;1m NOTE: Data folder /var/lib/blynk has been preserved. \e[0m"
    fi
}