51 lines
No EOL
836 B
Bash
51 lines
No EOL
836 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/ *$//'
|
|
}
|
|
|
|
echo Stopping drone
|
|
|
|
upstart() {
|
|
initctl stop drone || :
|
|
}
|
|
|
|
systemd() {
|
|
if [ "$1" -eq 0 ] ; then
|
|
systemctl --no-reload disable drone || :
|
|
systemctl stop drone || :
|
|
fi
|
|
}
|
|
|
|
validate_ver() {
|
|
echo "$(version) < $1" | bc
|
|
}
|
|
|
|
case "$(dist)" in
|
|
debian)
|
|
if [ $(validate_ver "8.0") -eq 1 ]; then
|
|
upstart
|
|
else
|
|
systemd $1
|
|
fi
|
|
;;
|
|
ubuntu)
|
|
if [ $(validate_ver "14.10") -eq 1 ]; 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 |