1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-12 08:23:48 +02:00
woodpecker/packaging/scripts/prerm.deb
2014-11-02 16:36:53 +03:00

59 lines
998 B
Bash

#!/bin/sh
set -e
dist() {
lsb_release -i | awk '{print tolower($3)}' | sed -e 's/^ *//' -e 's/ *$//'
}
version() {
lsb_release -r | awk '{print $2}' | sed -e 's/^ *//' -e 's/ *$//' | awk -F. '{ print $1 }'
}
echo Stopping drone
upstart() {
initctl stop drone || :
}
systemd() {
if [ $1 = "remove" ] ; then
systemctl --no-reload disable drone || :
systemctl stop drone || :
fi
}
sysv() {
if [ -f /etc/init.d/drone ] ; then
if pidof /usr/local/bin/droned >/dev/null; then
exec /etc/init.d/drone stop || :
fi
fi
}
validate_ver() {
echo "$(version) < $1" | bc
}
case "$(dist)" in
debian)
if [ "$(version)" -lt "8" ]; then
sysv
else
systemd $1
fi
;;
ubuntu)
if [ "$(version)" -lt "15" ]; then
upstart
else
systemd $1
fi
;;
*)
if [ -f /usr/local/bin/droned ]; then
if pidof /usr/local/bin/droned >/dev/null; then
kill -9 `pidof /usr/local/bin/droned`
fi
fi
;;
esac