Wednesday, September 6, 2017

Auto Starting Cloud9 on a Raspberry Pi (Linux)

This is an /etc/init.d/ script you can use on your Raspberry Pi, or other Linux machine, to auto start cloud9 at boot time.

#!/bin/bash

### BEGIN INIT INFO
# Provides:          cloud9
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Simple script to start cloud9 at boot
# Description:       A simple script which will start / stop cloud9 at boot / shutdown.
### END INIT INFO

# If you want a command to always run, put it here

# Carry out specific functions when asked to by the system
case "$1" in
  start)
    # echo "Starting noip"
    # run application you want to start
    cd /home/pi/c9sdk
    sudo -u pi ./server.js -s standalone-homedir -l 0.0.0.0 -a : &
    echo "Launching cloud9 with workspace root set to /home/pi"
    ;;
  stop)
    echo "Stopping cloud9"
    # kill application you want to stop
    pkill -f "node ./server.js"
    ;;
  *)
    echo "Usage: /etc/init.d/cloud9 {start|stop}"
    exit 1
    ;;
esac

exit 0