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

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 a63345ac was 2934e9e, checked in by ramon <ramongomez@…>, 14 years ago

Versión 1.0.2: corregir errata al parar servicios en Ubuntu (modifica #414)

git-svn-id: https://opengnsys.es/svn/branches/version1.0@2231 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
67export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/bin"
68
69# Read config file if it is present.
70if [ -r /etc/default/opengnsys ]
71then
[4b08fa5]72    source /etc/default/opengnsys
[ca6183e]73fi
74
[2777f20]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)
[5454b9d]80            INITFUNCTIONS=/lib/lsb/init-functions
[e64207e]81            DAEMONSTART="start-stop-daemon --start --quiet --background --exec"
82            EXTRAOPTS="--"
[2934e9e]83            DAEMONSTOP="start-stop-daemon --stop --quiet --oknodo --exec"
[5454b9d]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"
[e64207e]91            EXTRAOPTS=""
[2777f20]92            DAEMONSTOP="killproc"
[5454b9d]93            ACTIONMSG="echo -n"
[2934e9e]94            SUCCESSMSG="( success; echo )"
95            FAILMSG="( failure; echo )"
[2777f20]96            ;;
97        *)  echo "Distribución Linux desconcocida"
98            exit ;;
99    esac
[d4e90c1]100    if [ -r $INITFUNCTIONS ]; then
[5454b9d]101        source $INITFUNCTIONS
102    fi
[2777f20]103}
104
[ca6183e]105arranca_demonios() {
106  if [ $RUN_OGADMSERVER = "yes" ]
107  then
[5454b9d]108     $ACTIONMSG "Iniciando demonio: $SERVERNAME"
[e64207e]109     $DAEMONSTART $SERVERDAEMON $EXTRAOPTS $SERVERDAEMON_OPTIONS
[5454b9d]110     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]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
[5454b9d]118     $ACTIONMSG "Iniciando demonio: $REPONAME"
[e64207e]119     $DAEMONSTART $REPODAEMON $EXTRAOPTS $REPODAEMON_OPTIONS
[5454b9d]120     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]121     ############ ADV   
[5454b9d]122     $ACTIONMSG "Iniciando demonio: $REPOAUXNAME"
123     faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
124     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[2777f20]125     ############ ADV
[ca6183e]126  fi
[aeb0e7d7]127  if [ $RUN_OGADMAGENT = "yes" ]
128  then
[5454b9d]129     $ACTIONMSG "Iniciando demonio: $AGENTNAME"
[e64207e]130     $DAEMONSTART $AGENTDAEMON $EXTRAOPTS $AGENTDAEMON_OPTIONS
[5454b9d]131     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[aeb0e7d7]132  fi   
[ca6183e]133  if [ $RUN_BTTRACKER = "yes" ]
134  then
[5454b9d]135     $ACTIONMSG "Iniciando demonio: $BTTRACK"
[ca6183e]136     start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec $BTTRACK -- $BTTRACK_OPTIONS
[5454b9d]137     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]138  fi
139  if [ $RUN_BTSEEDER = "yes" ]
140  then
[5454b9d]141     $ACTIONMSG "Iniciando demonio: $BTSEEDER"
[ca6183e]142     start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet  --background --exec $BTSEEDER -- $BTTORRENTSDIR
[5454b9d]143     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]144  fi
145
146}
147
148para_demonios() {
149  if [ -e $BTSEEDERPID ]
150  then
[5454b9d]151    $ACTIONMSG "Parando demonio: $BTSEEDER"
[ca6183e]152    start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTSEEDERPID
[5454b9d]153    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
154    rm -f $BTSEEDERPID
[ca6183e]155  fi
156  if [ -e $BTTRACKPID ]
157  then
[5454b9d]158    $ACTIONMSG "Parando demonio: $BTTRACK"
[ca6183e]159    start-stop-daemon --stop --quiet --oknodo --pidfile $BTTRACKPID
[5454b9d]160    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
161    rm -f $BTTRACKPID
[aeb0e7d7]162  fi
[5454b9d]163  $ACTIONMSG "Parando demonio: $AGENTNAME"
[2777f20]164  $DAEMONSTOP $AGENTDAEMON
[5454b9d]165  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
166  $ACTIONMSG "Parando demonio: $REPONAME"
[2777f20]167  $DAEMONSTOP $REPODAEMON
[5454b9d]168  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]169  ############# ADV
[5454b9d]170  $ACTIONMSG "Parando demonio: $REPOAUXNAME"
[8fc9552]171  pkill faucet
[4b08fa5]172  [ $? -le 1 ] && $SUCCESSMSG || $FAILMSG
[8fc9552]173  ############ ADV 
[5454b9d]174  $ACTIONMSG "Parando demonio: $SERVERNAME"
[2777f20]175  $DAEMONSTOP $SERVERDAEMON
[5454b9d]176  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]177}
178
[2777f20]179config
180
[ca6183e]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: opengnsys "$1" {start|stop|restart}"
195        exit 1
196        ;;
197esac
198
199exit 0
Note: See TracBrowser for help on using the repository browser.