Created
January 30, 2017 09:49
-
-
Save adionditsak/01cb91b1a0e74ce98007ee7e1c253d51 to your computer and use it in GitHub Desktop.
Revisions
-
adionditsak created this gist
Jan 30, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,80 @@ # # 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 VAULT_PATH="/usr/local/bin/vault" VAULT_CONFIG="/etc/vault/vault.hcl" VAULT_STARTUP_LOG="/var/log/vault_startup.log" start() { $VAULT_PATH server -config=$VAULT_CONFIG 2>&1 >> $VAULT_STARTUP_LOG & return $? } stop() { # Seal the vault before stopping $VAULT_PATH seal -address=http://$(cat $VAULT_CONFIG |awk '/address/ {x=$3} END {print x}'|sed 's/"//g') # 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 $VAULT_PATH status -address=http://$(cat $VAULT_CONFIG |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 $VAULT_PATH seal -address=http://$(cat $VAULT_CONFIG |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 exit $RETVAL