I have the following script which restarts god when I reboot my server (Ubuntu). How can I get god to start as the user "rails"?
#!/bin/sh
### BEGIN INIT INFO
# Provides: god
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: God
### END INIT INFO
NAME=god
DESC=god
PID=/home/rails/xxx/shared/pids/god.pid
LOG=/home/rails/xxx/shared/log/god.log
set -e
# Make sure the binary and the config file are present before proceeding
test -x /usr/bin/god || exit 0
# Create this file and put in a variable called GOD_CONFIG, pointing to
# your God configuration file
test -f /etc/default/god && . /etc/default/god
[ $GOD_CONFIG ] || exit 0
. /lib/lsb/init-functions
RETVAL=0
case "$1" in
start)
echo -n "Starting $DESC: "
/bin/su rails -c '/usr/bin/god -c $GOD_CONFIG -P $PID -l $LOG'
RETVAL=$?
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
kill `cat $PID`
RETVAL=$?
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
kill `cat $PID`
/bin/su rails -c '/usr/bin/god -c $GOD_CONFIG -P $PID -l $LOG'
RETVAL=$?
echo "$NAME."
;;
status)
/bin/su rails -c '/usr/bin/god status'
RETVAL=$?
;;
*)
echo "Usage: god {start|stop|restart|status}"
exit 1
;;
esac
exit $RETVAL
Any help with this would be awesome, as I'm a total n00b when it comes to servers.