59 lines
No EOL
998 B
Bash
59 lines
No EOL
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 |