source: admin/Sources/Services/opengnsys.init @ 15d8a19

Last change on this file since 15d8a19 was 2694f24, checked in by OpenGnSys Support Team <soporte-og@…>, 5 years ago

#993 Remove ogAdmServerAux

This patch removes ogAdmServerAux which is no longer needed. This script
is replaced by the modifications performed on 'setclientmode' and a call
to the ogServer API POST /modes.

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