harness-drone/packaging/scripts/prerm.deb
2014-10-14 13:19:32 +04:00

51 lines
No EOL
849 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
}
validate_ver() {
echo "$(version) < $1" | bc
}
case "$(dist)" in
debian)
if [ "$(version)" -lt "8" ]; then
upstart
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