-
-
Save kawsark/1bc715db64e4fffb96b36bdd8534adf0 to your computer and use it in GitHub Desktop.
/etc/init.d/vault for CentOS 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# vault - this script manages the vault server | |
# | |
# chkconfig: 345 96 04 | |
# processname: vault | |
### BEGIN INIT INFO | |
# Provides: vault | |
# Required-Start: $local_fs $network | |
# Required-Stop: $local_fs $network | |
# Default-Start: 3 4 5 | |
# Default-Stop: 0 1 2 6 | |
# Short-Description: Manage the vault server | |
### END INIT INFO | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
# Source networking configuration. | |
. /etc/sysconfig/network | |
# Check that networking is up. | |
[ "$NETWORKING" = "no" ] && exit 0 | |
exec="/usr/local/bin/vault" | |
prog=${exec##*/} | |
lockfile="/var/lock/subsys/$prog" | |
pidfile="/tmp/${prog}/${prog}.pid" | |
logfile="/var/log/${prog}/${prog}.log" | |
sysconfig="/etc/sysconfig/$prog" | |
confdir="/etc/${prog}.d" | |
user="vault" | |
[ -f $sysconfig ] && . $sysconfig | |
start() { | |
[ -x $exec ] || exit 5 | |
[ -d $confdir ] || exit 6 | |
echo -n $"Starting $prog: " | |
touch $logfile $pidfile | |
daemon --user=$user "{ $exec server $OPTIONS -config=$confdir &>> $logfile & }; echo \$! >| $pidfile" | |
RETVAL=$? | |
if [ $RETVAL -eq 0 ]; then | |
touch $lockfile | |
unseal | |
fi | |
echo | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping $prog: " | |
killproc -p $pidfile $exec 2>> $logfile | |
RETVAL=$? | |
[ $RETVAL -eq 0 ] && rm -f $lockfile | |
echo | |
return $RETVAL | |
} | |
restart() { | |
stop | |
start | |
} | |
reload() { | |
echo -n $"Reloading $prog: " | |
killproc -p $pidfile $exec -HUP | |
echo | |
} | |
force_reload() { | |
restart | |
} | |
rh_status() { | |
status $prog | |
} | |
rh_status_q() { | |
rh_status >/dev/null 2>&1 | |
} | |
unseal() { | |
while : | |
do | |
ss -pl | fgrep "((\"$prog\"," > /dev/null | |
[ $? -eq 0 ] && break | |
sleep 0.1 | |
done | |
for key in $KEYS; do $exec unseal $CERT $key >> $logfile ; done | |
} | |
seal() { | |
$exec seal $CERT >> $logfile | |
} | |
case "$1" in | |
start) | |
rh_status_q && exit 0 | |
$1 | |
;; | |
stop) | |
rh_status_q || exit 0 | |
$1 | |
;; | |
restart) | |
$1 | |
;; | |
status) | |
rh_status | |
;; | |
condrestart|try-restart) | |
rh_status_q || exit 7 | |
restart | |
;; | |
unseal) | |
$1 | |
;; | |
seal) | |
$1 | |
;; | |
*) | |
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|unseal|seal}" | |
exit 2 | |
esac | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment