#! /bin/sh ##########1.0###################################################################################################### ####### Script de arranque de los servicios de OpenGnSys: Servidor ogAdmServer, Servidor de repositorio ogAdmRepo, ####### Tracker Bittorrent y seeder de imagenes por Bittorrent ####### autor: jcxifre ####### basado en http://www.epilogue.org/~xef4/start-stop-example ################################################################################################################## ### BEGIN INIT INFO # Provides: opengnsys # Required-Start: # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 1 # Short-Description: Servicios del sistema OpenGnSys # Description: Servicios del sistema OpenGnSys: ### END INIT INFO # # Definiciones globales # BASEDIR=/opt/opengnsys # # Servidor de OpenGnSys # SERVERNAME=ogAdmServer SERVERDAEMON=$BASEDIR/sbin/$SERVERNAME SERVERCFG=$BASEDIR/etc/$SERVERNAME.cfg SERVERLOG=$BASEDIR/log/$SERVERNAME.log SERVERDAEMON_OPTIONS="-f $SERVERCFG -l $SERVERLOG" # # Servidor de Repositorio # REPONAME=ogAdmRepo REPODAEMON=$BASEDIR/sbin/$REPONAME REPOCFG=$BASEDIR/etc/$REPONAME.cfg REPOLOG=$BASEDIR/log/$REPONAME.log REPODAEMON_OPTIONS="-f $REPOCFG -l $REPOLOG" ############## ADV REPOAUXNAME=ogAdmRepoAux REPOAUXDAEMON=$BASEDIR/sbin/$REPOAUXNAME REPOAUXPORT=$((`cat $SERVERCFG | grep PUERTO | cut -f2 -d"="` + 1)) ############## ADV # # Servidor de tareas programadas # AGENTNAME=ogAdmAgent AGENTDAEMON=$BASEDIR/sbin/$AGENTNAME AGENTCFG=$BASEDIR/etc/$AGENTNAME.cfg AGENTLOG=$BASEDIR/log/$AGENTNAME.log AGENTDAEMON_OPTIONS="-f $AGENTCFG -l $AGENTLOG" # # Opciones Bittorrent # BTTRACK=/usr/bin/bttrack.bittorrent BTSEEDER=/usr/bin/btlaunchmany.bittornado BTTRACKPORT=6969 BTTRACKDFILE=/tmp/dstate BTTRACKLOG=/opt/opengnsys/log/bttrack.log BTINTERVAL=30 BTTORRENTSDIR=/opt/opengnsys/images BTALLOW_GET=1 BTTRACK_OPTIONS=" --port $BTTRACKPORT --dfile $BTTRACKDFILE --reannounce_interval $BTINTERVAL --logfile $BTTRACKLOG --allowed_dir $BTTORRENTSDIR --allow_get $BTALLOW_GET --parse_allowed_interval 1" BTTRACKPID="/var/run/bttrack.pid" BTSEEDERPID="/var/run/btseeder.pid" set -e export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/bin" # Read config file if it is present. if [ -r /etc/default/opengnsys ] then . /etc/default/opengnsys fi arranca_demonios() { if [ $RUN_OGADMSERVER = "yes" ] then echo -n "Iniciando demonio: "$SERVERNAME start-stop-daemon --start --quiet --background --exec $SERVERDAEMON -- $SERVERDAEMON_OPTIONS echo "." fi if [ $RUN_OGADMSERVER = "yes" ] && [ $RUN_OGADMREPO = "yes" ] then sleep 5 # Damos tiempo a que ogAdmServer este funcionando fi if [ $RUN_OGADMREPO = "yes" ] then echo -n "Iniciando demonio: "$REPONAME start-stop-daemon --start --quiet --background --exec $REPODAEMON -- $REPODAEMON_OPTIONS echo "." ############ ADV echo -n "Iniciando demonio: "$REPOAUXNAME faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON" echo "." ############ ADV fi if [ $RUN_OGADMAGENT = "yes" ] then echo -n "Iniciando demonio: "$AGENTNAME $AGENTDAEMON start-stop-daemon --start --quiet --background --exec $AGENTDAEMON -- $AGENTDAEMON_OPTIONS echo "." fi if [ $RUN_BTTRACKER = "yes" ] then echo -n "Iniciando demonio: "$BTTRACK start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec $BTTRACK -- $BTTRACK_OPTIONS echo "." fi if [ $RUN_BTSEEDER = "yes" ] then echo -n "Iniciando demonio: "$BTSEEDER start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet --background --exec $BTSEEDER -- $BTTORRENTSDIR echo "." fi } para_demonios() { if [ -e $BTSEEDERPID ] then echo -n "Parando demonio: "$BTSEEDER start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTSEEDERPID echo "." rm $BTSEEDERPID > /dev/null fi if [ -e $BTTRACKPID ] then echo -n "Parando demonio: "$BTTRACK start-stop-daemon --stop --quiet --oknodo --pidfile $BTTRACKPID echo "." rm $BTTRACKPID > /dev/null fi echo -n "Parando demonio: "$AGENTNAME start-stop-daemon --stop --quiet --oknodo --name $AGENTNAME echo "." echo -n "Parando demonio: "$REPONAME start-stop-daemon --stop --quiet --oknodo --name $REPONAME echo "." ############# ADV echo -n "Parando demonio: "$REPOAUXNAME pkill faucet ############ ADV echo -n "Parando demonio: "$SERVERNAME start-stop-daemon --stop --quiet --oknodo --name $SERVERNAME echo "." } case "$1" in start) arranca_demonios ;; stop) para_demonios ;; restart) para_demonios arranca_demonios ;; *) echo "Uso: opengnsys "$1" {start|stop|restart}" exit 1 ;; esac exit 0