mirror of
https://github.com/adnanh/webhook.git
synced 2025-06-24 21:38:32 +00:00
adding a rpm spec file and init script
This commit is contained in:
parent
409b441c31
commit
ffd05a2101
2 changed files with 291 additions and 0 deletions
111
webhook.init
Normal file
111
webhook.init
Normal file
|
@ -0,0 +1,111 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# Start the Webhook daemon
|
||||
#
|
||||
# chkconfig: 35 82 16
|
||||
# description: webhook is a lightweight configurable tool written in Go, that \
|
||||
# allows you to easily create HTTP endpoints (hooks) on your server, which \
|
||||
# you can use to execute configured commands.
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: webhook
|
||||
# Required-Start: $syslog $local_fs
|
||||
# Required-Stop: $syslog $local_fs
|
||||
# Should-Start: 0 1 2 6
|
||||
# Should-Stop: 3 5
|
||||
# Default-Start: 0 1 2 6
|
||||
# Default-Stop: 3 5
|
||||
# Short-Description: webhook allows you to easily create HTTP endpoints (hooks) on your server
|
||||
# Description: webhook allows you to easily create HTTP endpoints (hooks) on your server
|
||||
### END INIT INFO
|
||||
|
||||
# Source function library.
|
||||
. /etc/rc.d/init.d/functions
|
||||
|
||||
exec="/usr/bin/webhook"
|
||||
prog="webhook"
|
||||
config="/etc/webhook/hooks.json"
|
||||
|
||||
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
|
||||
|
||||
|
||||
|
||||
|
||||
lockfile=/var/lock/subsys/$prog
|
||||
pidfile=/var/run/$prog.pid
|
||||
|
||||
start() {
|
||||
[ -x $exec ] || exit 5
|
||||
[ -f $config ] || exit 6
|
||||
echo -n $"Starting $prog: "
|
||||
# if not running, start it up here, usually something like "daemon $exec"
|
||||
((exec $exec -hooks=$config $OPTIONS &>/dev/null)&)
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && touch $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo -n $"Stopping $prog: "
|
||||
killproc $prog
|
||||
retval=$?
|
||||
echo
|
||||
[ $retval -eq 0 ] && rm -f $lockfile
|
||||
return $retval
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
||||
|
||||
reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
force_reload() {
|
||||
restart
|
||||
}
|
||||
|
||||
rh_status() {
|
||||
# run checks to determine if the service is running or use generic status
|
||||
status $prog
|
||||
}
|
||||
|
||||
rh_status_q() {
|
||||
rh_status >/dev/null 2>&1
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
rh_status_q && exit 0
|
||||
$1
|
||||
;;
|
||||
stop)
|
||||
rh_status_q || exit 0
|
||||
$1
|
||||
;;
|
||||
restart)
|
||||
$1
|
||||
;;
|
||||
reload)
|
||||
rh_status_q || exit 7
|
||||
$1
|
||||
;;
|
||||
force-reload)
|
||||
force_reload
|
||||
;;
|
||||
status)
|
||||
rh_status
|
||||
;;
|
||||
condrestart|try-restart)
|
||||
rh_status_q || exit 0
|
||||
restart
|
||||
;;
|
||||
*)
|
||||
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
|
||||
exit 2
|
||||
esac
|
||||
exit $?
|
Loading…
Add table
Add a link
Reference in a new issue