source: admin/Sources/Services/opengnsys.init @ 71643c0

Last change on this file since 71643c0 was 71643c0, checked in by ramon <ramongomez@…>, 13 years ago

Integrar versión 1.0.2 en rama trunk (modificar #464).

git-svn-id: https://opengnsys.es/svn/trunk@2404 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 5.1 KB
RevLine 
[71643c0]1#!/bin/bash
[ca6183e]2
3### BEGIN INIT INFO
4# Provides:          opengnsys
5# Required-Start:
6# Required-Stop:
7# Default-Start:     2 3 4 5
8# Default-Stop:      1
9# Short-Description: Servicios del sistema OpenGnSys
10# Description:       Servicios del sistema OpenGnSys:
11### END INIT INFO
12
13#
14# Definiciones globales
15#
16BASEDIR=/opt/opengnsys
17
18#
19# Servidor de OpenGnSys
20#
21SERVERNAME=ogAdmServer
22SERVERDAEMON=$BASEDIR/sbin/$SERVERNAME
23SERVERCFG=$BASEDIR/etc/$SERVERNAME.cfg
24SERVERLOG=$BASEDIR/log/$SERVERNAME.log
25SERVERDAEMON_OPTIONS="-f $SERVERCFG -l $SERVERLOG"
26
27#
28# Servidor de Repositorio
29#
30REPONAME=ogAdmRepo
31REPODAEMON=$BASEDIR/sbin/$REPONAME
32REPOCFG=$BASEDIR/etc/$REPONAME.cfg
33REPOLOG=$BASEDIR/log/$REPONAME.log
34REPODAEMON_OPTIONS="-f $REPOCFG -l $REPOLOG"
[8fc9552]35############## ADV
36REPOAUXNAME=ogAdmRepoAux
37REPOAUXDAEMON=$BASEDIR/sbin/$REPOAUXNAME
38REPOAUXPORT=$((`cat $SERVERCFG | grep PUERTO | cut -f2 -d"="` + 1))
39############## ADV
[aeb0e7d7]40
41#
42# Servidor de tareas programadas
43#
44AGENTNAME=ogAdmAgent
45AGENTDAEMON=$BASEDIR/sbin/$AGENTNAME
46AGENTCFG=$BASEDIR/etc/$AGENTNAME.cfg
47AGENTLOG=$BASEDIR/log/$AGENTNAME.log
48AGENTDAEMON_OPTIONS="-f $AGENTCFG -l $AGENTLOG"
49
[ca6183e]50#
51# Opciones Bittorrent
52#
53
54BTTRACK=/usr/bin/bttrack.bittorrent
55BTSEEDER=/usr/bin/btlaunchmany.bittornado
56BTTRACKPORT=6969
57BTTRACKDFILE=/tmp/dstate
58BTTRACKLOG=/opt/opengnsys/log/bttrack.log
59BTINTERVAL=30
60BTTORRENTSDIR=/opt/opengnsys/images
61BTALLOW_GET=1
62BTTRACK_OPTIONS=" --port $BTTRACKPORT --dfile $BTTRACKDFILE --reannounce_interval $BTINTERVAL --logfile $BTTRACKLOG --allowed_dir $BTTORRENTSDIR --allow_get $BTALLOW_GET --parse_allowed_interval 1"
63BTTRACKPID="/var/run/bttrack.pid"
64BTSEEDERPID="/var/run/btseeder.pid"
65
66
67export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/bin"
68
69# Read config file if it is present.
70if [ -r /etc/default/opengnsys ]
71then
[71643c0]72    source /etc/default/opengnsys
[ca6183e]73fi
74
[71643c0]75# Configuración de arranque según la distribución Linux usada.
76config() {
77    OSDISTRIB=$(lsb_release -is 2>/dev/null)
78    case "$OSDISTRIB" in
79        Ubuntu)
80            INITFUNCTIONS=/lib/lsb/init-functions
81            DAEMONSTART="start-stop-daemon --start --quiet --background --exec"
82            EXTRAOPTS="--"
83            DAEMONSTOP="start-stop-daemon --stop --quiet --oknodo --exec"
84            ACTIONMSG="log_daemon_msg"
85            SUCCESSMSG="log_end_msg 0"
86            FAILMSG="log_end_msg 1"
87            ;;
88        *)  echo "Distribución Linux desconcocida o no soportada."
89            exit ;;
90    esac
91    if [ -r $INITFUNCTIONS ]; then
92        source $INITFUNCTIONS
93    fi
94}
95
[ca6183e]96arranca_demonios() {
97  if [ $RUN_OGADMSERVER = "yes" ]
98  then
[71643c0]99     $ACTIONMSG "Iniciando demonio: $SERVERNAME"
100     $DAEMONSTART $SERVERDAEMON $EXTRAOPTS $SERVERDAEMON_OPTIONS
101     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]102  fi
103  if [ $RUN_OGADMSERVER = "yes" ] && [ $RUN_OGADMREPO = "yes" ]
104  then
105     sleep 5 # Damos tiempo a que ogAdmServer este funcionando
106  fi
107  if [ $RUN_OGADMREPO = "yes" ]
108  then
[71643c0]109     $ACTIONMSG "Iniciando demonio: $REPONAME"
110     $DAEMONSTART $REPODAEMON $EXTRAOPTS $REPODAEMON_OPTIONS
111     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]112     ############ ADV   
[71643c0]113     $ACTIONMSG "Iniciando demonio: $REPOAUXNAME"
114     faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
115     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
116     ############ ADV
[ca6183e]117  fi
[aeb0e7d7]118  if [ $RUN_OGADMAGENT = "yes" ]
119  then
[71643c0]120     $ACTIONMSG "Iniciando demonio: $AGENTNAME"
121     $DAEMONSTART $AGENTDAEMON $EXTRAOPTS $AGENTDAEMON_OPTIONS
122     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[aeb0e7d7]123  fi   
[ca6183e]124  if [ $RUN_BTTRACKER = "yes" ]
125  then
[71643c0]126     $ACTIONMSG "Iniciando demonio: $BTTRACK"
[ca6183e]127     start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec $BTTRACK -- $BTTRACK_OPTIONS
[71643c0]128     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]129  fi
130  if [ $RUN_BTSEEDER = "yes" ]
131  then
[71643c0]132     $ACTIONMSG "Iniciando demonio: $BTSEEDER"
[ca6183e]133     start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet  --background --exec $BTSEEDER -- $BTTORRENTSDIR
[71643c0]134     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]135  fi
136
137}
138
139para_demonios() {
140  if [ -e $BTSEEDERPID ]
141  then
[71643c0]142    $ACTIONMSG "Parando demonio: $BTSEEDER"
[ca6183e]143    start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTSEEDERPID
[71643c0]144    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
145    rm -f $BTSEEDERPID
[ca6183e]146  fi
147  if [ -e $BTTRACKPID ]
148  then
[71643c0]149    $ACTIONMSG "Parando demonio: $BTTRACK"
[ca6183e]150    start-stop-daemon --stop --quiet --oknodo --pidfile $BTTRACKPID
[71643c0]151    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
152    rm -f $BTTRACKPID
[aeb0e7d7]153  fi
[71643c0]154  $ACTIONMSG "Parando demonio: $AGENTNAME"
155  $DAEMONSTOP $AGENTDAEMON
156  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
157  $ACTIONMSG "Parando demonio: $REPONAME"
158  $DAEMONSTOP $REPODAEMON
159  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]160  ############# ADV
[71643c0]161  $ACTIONMSG "Parando demonio: $REPOAUXNAME"
[8fc9552]162  pkill faucet
[71643c0]163  [ $? -le 1 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]164  ############ ADV 
[71643c0]165  $ACTIONMSG "Parando demonio: $SERVERNAME"
166  $DAEMONSTOP $SERVERDAEMON
167  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]168}
169
[71643c0]170config
171
[ca6183e]172case "$1" in
173  start)
174        arranca_demonios
175        ;;
176  stop)
177        para_demonios
178        ;;
179  restart)
180        para_demonios
181        arranca_demonios
182        ;;
183
184  *)
[71643c0]185        echo "Uso: $0 {start|stop|restart}"
[ca6183e]186        exit 1
187        ;;
188esac
189
190exit 0
[71643c0]191
Note: See TracBrowser for help on using the repository browser.