73 lines
1.8 KiB
Bash
Executable File
73 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
### BEGIN INIT INFO
|
|
# Provides: ipfs
|
|
# Required-Start: $local_fs $remote_fs $network $syslog $named
|
|
# Required-Stop: $local_fs $remote_fs $network $syslog $named
|
|
# Default-Start: 2 3 4 5
|
|
# Default-Stop: 0 1 6
|
|
# Short-Description: starts the ipfs daemon
|
|
### END INIT INFO
|
|
|
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
|
DAEMON=/usr/local/bin/ipfs
|
|
IPFS_UID=#UID#
|
|
IPFS_GID=#GID#
|
|
IPFS_PID_FILE=/var/run/ipfs.pid
|
|
IPFS_DATA=#DATA#
|
|
|
|
test -x $DAEMON || exit 0
|
|
. /lib/lsb/init-functions
|
|
|
|
|
|
ipfs_start() {
|
|
export "HOME=$IPFS_DATA"
|
|
if start-stop-daemon --start --quiet --background \
|
|
--pidfile $IPFS_PID_FILE --make-pidfile \
|
|
--chuid $IPFS_UID:$IPFS_GID --exec $DAEMON -- daemon
|
|
then
|
|
log_end_msg 0
|
|
else
|
|
log_end_msg 1
|
|
rm -f $IPFS_PID_FILE
|
|
fi
|
|
} # ipfs_start
|
|
|
|
case "$1" in
|
|
start)
|
|
if [ -s $IPFS_PID_FILE ] && kill -0 $(cat $IPFS_PID_FILE) >/dev/null 2>&1; then
|
|
log_progress_msg "apparently already running"
|
|
log_end_msg 0
|
|
exit 0
|
|
fi
|
|
log_daemon_msg "Startin ipfs daemon" "ipfs"
|
|
ipfs_start
|
|
;;
|
|
stop)
|
|
log_daemon_msg "Stopping ipfs daemon" "ipfs"
|
|
start-stop-daemon --stop --quiet --oknodo --pidfile $IPFS_PID_FILE
|
|
log_end_msg $?
|
|
rm -f $IPFS_PID_FILE
|
|
;;
|
|
restart)
|
|
log_daemon_msg "Restarting rsync daemon" "ipfs"
|
|
if [ -s $IPFS_PID_FILE ] && kill -0 $(cat $IPFS_PID_FILE) >/dev/null 2>&1; then
|
|
start-stop-daemon --stop --quiet --oknodo --pidfile $IPFS_PID_FILE || true
|
|
sleep 1
|
|
else
|
|
log_warning_msg "ipfs daemon not running, attempting to start."
|
|
rm -f $IPFS_PID_FILE
|
|
fi
|
|
ipfs_start
|
|
;;
|
|
status)
|
|
status_of_proc -p $IPFS_PID_FILE "$DAEMON" ipfs
|
|
exit $?
|
|
;;
|
|
*)
|
|
echo "Usage: /etc/init.d/ipfs {start|stop|restart|status}"
|
|
exit 1
|
|
esac
|
|
|
|
exit 0
|