Added support for sysV systems, like debian 7
This commit is contained in:
parent
b44ca14fb7
commit
000387d10b
4 changed files with 111 additions and 3 deletions
75
packaging/root/usr/share/drone/init.d/drone
Normal file
75
packaging/root/usr/share/drone/init.d/drone
Normal file
|
@ -0,0 +1,75 @@
|
|||
#! /bin/sh
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: drone
|
||||
# Required-Start: $local_fs $remote_fs $network $syslog
|
||||
# Required-Stop: $local_fs $remote_fs $network $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Drone continuous integration server
|
||||
### END INIT INFO
|
||||
|
||||
DAEMON_OPTS="--config=/etc/drone/drone.toml"
|
||||
|
||||
pid() {
|
||||
if [ -f /usr/local/bin/droned ]; then
|
||||
pidof /usr/local/bin/droned
|
||||
fi
|
||||
}
|
||||
|
||||
stop() {
|
||||
if pidof /usr/local/bin/droned >/dev/null; then
|
||||
kill -9 "$(pid)"
|
||||
else
|
||||
echo "Drone not runned"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
if pidof /usr/local/bin/droned >/dev/null; then
|
||||
echo "Drone already runned"
|
||||
exit 1
|
||||
else
|
||||
nohup droned $DAEMON_OPTS > /var/log/drone.log 2>&1 &
|
||||
fi
|
||||
}
|
||||
|
||||
restart() {
|
||||
if pidof /usr/local/bin/droned >/dev/null; then
|
||||
kill -9 "$(pid)"
|
||||
nohup droned $DAEMON_OPTS > /var/log/drone.log 2>&1 &
|
||||
exit 0
|
||||
else
|
||||
nohup droned $DAEMON_OPTS > /var/log/drone.log 2>&1 &
|
||||
exit 0
|
||||
fi
|
||||
}
|
||||
|
||||
status() {
|
||||
if pidof /usr/local/bin/droned >/dev/null; then
|
||||
echo "Drone with pid $(pid) is running"
|
||||
else
|
||||
echo "Drone is not running"
|
||||
fi
|
||||
exit 0
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
restart)
|
||||
restart
|
||||
;;
|
||||
status)
|
||||
status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: service drone {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
|
@ -42,6 +42,26 @@ upstart() {
|
|||
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
|
||||
|
@ -62,7 +82,7 @@ systemd() {
|
|||
case "$(dist)" in
|
||||
debian)
|
||||
if [ "$(version)" -lt "8" ]; then
|
||||
upstart
|
||||
sysv
|
||||
else
|
||||
systemd $1
|
||||
fi
|
||||
|
|
|
@ -18,6 +18,11 @@ systemd() {
|
|||
rm -f /lib/systemd/system/drone.service
|
||||
}
|
||||
|
||||
sysv() {
|
||||
update-rc.d -f drone remove
|
||||
rm -f /etc/init.d/drone
|
||||
}
|
||||
|
||||
validate_ver() {
|
||||
echo "$(version) < $1" | bc
|
||||
}
|
||||
|
@ -25,7 +30,7 @@ validate_ver() {
|
|||
case "$(dist)" in
|
||||
debian)
|
||||
if [ "$(version)" -lt "8" ]; then
|
||||
upstart
|
||||
sysv
|
||||
else
|
||||
systemd
|
||||
fi
|
||||
|
|
|
@ -22,6 +22,14 @@ systemd() {
|
|||
fi
|
||||
}
|
||||
|
||||
sysv() {
|
||||
if [ -f /etc/init.d/drone ] ; then
|
||||
if pidof /usr/local/bin/droned >/dev/null; then
|
||||
exec /etc/init.d/drone stop || :
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
validate_ver() {
|
||||
echo "$(version) < $1" | bc
|
||||
}
|
||||
|
@ -29,7 +37,7 @@ validate_ver() {
|
|||
case "$(dist)" in
|
||||
debian)
|
||||
if [ "$(version)" -lt "8" ]; then
|
||||
upstart
|
||||
sysv
|
||||
else
|
||||
systemd $1
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue