Skip to content

Instantly share code, notes, and snippets.

@scottsweb
Created February 21, 2016 09:44
Show Gist options
  • Select an option

  • Save scottsweb/1e38e79ee095c2931c1a to your computer and use it in GitHub Desktop.

Select an option

Save scottsweb/1e38e79ee095c2931c1a to your computer and use it in GitHub Desktop.

Revisions

  1. scottsweb created this gist Feb 21, 2016.
    48 changes: 48 additions & 0 deletions photobooth
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    #!/bin/bash
    ### BEGIN INIT INFO
    # Provides: photobooth
    # Required-Start: $local_fs
    # Required-Stop: $local_fs
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Start or stop the photobooth server
    ### END INIT INFO

    USER=pi
    NAME=photobooth
    SCRIPT='/home/pi/photobooth/app.coffee'
    LOG='/tmp/photobooth.log'
    PIDFILE=/var/run/photobooth.pid

    . /lib/lsb/init-functions

    case "$1" in
    start)
    log_daemon_msg "Starting daemon" "$NAME"

    if [ ! -f "$LOG" ]; then
    touch $LOG
    chown $USER $LOG
    fi

    /usr/local/bin/coffee $SCRIPT >> $LOG

    log_end_msg 0
    ;;
    stop)
    log_daemon_msg "Stopping daemon" "$NAME"
    pkill -f $SCRIPT
    rm -f $PIDFILE
    sleep 1
    log_end_msg 0
    ;;
    restart)
    $0 stop
    sleep 5
    $0 start
    ;;
    *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
    esac
    exit 0