Skip to content

Instantly share code, notes, and snippets.

@bekatom
Created March 19, 2016 07:09
Show Gist options
  • Select an option

  • Save bekatom/7e0e9bcf749861903681 to your computer and use it in GitHub Desktop.

Select an option

Save bekatom/7e0e9bcf749861903681 to your computer and use it in GitHub Desktop.
/etc/init.d/vault
#
# Daemon for vault
#
# chkconfig: 345 99 20
# description: Daemon for vault
# processname: vault
### BEGIN INIT INFO
# Provides: vault
# Required-Start: $network
# Required-Stop:
# Should-Start:
# Should-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop vault
# Description: Daemon for vault
### END INIT INFO
#/usr/local/bin/vault server -config /etc/vault.d/config.json 2>&1 >> /var/log/vault.log&
start() {
/usr/local/bin/vault server -config=/etc/vault.d >> /var/log/vault.log 2>&1 &
return $?
}
stop() {
# Get the process number and kill the process
kill $(ps -C vault|awk 'END {print $1}')
return $?
}
status() {
if [ -z $(ps -C vault|awk 'END {print $1}'|grep -v PID) ]; then
echo "Vault is not running."
return 3
else
/usr/local/bin/vault status -address=http://$(cat /etc/vault.d/config.json |awk '/address/ {x=$3} END {print x}'|sed 's/"//g')
fi
return 0
}
seal () {
if [ -z $(ps -C vault|awk 'END {print $1}'|grep -v PID) ]; then
echo "Vault is not running."
return 3
else
/usr/local/bin/vault seal -address=http://$(cat /etc/vault.d/config.json |awk '/address/ {x=$3} END {print x}'|sed 's/"//g')
return $?
fi
}
case "$1" in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
status)
status
RETVAL=$?
;;
seal)
seal
RETVAL=$?
;;
*)
echo $"Usage: vault {start|stop|status|seal}"
RETVAL=2
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment