summaryrefslogtreecommitdiffstats
path: root/admin/Sources/Services
diff options
context:
space:
mode:
Diffstat (limited to 'admin/Sources/Services')
-rw-r--r--admin/Sources/Services/ogAdmAgent/Makefile9
-rw-r--r--admin/Sources/Services/ogAdmBoot/Makefile9
-rw-r--r--admin/Sources/Services/ogAdmRepo/Makefile9
-rwxr-xr-xadmin/Sources/Services/ogAdmRepoAux36
-rw-r--r--admin/Sources/Services/ogAdmServer/Makefile9
-rwxr-xr-xadmin/Sources/Services/opengnsys.init106
6 files changed, 109 insertions, 69 deletions
diff --git a/admin/Sources/Services/ogAdmAgent/Makefile b/admin/Sources/Services/ogAdmAgent/Makefile
index 3b483e85..6a7a180a 100644
--- a/admin/Sources/Services/ogAdmAgent/Makefile
+++ b/admin/Sources/Services/ogAdmAgent/Makefile
@@ -8,11 +8,16 @@ INSTALL_DIR := /opt/opengnsys
# Opciones de compilacion
#CFLAGS := -O0 -g -Wall -I../../Includes # Depuracion
-CFLAGS := -O3 -Wall -I../../Includes # Optimizacion
+CFLAGS := -O3 -Wall -I../../Includes # Depuracion
CPPFLAGS := $(CFLAGS)
# Opciones de linkado
-LDFLAGS := -L/usr/lib -L/usr/lib/mysql -lpthread -lmysqlclient
+LBIT=$(shell getconf LONG_BIT)
+ifeq ($(LBIT), 64)
+ LDFLAGS := -L/usr/lib64 -L/usr/lib64/mysql -lpthread -lmysqlclient
+else
+ LDFLAGS := -L/usr/lib -L/usr/lib/mysql -lpthread -lmysqlclient
+endif
# Ficheros objetos
OBJS := ../../Includes/Database.o sources/ogAdmAgent.o
diff --git a/admin/Sources/Services/ogAdmBoot/Makefile b/admin/Sources/Services/ogAdmBoot/Makefile
index 79b30104..a8d9da0e 100644
--- a/admin/Sources/Services/ogAdmBoot/Makefile
+++ b/admin/Sources/Services/ogAdmBoot/Makefile
@@ -8,11 +8,16 @@ INSTALL_DIR := /opt/opengnsys
# Opciones de compilacion
#CFLAGS := -O0 -g -Wall -I../includes # Depuracion
-CFLAGS := -O3 -Wall -I../includes # Optimizacion
+CFLAGS := -O3 -Wall -I../includes # Depuracion
CPPFLAGS := $(CFLAGS)
# Opciones de linkado
-LDFLAGS := -L/usr/lib -L/usr/lib/mysql -lpthread -lmysqlclient
+LBIT=$(shell getconf LONG_BIT)
+ifeq ($(LBIT), 64)
+ LDFLAGS := -L/usr/lib64 -L/usr/lib64/mysql -lpthread -lmysqlclient
+else
+ LDFLAGS := -L/usr/lib -L/usr/lib/mysql -lpthread -lmysqlclient
+endif
# Ficheros objetos
OBJS := ../includes/Database.o sources/ogAdmBoot.o
diff --git a/admin/Sources/Services/ogAdmRepo/Makefile b/admin/Sources/Services/ogAdmRepo/Makefile
index 903467f4..b7b9a592 100644
--- a/admin/Sources/Services/ogAdmRepo/Makefile
+++ b/admin/Sources/Services/ogAdmRepo/Makefile
@@ -8,11 +8,16 @@ INSTALL_DIR := /opt/opengnsys
# Opciones de compilacion
#CFLAGS := -O0 -g -Wall -I../../Includes # Depuracion
-CFLAGS := -O3 -Wall -I../../Includes # Optimizacion
+CFLAGS := -O3 -Wall -I../../Includes # Depuracion
CPPFLAGS := $(CFLAGS)
# Opciones de linkado
-LDFLAGS := -L/usr/lib -L/usr/lib/mysql -lpthread -lmysqlclient
+LBIT := $(shell getconf LONG_BIT)
+ifeq ($(LBIT), 64)
+ LDFLAGS := -L/usr/lib64 -L/usr/lib64/mysql -lpthread -lmysqlclient
+else
+ LDFLAGS := -L/usr/lib -L/usr/lib/mysql -lpthread -lmysqlclient
+endif
# Ficheros objetos
OBJS := ../../Includes/Database.o sources/ogAdmRepo.o
diff --git a/admin/Sources/Services/ogAdmRepoAux b/admin/Sources/Services/ogAdmRepoAux
index 9dd4b0bb..21c0e4f1 100755
--- a/admin/Sources/Services/ogAdmRepoAux
+++ b/admin/Sources/Services/ogAdmRepoAux
@@ -11,11 +11,17 @@ PARM=`cat`
BASEDIR=/opt/opengnsys
+PATH=$PATH:$BASEDIR/bin
REPONAME=ogAdmRepo
REPOLOG=$BASEDIR/log/$REPONAME.log
MCASTLOGBASE=$BASEDIR/log/mcastlog
MCASTLOG=$MCASTLOGBASE/ogAdmRepoMcast.`date +%Y%m%d-%H%M%S`
+# Añade registro de incidencias.
+function echolog () {
+ date +"%Y%m%d-%H%M%S $*" >> $REPOLOG
+}
+
mkdir -p $MCASTLOGBASE
PARM1=$(echo $PARM | cut -f1 -d" ")
@@ -24,28 +30,26 @@ PARM3=$(echo $PARM | cut -f3 -d" ")
PARM4=$(echo $PARM | cut -f4 -d" ")
-case $PARM1 in
+case "$PARM1" in
START_MULTICAST)
#1 START_MULTICAST
#2 fichero a enviar
#3 opciones de multicast
- FILE=/opt/opengnsys/images$PARM2
- MCASTOPT=$PARM3
- echo `date +%Y%m%d-%H%M%S` "/opt/opengnsys/bin/sendFileMcast $FILE $MCASTOPT" >> $REPOLOG
- /opt/opengnsys/bin/sendFileMcast $FILE $MCASTOPT &>> $MCASTLOG
+ FILE="$PARM2"
+ MCASTOPT="$PARM3"
+ echolog "Ejecutar $(which sendFileMcast) $FILE $MCASTOPT"
+ sendFileMcast $FILE $MCASTOPT &>> $MCASTLOG
case $? in
- 1)
- echo `date +%Y%m%d-%H%M%S` Parametros insuficientes >> $REPOLOG
- ;;
- 2)
- echo `date +%Y%m%d-%H%M%S` Fichero no accesible >> $REPOLOG
- ;;
- 3)
- echo `date +%Y%m%d-%H%M%S` sesion multicast no valida >> $REPOLOG
- ;;
+ 1) echolog "Parametros insuficientes"
+ return 1 ;;
+ 2) echolog "Fichero no accesible"
+ return 2 ;;
+ 3) echolog "Sesion multicast no valida"
+ return 3 ;;
esac
;;
default)
- echo "Solicitud con parametros: - $PARM - no realizada: No registrada o con errores" >> $REPOLOG
+ echolog "Solicitud con parametros \"$PARM\" no realizada, no registrada o con errores"
;;
-esac \ No newline at end of file
+esac
+
diff --git a/admin/Sources/Services/ogAdmServer/Makefile b/admin/Sources/Services/ogAdmServer/Makefile
index ae5a5893..d2312ddf 100644
--- a/admin/Sources/Services/ogAdmServer/Makefile
+++ b/admin/Sources/Services/ogAdmServer/Makefile
@@ -8,11 +8,16 @@ INSTALL_DIR := /opt/opengnsys
# Opciones de compilacion
#CFLAGS := -O0 -g -Wall -I../../Includes # Depuracion
-CFLAGS := -O3 -Wall -I../../Includes # Optimizacion
+CFLAGS := -O3 -Wall -I../../Includes # Depuracion
CPPFLAGS := $(CFLAGS)
# Opciones de linkado
-LDFLAGS := -L/usr/lib -L/usr/lib/mysql -lpthread -lmysqlclient
+LBIT := $(shell getconf LONG_BIT)
+ifeq ($(LBIT), 64)
+ LDFLAGS := -L/usr/lib64 -L/usr/lib64/mysql -lpthread -lmysqlclient
+else
+ LDFLAGS := -L/usr/lib -L/usr/lib/mysql -lpthread -lmysqlclient
+endif
# Ficheros objetos
OBJS := ../../Includes/Database.o sources/ogAdmServer.o
diff --git a/admin/Sources/Services/opengnsys.init b/admin/Sources/Services/opengnsys.init
index a195301e..6dca623c 100755
--- a/admin/Sources/Services/opengnsys.init
+++ b/admin/Sources/Services/opengnsys.init
@@ -1,12 +1,4 @@
-#! /bin/sh
-
-##########1.0######################################################################################################
-####### Script de arranque de los servicios de OpenGnSys: Servidor ogAdmServer, Servidor de repositorio ogAdmRepo,
-####### Tracker Bittorrent y seeder de imagenes por Bittorrent
-####### autor: jcxifre <jcxifre@unizar.es>
-####### basado en http://www.epilogue.org/~xef4/start-stop-example
-##################################################################################################################
-
+#!/bin/bash
### BEGIN INIT INFO
# Provides: opengnsys
@@ -72,21 +64,41 @@ BTTRACKPID="/var/run/bttrack.pid"
BTSEEDERPID="/var/run/btseeder.pid"
-set -e
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/bin"
# Read config file if it is present.
if [ -r /etc/default/opengnsys ]
then
- . /etc/default/opengnsys
+ source /etc/default/opengnsys
fi
+# Configuración de arranque según la distribución Linux usada.
+config() {
+ OSDISTRIB=$(lsb_release -is 2>/dev/null)
+ case "$OSDISTRIB" in
+ Ubuntu)
+ INITFUNCTIONS=/lib/lsb/init-functions
+ DAEMONSTART="start-stop-daemon --start --quiet --background --exec"
+ EXTRAOPTS="--"
+ DAEMONSTOP="start-stop-daemon --stop --quiet --oknodo --exec"
+ ACTIONMSG="log_daemon_msg"
+ SUCCESSMSG="log_end_msg 0"
+ FAILMSG="log_end_msg 1"
+ ;;
+ *) echo "Distribución Linux desconcocida o no soportada."
+ exit ;;
+ esac
+ if [ -r $INITFUNCTIONS ]; then
+ source $INITFUNCTIONS
+ fi
+}
+
arranca_demonios() {
if [ $RUN_OGADMSERVER = "yes" ]
then
- echo -n "Iniciando demonio: "$SERVERNAME
- start-stop-daemon --start --quiet --background --exec $SERVERDAEMON -- $SERVERDAEMON_OPTIONS
- echo "."
+ $ACTIONMSG "Iniciando demonio: $SERVERNAME"
+ $DAEMONSTART $SERVERDAEMON $EXTRAOPTS $SERVERDAEMON_OPTIONS
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
fi
if [ $RUN_OGADMSERVER = "yes" ] && [ $RUN_OGADMREPO = "yes" ]
then
@@ -94,32 +106,32 @@ arranca_demonios() {
fi
if [ $RUN_OGADMREPO = "yes" ]
then
- echo -n "Iniciando demonio: "$REPONAME
- start-stop-daemon --start --quiet --background --exec $REPODAEMON -- $REPODAEMON_OPTIONS
- echo "."
+ $ACTIONMSG "Iniciando demonio: $REPONAME"
+ $DAEMONSTART $REPODAEMON $EXTRAOPTS $REPODAEMON_OPTIONS
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
############ ADV
- echo -n "Iniciando demonio: "$REPOAUXNAME
- faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
- echo "."
- ############ ADV
+ $ACTIONMSG "Iniciando demonio: $REPOAUXNAME"
+ faucet $REPOAUXPORT --daemon --in bash -c "$REPOAUXDAEMON"
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
+ ############ ADV
fi
if [ $RUN_OGADMAGENT = "yes" ]
then
- echo -n "Iniciando demonio: "$AGENTNAME $AGENTDAEMON
- start-stop-daemon --start --quiet --background --exec $AGENTDAEMON -- $AGENTDAEMON_OPTIONS
- echo "."
+ $ACTIONMSG "Iniciando demonio: $AGENTNAME"
+ $DAEMONSTART $AGENTDAEMON $EXTRAOPTS $AGENTDAEMON_OPTIONS
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
fi
if [ $RUN_BTTRACKER = "yes" ]
then
- echo -n "Iniciando demonio: "$BTTRACK
+ $ACTIONMSG "Iniciando demonio: $BTTRACK"
start-stop-daemon --make-pidfile --pidfile $BTTRACKPID --start --quiet --background --exec $BTTRACK -- $BTTRACK_OPTIONS
- echo "."
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
fi
if [ $RUN_BTSEEDER = "yes" ]
then
- echo -n "Iniciando demonio: "$BTSEEDER
+ $ACTIONMSG "Iniciando demonio: $BTSEEDER"
start-stop-daemon --make-pidfile --pidfile $BTSEEDERPID --start --quiet --background --exec $BTSEEDER -- $BTTORRENTSDIR
- echo "."
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
fi
}
@@ -127,33 +139,36 @@ arranca_demonios() {
para_demonios() {
if [ -e $BTSEEDERPID ]
then
- echo -n "Parando demonio: "$BTSEEDER
+ $ACTIONMSG "Parando demonio: $BTSEEDER"
start-stop-daemon --stop --quiet --oknodo --retry 30 --pidfile $BTSEEDERPID
- echo "."
- rm $BTSEEDERPID > /dev/null
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
+ rm -f $BTSEEDERPID
fi
if [ -e $BTTRACKPID ]
then
- echo -n "Parando demonio: "$BTTRACK
+ $ACTIONMSG "Parando demonio: $BTTRACK"
start-stop-daemon --stop --quiet --oknodo --pidfile $BTTRACKPID
- echo "."
- rm $BTTRACKPID > /dev/null
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
+ rm -f $BTTRACKPID
fi
- echo -n "Parando demonio: "$AGENTNAME
- start-stop-daemon --stop --quiet --oknodo --name $AGENTNAME
- echo "."
- echo -n "Parando demonio: "$REPONAME
- start-stop-daemon --stop --quiet --oknodo --name $REPONAME
- echo "."
+ $ACTIONMSG "Parando demonio: $AGENTNAME"
+ $DAEMONSTOP $AGENTDAEMON
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
+ $ACTIONMSG "Parando demonio: $REPONAME"
+ $DAEMONSTOP $REPODAEMON
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
############# ADV
- echo -n "Parando demonio: "$REPOAUXNAME
+ $ACTIONMSG "Parando demonio: $REPOAUXNAME"
pkill faucet
+ [ $? -le 1 ] && $SUCCESSMSG || $FAILMSG
############ ADV
- echo -n "Parando demonio: "$SERVERNAME
- start-stop-daemon --stop --quiet --oknodo --name $SERVERNAME
- echo "."
+ $ACTIONMSG "Parando demonio: $SERVERNAME"
+ $DAEMONSTOP $SERVERDAEMON
+ [ $? = 0 ] && $SUCCESSMSG || $FAILMSG
}
+config
+
case "$1" in
start)
arranca_demonios
@@ -167,9 +182,10 @@ case "$1" in
;;
*)
- echo "Uso: opengnsys "$1" {start|stop|restart}"
+ echo "Uso: $0 {start|stop|restart}"
exit 1
;;
esac
exit 0
+