source: admin/Sources/Services/opengnsys.init @ 73a1bd6

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 73a1bd6 was 0fe2488, checked in by ramon <ramongomez@…>, 13 years ago

Versión 1.0.3, #414: Instalación completa en Debian 6, independizando el directorio para TFTP.

git-svn-id: https://opengnsys.es/svn/branches/version1.0@2440 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
67export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/bin"
68
69# Read config file if it is present.
70if [ -r /etc/default/opengnsys ]
71then
72    source /etc/default/opengnsys
73fi
74
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|Debian|LinuxMint)
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        Fedora)
89            INITFUNCTIONS=/etc/init.d/functions
90            DAEMONSTART="daemon"
91            EXTRAOPTS=""
92            DAEMONSTOP="killproc"
93            ACTIONMSG="echo -n"
94            SUCCESSMSG="( success; echo )"
95            FAILMSG="( failure; echo )"
96            ;;
97        *)  echo "Distribución Linux desconcocida o no soportada."
98            exit ;;
99    esac
100    if [ -r $INITFUNCTIONS ]; then
101        source $INITFUNCTIONS
102    fi
103}
104
105arranca_demonios() {
106  if [ $RUN_OGADMSERVER = "yes" ]
107  then
108     $ACTIONMSG "Iniciando demonio: $SERVERNAME"
109     $DAEMONSTART $SERVERDAEMON $EXTRAOPTS $SERVERDAEMON_OPTIONS
110     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
111  fi
112  if [ $RUN_OGADMSERVER = "yes" ] && [ $RUN_OGADMREPO = "yes" ]
113  then
114     sleep 5 # Damos tiempo a que ogAdmServer este funcionando
115  fi
116  if [ $RUN_OGADMREPO = "yes" ]
117  then
118     $ACTIONMSG "Iniciando demonio: $REPONAME"
119     $DAEMONSTART $REPODAEMON $EXTRAOPTS $REPODAEMON_OPTIONS
120     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
121     ############ ADV   
122     $ACTIONMSG "Iniciando demonio: $REPOAUXNAME"
123     faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
124     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
125     ############ ADV
126  fi
127  if [ $RUN_OGADMAGENT = "yes" ]
128  then
129     $ACTIONMSG "Iniciando demonio: $AGENTNAME"
130     $DAEMONSTART $AGENTDAEMON $EXTRAOPTS $AGENTDAEMON_OPTIONS
131     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
132  fi   
133  if [ $RUN_BTTRACKER = "yes" ]
134  then
135     $ACTIONMSG "Iniciando demonio: $BTTRACK"
136     start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec $BTTRACK -- $BTTRACK_OPTIONS
137     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
138  fi
139  if [ $RUN_BTSEEDER = "yes" ]
140  then
141     $ACTIONMSG "Iniciando demonio: $BTSEEDER"
142     start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet  --background --exec $BTSEEDER -- $BTTORRENTSDIR
143     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
144  fi
145
146}
147
148para_demonios() {
149  if [ -e $BTSEEDERPID ]
150  then
151    $ACTIONMSG "Parando demonio: $BTSEEDER"
152    start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTSEEDERPID
153    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
154    rm -f $BTSEEDERPID
155  fi
156  if [ -e $BTTRACKPID ]
157  then
158    $ACTIONMSG "Parando demonio: $BTTRACK"
159    start-stop-daemon --stop --quiet --oknodo --pidfile $BTTRACKPID
160    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
161    rm -f $BTTRACKPID
162  fi
163  $ACTIONMSG "Parando demonio: $AGENTNAME"
164  $DAEMONSTOP $AGENTDAEMON
165  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
166  $ACTIONMSG "Parando demonio: $REPONAME"
167  $DAEMONSTOP $REPODAEMON
168  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
169  ############# ADV
170  $ACTIONMSG "Parando demonio: $REPOAUXNAME"
171  pkill faucet
172  [ $? -le 1 ] && $SUCCESSMSG || $FAILMSG
173  ############ ADV 
174  $ACTIONMSG "Parando demonio: $SERVERNAME"
175  $DAEMONSTOP $SERVERDAEMON
176  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
177}
178
179config
180
181case "$1" in
182  start)
183        arranca_demonios
184        ;;
185  stop)
186        para_demonios
187        ;;
188  restart)
189        para_demonios
190        arranca_demonios
191        ;;
192
193  *)
194        echo "Uso: $0 {start|stop|restart}"
195        exit 1
196        ;;
197esac
198
199exit 0
Note: See TracBrowser for help on using the repository browser.