<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br><br>Thanks for this code.<br>I've done some small improvement and added a script for OCCI.<br><br>You can find them here : http://dev.opennebula.org/issues/1289<br><br>Cheers,<br>Nicolas AGIUS<br><br>--- En date de : <b>Dim 22.4.12, Francesco Camisa <i><francesco.camisa@policlinicosanmarco.it></i></b> a écrit :<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>De: Francesco Camisa <francesco.camisa@policlinicosanmarco.it><br>Objet: [one-users] sunstone-server and oneacctd CentOS init.d scripts<br>À: users@lists.opennebula.org<br>Date: Dimanche 22 avril 2012, 15h58<br><br><div class="plainMail">I find usefull to have sunstone-server and oneacctd to start automatically.<br><br>I have created the following scripts. They are rough but do their job in my tests. Any input on
improving them is much appreciated.<br><br>For oneacctd:<br><br>#!/bin/bash<br>#<br># /etc/rc.d/init.d/oneacctd-d<br>#<br># Starts the oneacctd daemon<br>#<br># chkconfig: 345 66 34<br># description: Starts the oneacctd daemon<br># processname: oneacctd-d<br><br>### BEGIN INIT INFO<br># Provides: oneacctd-d<br># Required-Start: $local_fs $remote_fs oned<br># Required-Stop: $local_fs $remote_fs oned<br># Default-Start: 2 3 4 5<br># Default-Stop: 0 1 6<br># Short-Description: start and stop oneacctd-d<br># Description: start and stop oneacctd-d<br>### END INIT INFO<br><br>ONEACCTD_BIN=/usr/bin/oneacctd<br>prog=acctd.rb<br><br># Source function library.<br>. /etc/rc.d/init.d/functions<br><br>lockfile=/var/lock/subsys/$prog<br>pidfile=/var/run/$prog.pid<br><br>RETVAL=0<br><br>check() {<br> # Check that we're a privileged user<br> [ `id -u` = 0 ] || exit 4<br><br> # Check if oneacctd-d is
executable<br> test -x $ONEACCTD_BIN || exit 5<br>}<br><br>start() {<br> check<br> echo -n $"Starting oneacctd daemon: "<br> daemon --user oneadmin $ONEACCTD_BIN start<br> RETVAL=$?<br> echo<br> [ $RETVAL -eq 0 ] && touch $lockfile && echo $(ps -ef|grep su[n]stone-server | awk '{print $2}') > $pidfile<br> return $RETVAL<br>}<br><br>stop() {<br><br> check<br><br> echo -n $"Stopping oneacctd daemon: "<br> su oneadmin -s /bin/sh -c "$ONEACCTD_BIN stop"<br> RETVAL=$?<br> echo<br> [ $RETVAL -eq 0 ] && rm -f $lockfile && rm -f $pidfile<br> return $RETVAL<br>}<br><br>restart() {<br> stop<br> start<br>}<br><br><br>case "$1" in<br>start)<br> start<br> ;;<br>stop)<br>
stop<br> ;;<br>restart)<br> restart<br> ;;<br>status)<br> status $prog<br> RETVAL=$?<br> ;;<br>*)<br> echo $"Usage: $0 {start|stop|status|restart}"<br> RETVAL=2<br>esac<br><br>exit $RETVAL<br><br>For sunstone-server:<br><br>#!/bin/bash<br>#<br># /etc/rc.d/init.d/sunstoned<br>#<br># Starts the Sunstone Server daemon<br>#<br># chkconfig: 345 66 34<br># description: Starts the Sunstone Server daemon<br># processname: sunstoned<br><br>### BEGIN INIT INFO<br># Provides: sunstoned<br># Required-Start: $local_fs $remote_fs oned<br># Required-Stop: $local_fs $remote_fs oned<br># Default-Start: 2 3 4 5<br># Default-Stop: 0 1 6<br># Short-Description: start and stop sunstoned<br># Description: start and stop sunstoned<br>### END INIT INFO<br><br>SUNSTONE_BIN=/usr/bin/sunstone-server<br>prog=sunstone-server.rb<br><br># Source function
library.<br>. /etc/rc.d/init.d/functions<br><br>lockfile=/var/lock/subsys/$prog<br>pidfile=/var/run/$prog.pid<br><br>RETVAL=0<br><br>check() {<br> # Check that we're a privileged user<br> [ `id -u` = 0 ] || exit 4<br><br> # Check if sunstoned is executable<br> test -x $SUNSTONE_BIN || exit 5<br>}<br><br>start() {<br> check<br> echo -n $"Starting Sunstone Server daemon: "<br> daemon --user oneadmin $SUNSTONE_BIN start<br> RETVAL=$?<br> echo<br> [ $RETVAL -eq 0 ] && touch $lockfile && echo $(ps -ef|grep su[n]stone-server | awk '{print $2}') > $pidfile<br> return $RETVAL<br>}<br><br>stop() {<br><br> check<br><br> echo -n $"Stopping Sunstone Server daemon: "<br> su oneadmin -s /bin/sh -c "$SUNSTONE_BIN stop"<br> RETVAL=$?<br>
echo<br> [ $RETVAL -eq 0 ] && rm -f $lockfile && rm -f $pidfile<br> return $RETVAL<br>}<br><br>restart() {<br> stop<br> start<br>}<br><br><br>case "$1" in<br>start)<br> start<br> ;;<br>stop)<br> stop<br> ;;<br>restart)<br> restart<br> ;;<br>status)<br> status $prog<br> RETVAL=$?<br> ;;<br>*)<br> echo $"Usage: $0 {start|stop|status|restart}"<br> RETVAL=2<br>esac<br><br>exit $RETVAL<br><br><br>Francesco Camisa<br>Vice Direttore Generale<br>Policlinico San Marco<br>via Zanotto 40<br>30173 Mestre-VE<br>Italy<br>_______________________________________________<br>Users mailing list<br><a ymailto="mailto:Users@lists.opennebula.org" href="/mc/compose?to=Users@lists.opennebula.org">Users@lists.opennebula.org</a><br><a
href="http://lists.opennebula.org/listinfo.cgi/users-opennebula.org" target="_blank">http://lists.opennebula.org/listinfo.cgi/users-opennebula.org</a><br></div></blockquote></td></tr></table>