Created
March 19, 2016 07:09
-
-
Save bekatom/7e0e9bcf749861903681 to your computer and use it in GitHub Desktop.
/etc/init.d/vault
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 characters
| # | |
| # 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