source: admin/Sources/Services/opengnsys.init @ cd95622

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since cd95622 was e64207e, checked in by ramon <ramongomez@…>, 14 years ago

Versión 1.0.2: corregir arranque de servicios en Ubuntu (modifica #414)

git-svn-id: https://opengnsys.es/svn/branches/version1.0@2211 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100755
File size: 5.4 KB
Line 
1#!/bin/bash
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"
35############## ADV
36REPOAUXNAME=ogAdmRepoAux
37REPOAUXDAEMON=$BASEDIR/sbin/$REPOAUXNAME
38REPOAUXPORT=$((`cat $SERVERCFG | grep PUERTO | cut -f2 -d"="` + 1))
39############## ADV
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
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
67set -e
68export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/bin"
69
70# Read config file if it is present.
71if [ -r /etc/default/opengnsys ]
72then
73        . /etc/default/opengnsys
74fi
75
76# Configuración de arranque según la distribución Linux usada.
77config() {
78    OSDISTRIB=$(lsb_release -is 2>/dev/null)
79    case "$OSDISTRIB" in
80        Ubuntu)
81            INITFUNCTIONS=/lib/lsb/init-functions
82            DAEMONSTART="start-stop-daemon --start --quiet --background --exec"
83            EXTRAOPTS="--"
84            DAEMONSTOP="start-stop-daemon --stop --quiet --oknodo --name"
85            ACTIONMSG="log_daemon_msg"
86            SUCCESSMSG="log_end_msg 0"
87            FAILMSG="log_end_msg 1"
88            ;;
89        Fedora)
90            INITFUNCTIONS=/etc/init.d/functions
91            DAEMONSTART="daemon"
92            EXTRAOPTS=""
93            DAEMONSTOP="killproc"
94            ACTIONMSG="echo -n"
95            SUCCESSMSG="success; echo"
96            FAILMSG="failure; echo"
97            ;;
98        *)  echo "Distribución Linux desconcocida"
99            exit ;;
100    esac
101    if [ -r $INITFUNCTIONS ]; then
102        source $INITFUNCTIONS
103    fi
104}
105
106arranca_demonios() {
107  if [ $RUN_OGADMSERVER = "yes" ]
108  then
109     $ACTIONMSG "Iniciando demonio: $SERVERNAME"
110     $DAEMONSTART $SERVERDAEMON $EXTRAOPTS $SERVERDAEMON_OPTIONS
111     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
112  fi
113  if [ $RUN_OGADMSERVER = "yes" ] && [ $RUN_OGADMREPO = "yes" ]
114  then
115     sleep 5 # Damos tiempo a que ogAdmServer este funcionando
116  fi
117  if [ $RUN_OGADMREPO = "yes" ]
118  then
119     $ACTIONMSG "Iniciando demonio: $REPONAME"
120     $DAEMONSTART $REPODAEMON $EXTRAOPTS $REPODAEMON_OPTIONS
121     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
122     ############ ADV   
123     $ACTIONMSG "Iniciando demonio: $REPOAUXNAME"
124     faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
125     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
126     ############ ADV
127  fi
128  if [ $RUN_OGADMAGENT = "yes" ]
129  then
130     $ACTIONMSG "Iniciando demonio: $AGENTNAME"
131     $DAEMONSTART $AGENTDAEMON $EXTRAOPTS $AGENTDAEMON_OPTIONS
132     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
133  fi   
134  if [ $RUN_BTTRACKER = "yes" ]
135  then
136     $ACTIONMSG "Iniciando demonio: $BTTRACK"
137     start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec $BTTRACK -- $BTTRACK_OPTIONS
138     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
139  fi
140  if [ $RUN_BTSEEDER = "yes" ]
141  then
142     $ACTIONMSG "Iniciando demonio: $BTSEEDER"
143     start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet  --background --exec $BTSEEDER -- $BTTORRENTSDIR
144     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
145  fi
146
147}
148
149para_demonios() {
150  if [ -e $BTSEEDERPID ]
151  then
152    $ACTIONMSG "Parando demonio: $BTSEEDER"
153    start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTSEEDERPID
154    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
155    rm -f $BTSEEDERPID
156  fi
157  if [ -e $BTTRACKPID ]
158  then
159    $ACTIONMSG "Parando demonio: $BTTRACK"
160    start-stop-daemon --stop --quiet --oknodo --pidfile $BTTRACKPID
161    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
162    rm -f $BTTRACKPID
163  fi
164  $ACTIONMSG "Parando demonio: $AGENTNAME"
165  $DAEMONSTOP $AGENTDAEMON
166  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
167  $ACTIONMSG "Parando demonio: $REPONAME"
168  $DAEMONSTOP $REPODAEMON
169  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
170  ############# ADV
171  $ACTIONMSG "Parando demonio: $REPOAUXNAME"
172  pkill faucet
173  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
174  ############ ADV 
175  $ACTIONMSG "Parando demonio: $SERVERNAME"
176  $DAEMONSTOP $SERVERDAEMON
177  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
178}
179
180config
181
182case "$1" in
183  start)
184        arranca_demonios
185        ;;
186  stop)
187        para_demonios
188        ;;
189  restart)
190        para_demonios
191        arranca_demonios
192        ;;
193
194  *)
195        echo "Uso: opengnsys "$1" {start|stop|restart}"
196        exit 1
197        ;;
198esac
199
200exit 0
Note: See TracBrowser for help on using the repository browser.