50 lines
No EOL
809 B
Bash
50 lines
No EOL
809 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/ *$//'
|
|
}
|
|
|
|
upstart() {
|
|
rm -f /etc/init/drone.conf
|
|
}
|
|
|
|
systemd() {
|
|
rm -f /lib/systemd/system/drone.service
|
|
}
|
|
|
|
validate_ver() {
|
|
echo "$(version) < $1" | bc
|
|
}
|
|
|
|
case "$(dist)" in
|
|
debian)
|
|
if [ $(validate_ver "8.0") -eq 1 ]; then
|
|
upstart
|
|
else
|
|
systemd
|
|
fi
|
|
;;
|
|
ubuntu)
|
|
if [ $(validate_ver "14.10") -eq 1 ]; then
|
|
upstart
|
|
else
|
|
systemd
|
|
fi
|
|
;;
|
|
*)
|
|
echo "\033[33m Please remove service manually \033[0m"
|
|
;;
|
|
esac
|
|
|
|
# https://www.debian.org/doc/debian-policy/ch-maintainerscripts.html
|
|
|
|
if [ "$1" = "purge" ] ; then
|
|
echo "Purging drone configuration"
|
|
rm -rf /etc/drone
|
|
fi |