diff options
Diffstat (limited to 'installer/opengnsys_update.sh')
-rwxr-xr-x | installer/opengnsys_update.sh | 88 |
1 files changed, 58 insertions, 30 deletions
diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh index f0a6f32f..aa981c0a 100755 --- a/installer/opengnsys_update.sh +++ b/installer/opengnsys_update.sh @@ -55,8 +55,6 @@ fi # Cargar configuración de acceso a la base de datos. if [ -r $INSTALL_TARGET/etc/ogAdmServer.cfg ]; then source $INSTALL_TARGET/etc/ogAdmServer.cfg -elif [ -r $INSTALL_TARGET/etc/ogAdmAgent.cfg ]; then - source $INSTALL_TARGET/etc/ogAdmAgent.cfg fi OPENGNSYS_DATABASE=${OPENGNSYS_DATABASE:-"$CATALOG"} # Base de datos OPENGNSYS_DBUSER=${OPENGNSYS_DBUSER:-"$USUARIO"} # Usuario de acceso @@ -117,7 +115,7 @@ function autoConfigure() # Configuración según la distribución de Linux. if [ -f /etc/debian_version ]; then # Distribución basada en paquetes Deb. - DEPENDENCIES=( curl rsync btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast libev-dev libjansson-dev libssl-dev shim-signed grub-efi-amd64-signed php-fpm gawk libdbi-dev libdbi1 libdbd-mysql) + DEPENDENCIES=( curl rsync btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast libev-dev libjansson-dev libssl-dev shim-signed grub-efi-amd64-signed php-fpm gawk libdbi-dev libdbi1 libdbd-mysql automake) # Paquete correcto para realpath. [ -z "$(apt-cache pkgnames realpath)" ] && DEPENDENCIES=( ${DEPENDENCIES[@]//realpath/coreutils} ) UPDATEPKGLIST="add-apt-repository -y ppa:ondrej/php; apt-get update" @@ -144,7 +142,7 @@ function autoConfigure() INETDCFGDIR=/etc/xinetd.d elif [ -f /etc/redhat-release ]; then # Distribución basada en paquetes rpm. - DEPENDENCIES=( curl rsync btrfs-progs procps-ng arp-scan gettext moreutils jq net-tools udpcast libev-devel jansson-devel openssl-devel shim-x64 grub2-efi-x64 grub2-efi-x64-modules gawk libdbi-devel libdbi libdbi-dbd-mysql) + DEPENDENCIES=( curl rsync btrfs-progs procps-ng arp-scan gettext moreutils jq net-tools udpcast libev-devel jansson-devel openssl-devel shim-x64 grub2-efi-x64 grub2-efi-x64-modules gawk libdbi-devel libdbi libdbi-dbd-mysql automake) # Repositorios para PHP 7 en CentOS. [ "$OSDISTRIB" == "centos" ] && UPDATEPKGLIST="yum update -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-$OSVERSION.noarch.rpm http://rpms.remirepo.net/enterprise/remi-release-$OSVERSION.rpm" INSTALLPKGS="yum install -y" @@ -972,9 +970,27 @@ function updateServerFiles() if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys 2>/dev/null; then echoAndLog "${FUNCNAME}(): updating new init file" backupFile /etc/init.d/opengnsys + service="opengnsys" + $STOPSERVICE cp -a $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.init /etc/init.d/opengnsys + systemctl daemon-reload + $STARTSERVICE NEWFILES="$NEWFILES /etc/init.d/opengnsys" fi + if ! diff -q \ + $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.service \ + /lib/systemd/system/opengnsys.service 2>/dev/null; then + echoAndLog "${FUNCNAME}(): updating new service file" + backupFile /lib/systemd/system/opengnsys.service + service="opengnsys" + $STOPSERVICE + cp -a \ + $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.service \ + /lib/systemd/system/opengnsys.service + systemctl daemon-reload + $STARTSERVICE + NEWFILES="$NEWFILES /lib/systemd/system/opengnsys.service" + fi if ! diff -q $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default /etc/default/opengnsys >/dev/null; then echoAndLog "${FUNCNAME}(): updating new default file" backupFile /etc/default/opengnsys @@ -987,12 +1003,6 @@ function updateServerFiles() done < $WORKDIR/opengnsys/admin/Sources/Services/opengnsys.default NEWFILES="$NEWFILES /etc/default/opengnsys" fi - if egrep -q "(UrlMsg=.*msgbrowser.php)|(UrlMenu=http://)" $INSTALL_TARGET/client/etc/ogAdmClient.cfg 2>/dev/null; then - echoAndLog "${FUNCNAME}(): updating new client config file" - backupFile $INSTALL_TARGET/client/etc/ogAdmClient.cfg - perl -pi -e 's!UrlMsg=.*msgbrowser\.php!UrlMsg=http://localhost/cgi-bin/httpd-log\.sh!g; s!UrlMenu=http://!UrlMenu=https://!g' $INSTALL_TARGET/client/etc/ogAdmClient.cfg - NEWFILES="$NEWFILES $INSTALL_TARGET/client/etc/ogAdmClient.cfg" - fi echoAndLog "${FUNCNAME}(): updating cron files" [ ! -f /etc/cron.d/torrentcreator ] && echo "* * * * * root [ -x $INSTALL_TARGET/bin/torrent-creator ] && $INSTALL_TARGET/bin/torrent-creator" > /etc/cron.d/torrentcreator @@ -1029,11 +1039,13 @@ function moveNewService() # Comparar los ficheros. if ! diff -q $1 $2/$(basename $1) &>/dev/null; then # Parar los servicios si fuese necesario. - [ -z "$NEWSERVICES" ] && service="opengnsys" $STOPSERVICE + service="opengnsys" + [ -z "$NEWSERVICES" ] && $STOPSERVICE # Nuevo servicio. NEWSERVICES="$NEWSERVICES $(basename $1)" # Mover el nuevo fichero de servicio mv $1 $2 + $STARTSERVICE fi } @@ -1046,7 +1058,7 @@ function compileServices() # Compilar OpenGnsys Server echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Admin Server" pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmServer - make && moveNewService ogAdmServer $INSTALL_TARGET/sbin + autoreconf -fi && ./configure && make && moveNewService ogAdmServer $INSTALL_TARGET/sbin if [ $? -ne 0 ]; then echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Admin Server" hayErrores=1 @@ -1054,25 +1066,11 @@ function compileServices() popd # Parar antiguo servicio de repositorio. pgrep ogAdmRepo > /dev/null && service="ogAdmRepo" $STOPSERVICE - # Compilar OpenGnsys Agent - echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Server Agent" - pushd $WORKDIR/opengnsys/admin/Sources/Services/ogAdmAgent - make && moveNewService ogAdmAgent $INSTALL_TARGET/sbin - if [ $? -ne 0 ]; then - echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Server Agent" - hayErrores=1 - fi - popd + # Remove OpenGnsys Agent (ogAdmAgent) + echoAndLog "${FUNCNAME}(): deleting deprecated OpenGnsys Agent" + [ -e $INSTALL_TARGET/sbin/ogAdmAgent ] && \ + rm -f $INSTALL_TARGET/sbin/ogAdmAgent - # Compilar OpenGnsys Client - echoAndLog "${FUNCNAME}(): Recompiling OpenGnsys Client" - pushd $WORKDIR/opengnsys/admin/Sources/Clients/ogAdmClient - make && mv ogAdmClient $INSTALL_TARGET/client/bin - if [ $? -ne 0 ]; then - echoAndLog "${FUNCNAME}(): error while compiling OpenGnsys Client" - hayErrores=1 - fi - popd # Generar un API token de ogAdmServer si no existe en el fichero de configuración. grep -q "APITOKEN=" $INSTALL_TARGET/etc/ogAdmServer.cfg || \ $INSTALL_TARGET/bin/settoken -f @@ -1138,6 +1136,30 @@ function updateClient() fi } +# Update ogClient +function updateOgClient() +{ + local ogclientUrl="https://codeload.github.com/opengnsys/ogClient/zip/$BRANCH" + + echoAndLog "${FUNCNAME}(): downloading ogClient code..." + + if ! (curl "${ogclientUrl}" -o ogclient.zip && \ + unzip -qo ogclient.zip) + then + errorAndLog "${FUNCNAME}(): "\ + "error getting ogClient code from ${ogclientUrl}" + return 1 + fi + if [ -e $INSTALL_TARGET/client/ogClient/cfg/ogclient.json ]; then + rm -f ogClient-"$BRANCH"/cfg/ogclient.json + fi + mv -f "ogClient-$BRANCH" $INSTALL_TARGET/client/ogClient + rm -f ogclient.zip + echoAndLog "${FUNCNAME}(): ogClient code was downloaded and updated" + + return 0 +} + # Comprobar permisos y ficheros. function checkFiles() { @@ -1330,6 +1352,12 @@ if [ $? -ne 0 ]; then exit 1 fi +# Update ogClient +if ! updateOgClient; then + errorAndLog "Error updating ogClient files" + exit 1 +fi + # Comprobar permisos y ficheros. checkFiles |