source: admin/Sources/Services/opengnsys.init @ 653c64e

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 653c64e was d4e90c1, checked in by ramon <ramongomez@…>, 14 years ago

Versión 1.0.2: corregir erratas en actualizador y en arranque de servicios.

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

  • Property mode set to 100755
File size: 5.2 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
[d4e90c1]82            DAEMONSTART="start_daemon"
[5454b9d]83            DAEMONSTOP="killproc"
84            ACTIONMSG="log_daemon_msg"
85            SUCCESSMSG="log_end_msg 0"
86            FAILMSG="log_end_msg 1"
[2777f20]87            ;;
88        Fedora)
[5454b9d]89            INITFUNCTIONS=/etc/init.d/functions
[2777f20]90            DAEMONSTART="daemon"
91            DAEMONSTOP="killproc"
[5454b9d]92            ACTIONMSG="echo -n"
93            SUCCESSMSG="success; echo"
94            FAILMSG="failure; echo"
[2777f20]95            ;;
96        *)  echo "Distribución Linux desconcocida"
97            exit ;;
98    esac
[d4e90c1]99    if [ -r $INITFUNCTIONS ]; then
[5454b9d]100        source $INITFUNCTIONS
101    fi
[2777f20]102}
103
[ca6183e]104arranca_demonios() {
105  if [ $RUN_OGADMSERVER = "yes" ]
106  then
[5454b9d]107     $ACTIONMSG "Iniciando demonio: $SERVERNAME"
108     $DAEMONSTART $SERVERDAEMON $SERVERDAEMON_OPTIONS
109     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]110  fi
111  if [ $RUN_OGADMSERVER = "yes" ] && [ $RUN_OGADMREPO = "yes" ]
112  then
113     sleep 5 # Damos tiempo a que ogAdmServer este funcionando
114  fi
115  if [ $RUN_OGADMREPO = "yes" ]
116  then
[5454b9d]117     $ACTIONMSG "Iniciando demonio: $REPONAME"
118     $DAEMONSTART $REPODAEMON $REPODAEMON_OPTIONS
119     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]120     ############ ADV   
[5454b9d]121     $ACTIONMSG "Iniciando demonio: $REPOAUXNAME"
122     faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
123     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[2777f20]124     ############ ADV
[ca6183e]125  fi
[aeb0e7d7]126  if [ $RUN_OGADMAGENT = "yes" ]
127  then
[5454b9d]128     $ACTIONMSG "Iniciando demonio: $AGENTNAME"
129     $DAEMONSTART $AGENTDAEMON $AGENTDAEMON_OPTIONS
130     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[aeb0e7d7]131  fi   
[ca6183e]132  if [ $RUN_BTTRACKER = "yes" ]
133  then
[5454b9d]134     $ACTIONMSG "Iniciando demonio: $BTTRACK"
[ca6183e]135     start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec $BTTRACK -- $BTTRACK_OPTIONS
[5454b9d]136     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]137  fi
138  if [ $RUN_BTSEEDER = "yes" ]
139  then
[5454b9d]140     $ACTIONMSG "Iniciando demonio: $BTSEEDER"
[ca6183e]141     start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet  --background --exec $BTSEEDER -- $BTTORRENTSDIR
[5454b9d]142     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]143  fi
144
145}
146
147para_demonios() {
148  if [ -e $BTSEEDERPID ]
149  then
[5454b9d]150    $ACTIONMSG "Parando demonio: $BTSEEDER"
[ca6183e]151    start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTSEEDERPID
[5454b9d]152    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
153    rm -f $BTSEEDERPID
[ca6183e]154  fi
155  if [ -e $BTTRACKPID ]
156  then
[5454b9d]157    $ACTIONMSG "Parando demonio: $BTTRACK"
[ca6183e]158    start-stop-daemon --stop --quiet --oknodo --pidfile $BTTRACKPID
[5454b9d]159    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
160    rm -f $BTTRACKPID
[aeb0e7d7]161  fi
[5454b9d]162  $ACTIONMSG "Parando demonio: $AGENTNAME"
[2777f20]163  $DAEMONSTOP $AGENTDAEMON
[5454b9d]164  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
165  $ACTIONMSG "Parando demonio: $REPONAME"
[2777f20]166  $DAEMONSTOP $REPODAEMON
[5454b9d]167  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]168  ############# ADV
[5454b9d]169  $ACTIONMSG "Parando demonio: $REPOAUXNAME"
[8fc9552]170  pkill faucet
[5454b9d]171  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]172  ############ ADV 
[5454b9d]173  $ACTIONMSG "Parando demonio: $SERVERNAME"
[2777f20]174  $DAEMONSTOP $SERVERDAEMON
[5454b9d]175  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]176}
177
[2777f20]178config
179
[ca6183e]180case "$1" in
181  start)
182        arranca_demonios
183        ;;
184  stop)
185        para_demonios
186        ;;
187  restart)
188        para_demonios
189        arranca_demonios
190        ;;
191
192  *)
193        echo "Uso: opengnsys "$1" {start|stop|restart}"
194        exit 1
195        ;;
196esac
197
198exit 0
Note: See TracBrowser for help on using the repository browser.