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
RevLine 
[d4e90c1]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
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
[2777f20]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)
[5454b9d]81            INITFUNCTIONS=/lib/lsb/init-functions
[e64207e]82            DAEMONSTART="start-stop-daemon --start --quiet --background --exec"
83            EXTRAOPTS="--"
84            DAEMONSTOP="start-stop-daemon --stop --quiet --oknodo --name"
[5454b9d]85            ACTIONMSG="log_daemon_msg"
86            SUCCESSMSG="log_end_msg 0"
87            FAILMSG="log_end_msg 1"
[2777f20]88            ;;
89        Fedora)
[5454b9d]90            INITFUNCTIONS=/etc/init.d/functions
[2777f20]91            DAEMONSTART="daemon"
[e64207e]92            EXTRAOPTS=""
[2777f20]93            DAEMONSTOP="killproc"
[5454b9d]94            ACTIONMSG="echo -n"
95            SUCCESSMSG="success; echo"
96            FAILMSG="failure; echo"
[2777f20]97            ;;
98        *)  echo "Distribución Linux desconcocida"
99            exit ;;
100    esac
[d4e90c1]101    if [ -r $INITFUNCTIONS ]; then
[5454b9d]102        source $INITFUNCTIONS
103    fi
[2777f20]104}
105
[ca6183e]106arranca_demonios() {
107  if [ $RUN_OGADMSERVER = "yes" ]
108  then
[5454b9d]109     $ACTIONMSG "Iniciando demonio: $SERVERNAME"
[e64207e]110     $DAEMONSTART $SERVERDAEMON $EXTRAOPTS $SERVERDAEMON_OPTIONS
[5454b9d]111     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]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
[5454b9d]119     $ACTIONMSG "Iniciando demonio: $REPONAME"
[e64207e]120     $DAEMONSTART $REPODAEMON $EXTRAOPTS $REPODAEMON_OPTIONS
[5454b9d]121     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]122     ############ ADV   
[5454b9d]123     $ACTIONMSG "Iniciando demonio: $REPOAUXNAME"
124     faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
125     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[2777f20]126     ############ ADV
[ca6183e]127  fi
[aeb0e7d7]128  if [ $RUN_OGADMAGENT = "yes" ]
129  then
[5454b9d]130     $ACTIONMSG "Iniciando demonio: $AGENTNAME"
[e64207e]131     $DAEMONSTART $AGENTDAEMON $EXTRAOPTS $AGENTDAEMON_OPTIONS
[5454b9d]132     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[aeb0e7d7]133  fi   
[ca6183e]134  if [ $RUN_BTTRACKER = "yes" ]
135  then
[5454b9d]136     $ACTIONMSG "Iniciando demonio: $BTTRACK"
[ca6183e]137     start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec $BTTRACK -- $BTTRACK_OPTIONS
[5454b9d]138     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]139  fi
140  if [ $RUN_BTSEEDER = "yes" ]
141  then
[5454b9d]142     $ACTIONMSG "Iniciando demonio: $BTSEEDER"
[ca6183e]143     start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet  --background --exec $BTSEEDER -- $BTTORRENTSDIR
[5454b9d]144     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]145  fi
146
147}
148
149para_demonios() {
150  if [ -e $BTSEEDERPID ]
151  then
[5454b9d]152    $ACTIONMSG "Parando demonio: $BTSEEDER"
[ca6183e]153    start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTSEEDERPID
[5454b9d]154    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
155    rm -f $BTSEEDERPID
[ca6183e]156  fi
157  if [ -e $BTTRACKPID ]
158  then
[5454b9d]159    $ACTIONMSG "Parando demonio: $BTTRACK"
[ca6183e]160    start-stop-daemon --stop --quiet --oknodo --pidfile $BTTRACKPID
[5454b9d]161    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
162    rm -f $BTTRACKPID
[aeb0e7d7]163  fi
[5454b9d]164  $ACTIONMSG "Parando demonio: $AGENTNAME"
[2777f20]165  $DAEMONSTOP $AGENTDAEMON
[5454b9d]166  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
167  $ACTIONMSG "Parando demonio: $REPONAME"
[2777f20]168  $DAEMONSTOP $REPODAEMON
[5454b9d]169  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]170  ############# ADV
[5454b9d]171  $ACTIONMSG "Parando demonio: $REPOAUXNAME"
[8fc9552]172  pkill faucet
[5454b9d]173  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]174  ############ ADV 
[5454b9d]175  $ACTIONMSG "Parando demonio: $SERVERNAME"
[2777f20]176  $DAEMONSTOP $SERVERDAEMON
[5454b9d]177  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]178}
179
[2777f20]180config
181
[ca6183e]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.