diff options
author | alonso <alonso@us.es> | 2010-10-23 10:36:47 +0000 |
---|---|---|
committer | alonso <alonso@us.es> | 2010-10-23 10:36:47 +0000 |
commit | ca6183e1582aa4bbf465eeaaa91979c563d430be (patch) | |
tree | 8c6b605b502278ef72723b66a14faca9e93e3a81 /admin/Sources/Services | |
parent | 0ba6567d1a24e29a389863c85d8c1c3e0c3476f6 (diff) |
git-svn-id: https://opengnsys.es/svn/trunk@1317 a21b9725-9963-47de-94b9-378ad31fedc9
Diffstat (limited to 'admin/Sources/Services')
-rw-r--r-- | admin/Sources/Services/opengnsys.default | 8 | ||||
-rwxr-xr-x | admin/Sources/Services/opengnsys.init | 143 |
2 files changed, 151 insertions, 0 deletions
diff --git a/admin/Sources/Services/opengnsys.default b/admin/Sources/Services/opengnsys.default new file mode 100644 index 00000000..0c84924e --- /dev/null +++ b/admin/Sources/Services/opengnsys.default @@ -0,0 +1,8 @@ +# RUN_OGADMSERVER run OpenGNSys Admin service. +# RUN_OGADMREPO run OpenGNSys Repository Manager service. +# RUN_BTTRACKER run Bittorrent Tracker +# RUN_BTSEEDER starts seeding of selected torrent files +RUN_OGADMSERVER="yes" +RUN_OGADMREPO="yes" +RUN_BTTRACKER="yes" +RUN_BTSEEDER="yes" diff --git a/admin/Sources/Services/opengnsys.init b/admin/Sources/Services/opengnsys.init new file mode 100755 index 00000000..ba08c7ad --- /dev/null +++ b/admin/Sources/Services/opengnsys.init @@ -0,0 +1,143 @@ +#! /bin/sh + +################################################################################################################## +####### Script de arranque de los servicios de OpenGnSys: Servidor ogAdmServer, Servidor de repositorio ogAdmRepo, +####### Tracker Bittorrent y seeder de imagenes por Bittorrent +####### autor: jcxifre <jcxifre@unizar.es> +####### 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" + +# +# 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 "." + 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: "$REPONAME + start-stop-daemon --stop --quiet --oknodo --name $REPONAME + echo "." + 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 |