Domanda

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?

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top