mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-12 08:23:48 +02:00
103 lines
2.4 KiB
Bash
103 lines
2.4 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
|
|
}
|
|
|
|
sysv() {
|
|
if [ -d /etc/init.d ]; then
|
|
echo "Your system $(dist) $(version): using SysV to control Drone"
|
|
if [ -f /usr/local/bin/droned ] && [ -f /etc/init.d/drone ]; then
|
|
if pidof /usr/local/bin/droned >/dev/null; then
|
|
/etc/init.d/drone stop
|
|
fi
|
|
fi
|
|
|
|
cp -r /usr/share/drone/init.d/drone /etc/init.d/drone
|
|
chmod 0755 /etc/init.d/drone
|
|
update-rc.d drone defaults
|
|
exec /etc/init.d/drone start || :
|
|
else
|
|
echo "Couldn't find SysV 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
|
|
sysv
|
|
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 |