Created
April 17, 2018 22:41
-
-
Save kissarat/0b15bd6cb50ec0174fe9e763f029a9bb to your computer and use it in GitHub Desktop.
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/bash | |
### BEGIN INIT INFO | |
# Provides: parity | |
# Required-Start: $remote_fs | |
# Required-Stop: $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Descrition: Parity Ethereum node | |
### END INIT INFO | |
NAME=parity | |
USER=ubuntu | |
LOGFILE=/var/log/${NAME}.log | |
PIDFILE=/run/${NAME}.pid | |
if [[ ! -f $PIDFILE ]] | |
then echo 0 > $PIDFILE | |
fi | |
if [[ ! -f $LOGFILE ]] | |
then echo 'Created' >> $LOGFILE | |
fi | |
if [[ $# -eq 0 ]]; then | |
echo "Usage: $0 {start|stop|status}" | |
exit 1 | |
else | |
COMMAND="$1" | |
fi | |
case $COMMAND in | |
start) | |
chown $USER $PIDFILE | |
chown $USER $LOGFILE | |
su - $USER -c "parity daemon $PIDFILE --log-file=$LOGFILE" | |
;; | |
status) | |
PID=`cat $PIDFILE` | |
if [[ $PID -gt 0 && -e /proc/${PID} && -a /proc/${PID}/exe ]] | |
then echo $NAME 'is running' | |
else echo $NAME 'is stopped' | |
fi | |
;; | |
stop) | |
PID=`cat $PIDFILE` | |
if [[ $PID -gt 0 && -e /proc/${PID} && -a /proc/${PID}/exe ]] | |
then | |
kill -s SIGINT `cat $PIDFILE` | |
rm $PIDFILE | |
echo "Stopped" >> $LOGFILE | |
fi | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment