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

83 lines
No EOL
1.8 KiB
Bash

#!/bin/sh
set -e
case "$1" in
abort-upgrade|abort-remove|abort-deconfigure|configure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
if [ -f /etc/drone/drone.toml ]; then
chmod 600 /etc/drone/drone.toml
fi
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 }'
}
upstart() {
if [ -d /etc/init ]; then
echo "Your system $(dist) $(version): using upstart to control Drone"
if [ -f /usr/local/bin/droned ]; then
if pidof /usr/local/bin/droned >/dev/null; then
initctl stop drone || :
fi
fi
cp -r /usr/share/drone/init/drone.conf /etc/init/drone.conf
initctl start drone || :
else
echo "Couldn't find upstart to control Drone, cannot proceed."
echo "Open an issue and tell us about your system."
exit 1
fi
}
systemd() {
if which systemctl > /dev/null; then
cp /usr/share/drone/systemd/drone.service /lib/systemd/system/drone.service
systemctl daemon-reload || :
if [ "$1" = "configure" ] ; then
echo "Your system $(dist) $(version): using systemd to control Drone"
systemctl enable drone || :
systemctl restart drone || :
fi
else
echo "Couldn't find systemd to control Drone, cannot proceed."
echo "Open an issue and tell us about your system."
exit 1
fi
}
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
;;
*)
echo "\033[33m Your system $(dist) $(version) \033[0m"
echo "\033[33m This system is not supported, you can install service manually \033[0m"
;;
esac
exit 0