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

Last change on this file since d4daa34 was 4816ea5, checked in by OpenGnSys Support Team <soporte-og@…>, 5 years ago

#971 Remove ogAdmAgent initialization

All the functionalities of the ogAdmAgent are now in the ogAdmServer.
So, the it is not needed anymore.

This commit remove the installation and update of the ogAdmAgent, adds a
check to remove it if exists and removes it from the OpenGnsys init
script.

A future patch will remove all the code related to the ogAdmAgent.

  • Property mode set to 100755
File size: 6.1 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
[d7fe54a]9# Short-Description: Servicios del sistema OpenGnsys
10# Description:       Servicios del sistema OpenGnsys
[ca6183e]11### END INIT INFO
12
13#
14# Definiciones globales
15#
16BASEDIR=/opt/opengnsys
[e3d8dd1]17OPENGNSYSUSER="opengnsys"
18IMAGEDIR=$BASEDIR/images
19CLIENTLOGDIR=$BASEDIR/log/clients
[ca6183e]20
21#
[d7fe54a]22# Servidor de OpenGnsys
[ca6183e]23#
24SERVERNAME=ogAdmServer
25SERVERDAEMON=$BASEDIR/sbin/$SERVERNAME
26SERVERCFG=$BASEDIR/etc/$SERVERNAME.cfg
27SERVERLOG=$BASEDIR/log/$SERVERNAME.log
28SERVERDAEMON_OPTIONS="-f $SERVERCFG -l $SERVERLOG"
29
30#
31# Servidor de Repositorio
32#
[8fc9552]33############## ADV
34REPOAUXNAME=ogAdmRepoAux
35REPOAUXDAEMON=$BASEDIR/sbin/$REPOAUXNAME
[e3d8dd1]36REPOAUXPORT=$(awk -F= '/PUERTO/ {print $2+1}' $SERVERCFG 2>/dev/null)
[8fc9552]37############## ADV
[831830f]38############# IRINA # para setBootMode desde el cliente
39SERVERAUXNAME=ogAdmServerAux
40SERVERAUXDAEMON=$BASEDIR/sbin/$SERVERAUXNAME
41SERVERAUXPORT=2011 
42############# IRINA
[aeb0e7d7]43
44#
[ca6183e]45# Opciones Bittorrent
46#
47
48BTTRACK=/usr/bin/bttrack.bittorrent
49BTSEEDER=/usr/bin/btlaunchmany.bittornado
50BTTRACKPORT=6969
51BTTRACKDFILE=/tmp/dstate
[e3d8dd1]52BTTRACKLOG=$BASEDIR/log/bttrack.log
[ca6183e]53BTINTERVAL=30
[e3d8dd1]54BTTORRENTSDIR=$BASEDIR/images
[1cf578b]55BTTRACK_OPTIONS=" --port $BTTRACKPORT --dfile $BTTRACKDFILE --reannounce_interval $BTINTERVAL --logfile $BTTRACKLOG --allowed_dir $BTTORRENTSDIR --allow_get 1"
[ca6183e]56BTTRACKPID="/var/run/bttrack.pid"
57BTSEEDERPID="/var/run/btseeder.pid"
58
59
60export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/bin"
61
62# Read config file if it is present.
[1cf578b]63if [ -r /etc/default/opengnsys ]; then
[4b08fa5]64    source /etc/default/opengnsys
[ca6183e]65fi
66
[2777f20]67# Configuración de arranque según la distribución Linux usada.
68config() {
[6374326]69    if [ -f /etc/os-release ]; then
70        source /etc/os-release
[eeb438a]71        OSDISTRIB="$ID"
[6374326]72    else
73        OSDISTRIB=$(lsb_release -is 2>/dev/null)
74    fi
[eeb438a]75    OSDISTRIB="${OSDISTRIB,,}"
[2777f20]76    case "$OSDISTRIB" in
[eeb438a]77        ubuntu|debian|linuxmint)
[5454b9d]78            INITFUNCTIONS=/lib/lsb/init-functions
[e64207e]79            DAEMONSTART="start-stop-daemon --start --quiet --background --exec"
80            EXTRAOPTS="--"
[9d859d0]81            DAEMONSTOP="start-stop-daemon --stop --quiet --oknodo --name"
[5454b9d]82            ACTIONMSG="log_daemon_msg"
83            SUCCESSMSG="log_end_msg 0"
84            FAILMSG="log_end_msg 1"
[1cf578b]85            TRACKERSTART="start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec"
86            BTTRACK_OPTIONS="$BTTRACK_OPTIONS --parse_allowed_interval 1"
[9d859d0]87            TRACKERSTOP="start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTTRACKPID"
[1cf578b]88            SEEDERSTART="start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet --background --exec"
89            SEEDERSTOP="start-stop-daemon --stop --quiet --oknodo --pidfile $BTSEEDERPID"
[2777f20]90            ;;
[eeb438a]91        centos|fedora)
[5454b9d]92            INITFUNCTIONS=/etc/init.d/functions
[2777f20]93            DAEMONSTART="daemon"
[55477d2]94            ENDOPTS="&"
[2777f20]95            DAEMONSTOP="killproc"
[5454b9d]96            ACTIONMSG="echo -n"
[55477d2]97            SUCCESSMSG="eval ( success; echo )"
98            FAILMSG="eval ( failure; echo )"
[1cf578b]99            BTTRACK=/usr/bin/bttrack.py
100            BTSEEDER=/usr/bin/btlaunchmany.py
101            TRACKERSTART="daemon --pidfile $BTTRACKPID"
102            TRACKERSTOP="killproc -p $BTTRACKPID $BTTRACK"
103            SEEDERSTART="daemon --pidfile $BTSEEDERPID"
104            SEEDERSTOP="killproc -p $BTSEEDERPID $BTSEEDER"
[2777f20]105            ;;
[6ef01d9]106        *)  echo "Distribución Linux desconcocida o no soportada."
[2777f20]107            exit ;;
108    esac
[d4e90c1]109    if [ -r $INITFUNCTIONS ]; then
[5454b9d]110        source $INITFUNCTIONS
111    fi
[2777f20]112}
113
[ca6183e]114arranca_demonios() {
[d7fe54a]115  # Comprobar que está instalado OpenGnsys.
[e3d8dd1]116  if [ ! -d $BASEDIR ]; then
117     $ACTIONMSG "ERROR: No existe el directorio $BASEDIR"
118     $FAILMSG
119     exit $?
120  fi
[ea60f41]121  # Deshabilitar modo reforzado de SELinux.
122  [ -f /selinux/enforce ] && echo 0 > /selinux/enforce
[e3d8dd1]123  # Verificar permisos básicos.
124  if [ "$(stat --printf="%A%G" $IMAGEDIR 2>/dev/null)" != "drwxrwxr-x$OPENGNSYSUSER" ]; then
125     mkdir $IMAGEDIR 2>/dev/null
126     chmod 775 $IMAGEDIR
127     chgrp $OPENGNSYSUSER $IMAGEDIR
128  fi
129  if [ "$(stat --printf="%A%G" $CLIENTLOGDIR 2>/dev/null)" != "drwxrwxr-x$OPENGNSYSUSER" ]; then
130     mkdir -p $CLIENTLOGDIR 2>/dev/null
131     chmod 775 $CLIENTLOGDIR
132     chgrp $OPENGNSYSUSER $CLIENTLOGDIR
133  fi
134  # Arrancar los servicios indicados.
[1cf578b]135  if [ $RUN_OGADMSERVER = "yes" ]; then
[5454b9d]136     $ACTIONMSG "Iniciando demonio: $SERVERNAME"
[55477d2]137     $DAEMONSTART $SERVERDAEMON $EXTRAOPTS $SERVERDAEMON_OPTIONS $ENDOPTS
[5454b9d]138     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[831830f]139     # Para SetBootmode desde el cliente
140     $ACTIONMSG "Iniciando demonio: $SERVERAUXNAME"                    #
141     faucet $SERVERAUXPORT --daemon --in bash -c "$SERVERAUXDAEMON"    #   NUEVO
142     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]143  fi
[1cf578b]144  if [ $RUN_OGADMREPO = "yes" ]; then
[5454b9d]145     $ACTIONMSG "Iniciando demonio: $REPOAUXNAME"
146     faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
147     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]148  fi
[1cf578b]149  if [ $RUN_BTTRACKER = "yes" ]; then
[5454b9d]150     $ACTIONMSG "Iniciando demonio: $BTTRACK"
[1cf578b]151     $TRACKERSTART $BTTRACK $EXTRAOPTS $BTTRACK_OPTIONS $ENDOPTS
[5454b9d]152     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]153  fi
[1cf578b]154  if [ $RUN_BTSEEDER = "yes" ]; then
[5454b9d]155     $ACTIONMSG "Iniciando demonio: $BTSEEDER"
[1cf578b]156     $SEEDERSTART $BTSEEDER $EXTRAOPTS $BTTORRENTSDIR &>/dev/null $ENDOPTS
[5454b9d]157     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]158  fi
159
160}
161
162para_demonios() {
[1cf578b]163  if [ -e $BTSEEDERPID ]; then
[5454b9d]164    $ACTIONMSG "Parando demonio: $BTSEEDER"
[1cf578b]165    $SEEDERSTOP
[5454b9d]166    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
167    rm -f $BTSEEDERPID
[ca6183e]168  fi
[1cf578b]169  if [ -e $BTTRACKPID ]; then
[5454b9d]170    $ACTIONMSG "Parando demonio: $BTTRACK"
[1cf578b]171    $TRACKERSTOP
[5454b9d]172    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
173    rm -f $BTTRACKPID
[aeb0e7d7]174  fi
[5454b9d]175  $ACTIONMSG "Parando demonio: $REPOAUXNAME"
[8fc9552]176  pkill faucet
[4b08fa5]177  [ $? -le 1 ] && $SUCCESSMSG || $FAILMSG
[5454b9d]178  $ACTIONMSG "Parando demonio: $SERVERNAME"
[9d859d0]179  $DAEMONSTOP $SERVERNAME
[5454b9d]180  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
[ca6183e]181}
182
[2777f20]183config
184
[ca6183e]185case "$1" in
186  start)
187        arranca_demonios
188        ;;
189  stop)
190        para_demonios
191        ;;
192  restart)
193        para_demonios
194        arranca_demonios
195        ;;
196
197  *)
[6ef01d9]198        echo "Uso: $0 {start|stop|restart}"
[ca6183e]199        exit 1
200        ;;
201esac
202
203exit 0
[e3d8dd1]204
Note: See TracBrowser for help on using the repository browser.