5

To start Diaspora sever need to run these command:

cd /home/diaspora

./script/sever

My server(Ubuntu 11.10) everyday restart. I need to configure the server(Ubuntu 11.10) to allow diaspora server start up whenever my server is up. How to do it?

I have tried:

Log in as user which run diaspora as, open crontab editor (crontab -e), scroll to the end and enter:

@reboot cd /home/diaspora; ./script/sever

then save, but it still does not start up after my server boot up.

And,if crontab -e cannot do this, is it possible to write a init script to do this? If init script is able to do this, how to write the script to do it?

Community
  • 1
  • 1
Dr34mNiTez
  • 53
  • 4

1 Answers1

5

First you need to create an init script:

# This is the init script for starting up the
#  Diaspora
#
# chkconfig: 345 91 10
# description: Starts and stops the Diaspora daemon.
#

PROC_NAME=Diaspora
DIASPORA_HOME=/home/diaspora
# Change the user to whichever user you need
RUN_AS_USER=diaspora
startup="cd $DIASPORA_HOME; ./script/server"
# Replace by stop/shutdown command
#shutdown="$DIASPORA_HOME/script/server"

start(){
 echo -n $"Starting $PROC_NAME service: "
 su -l $RUN_AS_USER -c "$startup"
 RETVAL=$?
 echo
}

stop(){
 echo -n $"Stoping $PROC_NAME service: "
 # Uncomment here to allow stop
 # su -l $RUN_AS_USER -c "$shutdown"
 RETVAL=$?
 echo
}

restart(){
  stop
  start
}


# See how we were called.
case "$1" in
start)
 start
 ;;
stop)
 stop
 ;;
restart)
 restart
 ;;
*)
 echo $"Usage: $0 {start|stop|restart}"
 exit 1
esac

exit 0

Then make the file executable:

sudo chmod +x /etc/init.d/diaspora

Then you need to tell Ubuntu to start/stop, usually using the default run levels (assuming you saved the previous script in /etc/init.d/diaspora):

sudo update-rc.d diaspora defaults

Then try it out:

sudo service diaspora start

or

sudo /etc/init.d/diaspora start

If diaspora starts then you're good to go. Else the script might need adjustment.

Andrei Sfat
  • 8,440
  • 5
  • 49
  • 69
JScoobyCed
  • 10,203
  • 6
  • 34
  • 58
  • My diaspora still does not start up upon server reboot – Dr34mNiTez Feb 03 '12 at 02:34
  • Was there any error in the process above? You might want to set the 'x' flag on the script: sudo chmod +x /etc/init.d/diaspora Then try /etc/init.d/diaspora start and see what this gives – JScoobyCed Feb 03 '12 at 02:39
  • i have ran sudo chmod +x /etc/init.d/diaspora, then sudo update-rc.d diaspora defaults, then init 6 to reboot the server. but it still does not start my diaspora. It does not give me any error msg – Dr34mNiTez Feb 03 '12 at 02:46
  • 1
    I think I fond the error, to start diaspora, is need to run ./script/server, the command you put is startup="$DIASPORA_HOME/script/server" i should update it to startup="$DIASPORA_HOME/./script/server" ? – Dr34mNiTez Feb 03 '12 at 02:51
  • 1
    I edited the "startup" line because the script needs to be run from the diaspora home folder. I changed above to: startup="cd $DIASPORA_HOME; ./script/server" – JScoobyCed Feb 03 '12 at 02:54
  • 1
    THANK YOU VERY MUCH!! IT FINALLY WORKS!! – Dr34mNiTez Feb 03 '12 at 03:08