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

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 b86ca81 was ea60f41, checked in by ramon <ramongomez@…>, 13 years ago

Versión 1.0.4, #414: Modificar configuración de PHP y SELinux para consola web en CentOS.

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

  • Property mode set to 100755
File size: 6.2 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
17OPENGNSYSUSER="opengnsys"
18IMAGEDIR=$BASEDIR/images
19CLIENTLOGDIR=$BASEDIR/log/clients
20
21#
22# Servidor de OpenGnSys
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#
33REPONAME=ogAdmRepo
34REPODAEMON=$BASEDIR/sbin/$REPONAME
35REPOCFG=$BASEDIR/etc/$REPONAME.cfg
36REPOLOG=$BASEDIR/log/$REPONAME.log
37REPODAEMON_OPTIONS="-f $REPOCFG -l $REPOLOG"
38############## ADV
39REPOAUXNAME=ogAdmRepoAux
40REPOAUXDAEMON=$BASEDIR/sbin/$REPOAUXNAME
41REPOAUXPORT=$(awk -F= '/PUERTO/ {print $2+1}' $SERVERCFG 2>/dev/null)
42############## ADV
43
44#
45# Servidor de tareas programadas
46#
47AGENTNAME=ogAdmAgent
48AGENTDAEMON=$BASEDIR/sbin/$AGENTNAME
49AGENTCFG=$BASEDIR/etc/$AGENTNAME.cfg
50AGENTLOG=$BASEDIR/log/$AGENTNAME.log
51AGENTDAEMON_OPTIONS="-f $AGENTCFG -l $AGENTLOG"
52
53#
54# Opciones Bittorrent
55#
56
57BTTRACK=/usr/bin/bttrack.bittorrent
58BTSEEDER=/usr/bin/btlaunchmany.bittornado
59BTTRACKPORT=6969
60BTTRACKDFILE=/tmp/dstate
61BTTRACKLOG=$BASEDIR/log/bttrack.log
62BTINTERVAL=30
63BTTORRENTSDIR=$BASEDIR/images
64BTALLOW_GET=1
65BTTRACK_OPTIONS=" --port $BTTRACKPORT --dfile $BTTRACKDFILE --reannounce_interval $BTINTERVAL --logfile $BTTRACKLOG --allowed_dir $BTTORRENTSDIR --allow_get $BTALLOW_GET --parse_allowed_interval 1"
66BTTRACKPID="/var/run/bttrack.pid"
67BTSEEDERPID="/var/run/btseeder.pid"
68
69
70export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/bin"
71
72# Read config file if it is present.
73if [ -r /etc/default/opengnsys ]
74then
75    source /etc/default/opengnsys
76fi
77
78# Configuración de arranque según la distribución Linux usada.
79config() {
80    OSDISTRIB=$(lsb_release -is 2>/dev/null)
81    case "$OSDISTRIB" in
82        Ubuntu|Debian|LinuxMint)
83            INITFUNCTIONS=/lib/lsb/init-functions
84            DAEMONSTART="start-stop-daemon --start --quiet --background --exec"
85            EXTRAOPTS="--"
86            DAEMONSTOP="start-stop-daemon --stop --quiet --oknodo --exec"
87            ACTIONMSG="log_daemon_msg"
88            SUCCESSMSG="log_end_msg 0"
89            FAILMSG="log_end_msg 1"
90            ;;
91        CentOS|Fedora)
92            INITFUNCTIONS=/etc/init.d/functions
93            DAEMONSTART="daemon"
94            ENDOPTS="&"
95            DAEMONSTOP="killproc"
96            ACTIONMSG="echo -n"
97            SUCCESSMSG="eval ( success; echo )"
98            FAILMSG="eval ( failure; echo )"
99            ;;
100        *)  echo "Distribución Linux desconcocida o no soportada."
101            exit ;;
102    esac
103    if [ -r $INITFUNCTIONS ]; then
104        source $INITFUNCTIONS
105    fi
106}
107
108arranca_demonios() {
109  # Comprobar que está instalado OpenGnSys.
110  if [ ! -d $BASEDIR ]; then
111     $ACTIONMSG "ERROR: No existe el directorio $BASEDIR"
112     $FAILMSG
113     exit $?
114  fi
115  # Deshabilitar modo reforzado de SELinux.
116  [ -f /selinux/enforce ] && echo 0 > /selinux/enforce
117  # Verificar permisos básicos.
118  if [ "$(stat --printf="%A%G" $IMAGEDIR 2>/dev/null)" != "drwxrwxr-x$OPENGNSYSUSER" ]; then
119     mkdir $IMAGEDIR 2>/dev/null
120     chmod 775 $IMAGEDIR
121     chgrp $OPENGNSYSUSER $IMAGEDIR
122  fi
123  if [ "$(stat --printf="%A%G" $CLIENTLOGDIR 2>/dev/null)" != "drwxrwxr-x$OPENGNSYSUSER" ]; then
124     mkdir -p $CLIENTLOGDIR 2>/dev/null
125     chmod 775 $CLIENTLOGDIR
126     chgrp $OPENGNSYSUSER $CLIENTLOGDIR
127  fi
128  # Arrancar los servicios indicados.
129  if [ $RUN_OGADMSERVER = "yes" ]
130  then
131     $ACTIONMSG "Iniciando demonio: $SERVERNAME"
132     $DAEMONSTART $SERVERDAEMON $EXTRAOPTS $SERVERDAEMON_OPTIONS $ENDOPTS
133     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
134  fi
135  if [ $RUN_OGADMSERVER = "yes" ] && [ $RUN_OGADMREPO = "yes" ]
136  then
137     sleep 5 # Damos tiempo a que ogAdmServer este funcionando
138  fi
139  if [ $RUN_OGADMREPO = "yes" ]
140  then
141     $ACTIONMSG "Iniciando demonio: $REPONAME"
142     $DAEMONSTART $REPODAEMON $EXTRAOPTS $REPODAEMON_OPTIONS $ENDOPTS
143     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
144     ############ ADV   
145     $ACTIONMSG "Iniciando demonio: $REPOAUXNAME"
146     faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
147     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
148     ############ ADV
149  fi
150  if [ $RUN_OGADMAGENT = "yes" ]
151  then
152     $ACTIONMSG "Iniciando demonio: $AGENTNAME"
153     $DAEMONSTART $AGENTDAEMON $EXTRAOPTS $AGENTDAEMON_OPTIONS $ENDOPTS
154     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
155  fi   
156  if [ $RUN_BTTRACKER = "yes" ]
157  then
158     $ACTIONMSG "Iniciando demonio: $BTTRACK"
159     start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec $BTTRACK -- $BTTRACK_OPTIONS
160     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
161  fi
162  if [ $RUN_BTSEEDER = "yes" ]
163  then
164     $ACTIONMSG "Iniciando demonio: $BTSEEDER"
165     start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet  --background --exec $BTSEEDER -- $BTTORRENTSDIR
166     [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
167  fi
168
169}
170
171para_demonios() {
172  if [ -e $BTSEEDERPID ]
173  then
174    $ACTIONMSG "Parando demonio: $BTSEEDER"
175    start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTSEEDERPID
176    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
177    rm -f $BTSEEDERPID
178  fi
179  if [ -e $BTTRACKPID ]
180  then
181    $ACTIONMSG "Parando demonio: $BTTRACK"
182    start-stop-daemon --stop --quiet --oknodo --pidfile $BTTRACKPID
183    [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
184    rm -f $BTTRACKPID
185  fi
186  $ACTIONMSG "Parando demonio: $AGENTNAME"
187  $DAEMONSTOP $AGENTDAEMON
188  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
189  $ACTIONMSG "Parando demonio: $REPONAME"
190  $DAEMONSTOP $REPODAEMON
191  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
192  ############# ADV
193  $ACTIONMSG "Parando demonio: $REPOAUXNAME"
194  pkill faucet
195  [ $? -le 1 ] && $SUCCESSMSG || $FAILMSG
196  ############ ADV 
197  $ACTIONMSG "Parando demonio: $SERVERNAME"
198  $DAEMONSTOP $SERVERDAEMON
199  [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
200}
201
202config
203
204case "$1" in
205  start)
206        arranca_demonios
207        ;;
208  stop)
209        para_demonios
210        ;;
211  restart)
212        para_demonios
213        arranca_demonios
214        ;;
215
216  *)
217        echo "Uso: $0 {start|stop|restart}"
218        exit 1
219        ;;
220esac
221
222exit 0
223
Note: See TracBrowser for help on using the repository browser.