summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRamón M. Gómez <ramongomez@us.es>2018-05-24 20:24:56 +0200
committerRamón M. Gómez <ramongomez@us.es>2018-05-24 20:24:56 +0200
commit884b6ce68e87a1693df1f150e4a4704d6aa833c2 (patch)
tree8f201d50132f4d05636f5191a949646154e07eb8
parent9199fc761629d6ab0f117415f1052ba160ec0297 (diff)
#840: Usar repositorio de GitHub en instalación y actualización.
-rwxr-xr-xinstaller/opengnsys_installer.sh39
-rwxr-xr-xinstaller/opengnsys_update.sh71
2 files changed, 61 insertions, 49 deletions
diff --git a/installer/opengnsys_installer.sh b/installer/opengnsys_installer.sh
index 76563275..6fe905dc 100755
--- a/installer/opengnsys_installer.sh
+++ b/installer/opengnsys_installer.sh
@@ -95,17 +95,19 @@ done
echo -e "\\n=============================="
-# Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1).
+# Comprobar si se ha descargado el paquete comprimido (REMOTE=0) o sólo el instalador (REMOTE=1).
PROGRAMDIR=$(readlink -e "$(dirname "$0")")
PROGRAMNAME=$(basename "$0")
OPENGNSYS_SERVER="opengnsys.es"
DOWNLOADURL="https://$OPENGNSYS_SERVER/trac/downloads"
if [ -d "$PROGRAMDIR/../installer" ]; then
- USESVN=0
+ REMOTE=0
else
- USESVN=1
+ REMOTE=1
fi
-SVN_URL="https://$OPENGNSYS_SERVER/svn/branches/version1.1/"
+BRANCH="devel"
+CODE_URL="https://codeload.github.com/opengnsys/OpenGnsys/zip/$BRANCH"
+API_URL="https://api.github.com/repos/opengnsys/OpenGnsys/branches/$BRANCH"
WORKDIR=/tmp/opengnsys_installer
mkdir -p $WORKDIR
@@ -167,7 +169,7 @@ OSVERSION="${OSVERSION%%.*}"
# Configuración según la distribución GNU/Linux (usar minúsculas).
case "$OSDISTRIB" in
ubuntu|debian|linuxmint)
- DEPENDENCIES=( subversion apache2 php php-ldap libapache2-mod-php mysql-server php-mysql isc-dhcp-server bittorrent tftp-hpa tftpd-hpa xinetd build-essential g++-multilib libmysqlclient-dev wget curl doxygen graphviz bittornado ctorrent samba rsync unzip netpipes debootstrap schroot squashfs-tools btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast shim-signed grub-efi-amd64-signed )
+ DEPENDENCIES=( apache2 php php-ldap libapache2-mod-php mysql-server php-mysql isc-dhcp-server bittorrent tftp-hpa tftpd-hpa xinetd build-essential g++-multilib libmysqlclient-dev wget curl doxygen graphviz bittornado ctorrent samba rsync unzip netpipes debootstrap schroot squashfs-tools btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast shim-signed grub-efi-amd64-signed )
UPDATEPKGLIST="apt-get update"
INSTALLPKG="apt-get -y install --force-yes"
CHECKPKG="dpkg -s \$package 2>/dev/null | grep Status | grep -qw install"
@@ -204,7 +206,7 @@ case "$OSDISTRIB" in
TFTPCFGDIR=/var/lib/tftpboot
;;
fedora|centos)
- DEPENDENCIES=( subversion httpd mod_ssl php php-ldap mysql-server mysql-devel mysql-devel.i686 php-mysql dhcp tftp-server tftp xinetd binutils gcc gcc-c++ glibc-devel glibc-devel.i686 glibc-static glibc-static.i686 libstdc++-devel.i686 make wget curl doxygen graphviz ctorrent samba samba-client rsync unzip debootstrap schroot squashfs-tools python-crypto arp-scan procps-ng gettext moreutils jq net-tools http://ftp.altlinux.org/pub/distributions/ALTLinux/5.1/branch/$(arch)/RPMS.classic/netpipes-4.2-alt1.$(arch).rpm )
+ DEPENDENCIES=( httpd mod_ssl php php-ldap mysql-server mysql-devel mysql-devel.i686 php-mysql dhcp tftp-server tftp xinetd binutils gcc gcc-c++ glibc-devel glibc-devel.i686 glibc-static glibc-static.i686 libstdc++-devel.i686 make wget curl doxygen graphviz ctorrent samba samba-client rsync unzip debootstrap schroot squashfs-tools python-crypto arp-scan procps-ng gettext moreutils jq net-tools http://ftp.altlinux.org/pub/distributions/ALTLinux/5.1/branch/$(arch)/RPMS.classic/netpipes-4.2-alt1.$(arch).rpm )
INSTALLEXTRADEPS=( 'pushd /tmp; wget -t3 http://download.bittornado.com/download/BitTornado-0.3.18.tar.gz && tar xvzf BitTornado-0.3.18.tar.gz && cd BitTornado-CVS && python setup.py install && ln -fs btlaunchmany.py /usr/bin/btlaunchmany && ln -fs bttrack.py /usr/bin/bttrack; popd' )
INSTALLPKG="yum install -y libstdc++ libstdc++.i686"
CHECKPKG="rpm -q --quiet \$package"
@@ -786,11 +788,11 @@ EOF
#####################################################################
-####### Funciones para el manejo de Subversion
+####### Funciones para la descarga de código
#####################################################################
-# Obtiene el código fuente del proyecto desde el servidor SVN.
-function svnExportCode()
+# Obtiene el código fuente del proyecto desde el repositorio de GitHub.
+function downloadCode()
{
if [ $# -ne 1 ]; then
errorAndLog "${FUNCNAME}(): invalid number of parameters"
@@ -799,14 +801,15 @@ function svnExportCode()
local url="$1"
- echoAndLog "${FUNCNAME}(): downloading subversion code..."
+ echoAndLog "${FUNCNAME}(): downloading code..."
- svn export --force "$url" opengnsys
+ curl "${url}" -o opengnsys.zip && unzip opengnsys.zip && mv "OpenGnsys-$BRANCH" opengnsys
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error getting OpenGnsys code from $url"
return 1
fi
- echoAndLog "${FUNCNAME}(): subversion code downloaded"
+ rm -f opengnsys.zip
+ echoAndLog "${FUNCNAME}(): code was downloaded"
return 0
}
@@ -1073,7 +1076,6 @@ function installWebFiles()
errorAndLog "${FUNCNAME}(): Error copying web files."
exit 1
fi
- find $INSTALL_TARGET/www -name .svn -type d -exec rm -fr {} \; 2>/dev/null
# Descomprimir librerías: Slim y Swagger-UI.
unzip -o $WORKDIR/opengnsys/admin/$SLIMFILE -d $INSTALL_TARGET/www/rest
@@ -1397,7 +1399,6 @@ function copyClientFiles()
errorAndLog "${FUNCNAME}(): error while copying client estructure"
errstatus=1
fi
- find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
echoAndLog "${FUNCNAME}(): Copying OpenGnsys Cloning Engine files."
mkdir -p $INSTALL_TARGET/client/lib/engine/bin
@@ -1557,8 +1558,8 @@ function installationSummary()
[ -f $VERSIONFILE ] || echo "OpenGnsys Server" >$VERSIONFILE
# Incluir datos de revisión, si se está instaladno desde el repositorio
# de código o si no está incluida en el fichero de versión.
- if [ $USESVN -eq 1 ] || [ -z "$(awk '$3~/r[0-9]*/ {print}' $VERSIONFILE)" ]; then
- local REVISION=$(LANG=C svn info $SVN_URL|awk '/Rev:/ {print "r"$4}')
+ if [ $REMOTE -eq 1 ] || [ -z "$(awk '$3~/r[0-9]*/ {print}' $VERSIONFILE)" ]; then
+ local REVISION=$(curl -s "$API_URL" | jq -r ".commit.commit.committer.date" | awk '{gsub(/[^0-9]/,""); print}')
sed -ri "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE
fi
@@ -1656,10 +1657,10 @@ if [ $? -ne 0 ]; then
fi
# Si es necesario, descarga el repositorio de código en directorio temporal
-if [ $USESVN -eq 1 ]; then
- svnExportCode $SVN_URL
+if [ $REMOTE -eq 1 ]; then
+ downloadCode $CODE_URL
if [ $? -ne 0 ]; then
- errorAndLog "Error while getting code from svn"
+ errorAndLog "Error while getting code from the repository"
exit 1
fi
else
diff --git a/installer/opengnsys_update.sh b/installer/opengnsys_update.sh
index 212501db..63512336 100755
--- a/installer/opengnsys_update.sh
+++ b/installer/opengnsys_update.sh
@@ -64,16 +64,19 @@ if [ -z "$OPENGNSYS_DATABASE" -o -z "$OPENGNSYS_DBUSER" -o -z "$OPENGNSYS_DBPASS
exit 1
fi
-# Comprobar si se ha descargado el paquete comprimido (USESVN=0) o sólo el instalador (USESVN=1).
+# Comprobar si se ha descargado el paquete comprimido (REMOTE=0) o sólo el instalador (REMOTE=1).
PROGRAMDIR=$(readlink -e $(dirname "$0"))
PROGRAMNAME=$(basename "$0")
OPENGNSYS_SERVER="opengnsys.es"
if [ -d "$PROGRAMDIR/../installer" ]; then
- USESVN=0
+ REMOTE=0
else
- USESVN=1
+ REMOTE=1
fi
-SVN_URL="https://$OPENGNSYS_SERVER/svn/branches/version1.1/"
+BRANCH="devel"
+CODE_URL="https://codeload.github.com/opengnsys/OpenGnsys/zip/$BRANCH"
+API_URL="https://api.github.com/repos/opengnsys/OpenGnsys/branches/$BRANCH"
+RAW_URL="https://raw.githubusercontent.com/opengnsys/OpenGnsys/$BRANCH"
WORKDIR=/tmp/opengnsys_update
mkdir -p $WORKDIR
@@ -113,7 +116,7 @@ function autoConfigure()
# Configuración según la distribución de Linux.
if [ -f /etc/debian_version ]; then
- # Distribución basada en paquetes Deb.
+ # Distribución basada en paquetes Deb.
DEPENDENCIES=( curl rsync btrfs-tools procps arp-scan realpath php-curl gettext moreutils jq wakeonlan udpcast )
UPDATEPKGLIST="add-apt-repository -y ppa:ondrej/php; apt-get update"
INSTALLPKGS="apt-get -y install"
@@ -133,7 +136,7 @@ function autoConfigure()
APACHEGROUP="www-data"
INETDCFGDIR=/etc/xinetd.d
elif [ -f /etc/redhat-release ]; then
- # Distribución basada en paquetes rpm.
+ # Distribución basada en paquetes rpm.
DEPENDENCIES=( curl rsync btrfs-progs procps-ng arp-scan gettext moreutils jq net-tools )
# En CentOS 7 instalar arp-scan de CentOS 6.
[ "$OSDISTRIB$OSVERSION" == "centos7" ] && DEPENDENCIES=( ${DEPENDENCIES[*]/arp-scan/http://dag.wieers.com/redhat/el6/en/$(arch)/dag/RPMS/arp-scan-1.9-1.el6.rf.$(arch).rpm} )
@@ -174,8 +177,8 @@ function checkAutoUpdate()
local update=0
# Actaulizar el script si ha cambiado o no existe el original.
- if [ $USESVN -eq 1 ]; then
- svn export $SVN_URL/installer/$PROGRAMNAME
+ if [ $REMOTE -eq 1 ]; then
+ curl -s $RAW_URL/installer/$PROGRAMNAME -o $PROGRAMNAME
if ! diff -q $PROGRAMNAME $INSTALL_TARGET/lib/$PROGRAMNAME 2>/dev/null || ! test -f $INSTALL_TARGET/lib/$PROGRAMNAME; then
mv $PROGRAMNAME $INSTALL_TARGET/lib
update=1
@@ -394,10 +397,10 @@ function installDependencies()
#####################################################################
-####### Funciones para el manejo de Subversion
+####### Funciones para descargar código
#####################################################################
-function svnExportCode()
+function downloadCode()
{
if [ $# -ne 1 ]; then
errorAndLog "${FUNCNAME}(): invalid number of parameters"
@@ -406,14 +409,15 @@ function svnExportCode()
local url="$1"
- echoAndLog "${FUNCNAME}(): downloading subversion code..."
+ echoAndLog "${FUNCNAME}(): downloading code..."
- svn checkout "${url}" opengnsys
+ curl "${url}" -o opengnsys.zip && unzip opengnsys.zip && mv "OpenGnsys-$BRANCH" opengnsys
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error getting code from ${url}, verify your user and password"
return 1
fi
- echoAndLog "${FUNCNAME}(): subversion code downloaded"
+ rm -f opengnsys.zip
+ echoAndLog "${FUNCNAME}(): code was downloaded"
return 0
}
@@ -426,7 +430,14 @@ function svnExportCode()
function checkNetworkConnection()
{
OPENGNSYS_SERVER=${OPENGNSYS_SERVER:-"opengnsys.es"}
- wget --spider -q $OPENGNSYS_SERVER
+ if which curl &>/dev/null; then
+ curl --connect-timeout 10 -s $OPENGNSYS_SERVER -o /dev/null
+ elif which wget &>/dev/null; then
+ wget --spider -q $OPENGNSYS_SERVER
+ else
+ echoAndLog "${FUNCNAME}(): Cannot execute \"wget\" nor \"curl\"."
+ return 1
+ fi
}
# Comprobar si la versión es anterior a la actual.
@@ -436,8 +447,8 @@ function checkVersion()
# Obtener versión actual y versión a actualizar.
OLDVERSION=$(awk '{print $2}' $INSTALL_TARGET/doc/VERSION.txt 2>/dev/null)
- if [ $USESVN -eq 1 ]; then
- NEWVERSION=$(curl -s $SVN_URL/doc/VERSION.txt 2>/dev/null | awk '{print $2}')
+ if [ $REMOTE -eq 1 ]; then
+ NEWVERSION=$(curl -s $RAW_URL/doc/VERSION.txt 2>/dev/null | awk '{print $2}')
else
NEWVERSION=$(awk '{print $2}' $PROGRAMDIR/doc/VERSION.txt 2>/dev/null)
fi
@@ -480,16 +491,15 @@ function updateClientFiles()
# Actualizar ficheros del cliente.
backupFile $ENGINECFG
echoAndLog "${FUNCNAME}(): Updating OpenGnsys Client files"
- rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
+ rsync -irplt $WORKDIR/opengnsys/client/shared/* $INSTALL_TARGET/client
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error while updating client structure"
exit 1
fi
- find $INSTALL_TARGET/client -name .svn -type d -exec rm -fr {} \; 2>/dev/null
# Actualizar librerías del motor de clonación.
echoAndLog "${FUNCNAME}(): Updating OpenGnsys Cloning Engine files"
- rsync --exclude .svn -irplt $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
+ rsync -irplt $WORKDIR/opengnsys/client/engine/*.lib* $INSTALL_TARGET/client/lib/engine/bin
if [ $? -ne 0 ]; then
errorAndLog "${FUNCNAME}(): error while updating engine files"
exit 1
@@ -604,7 +614,7 @@ function updateWebFiles()
# Copiar los ficheros nuevos conservando el archivo de configuración de acceso.
backupFile $INSTALL_TARGET/www/controlacceso.php
mv $INSTALL_TARGET/www $INSTALL_TARGET/WebConsole
- rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET
+ rsync -irplt $WORKDIR/opengnsys/admin/WebConsole $INSTALL_TARGET
ERRCODE=$?
mv $INSTALL_TARGET/WebConsole $INSTALL_TARGET/www
rm -fr $INSTALL_TARGET/www/xajax
@@ -649,7 +659,7 @@ function updateDownloadableFiles()
mv $PROGRAMDIR/$FILENAME $TARGETFILE
else
echoAndLog "${FUNCNAME}(): Downloading $FILENAME"
- wget $DOWNLOADURL/$FILENAME -O $TARGETFILE
+ curl $DOWNLOADURL/$FILENAME -o $TARGETFILE
fi
if [ ! -s $TARGETFILE ]; then
errorAndLog "${FUNCNAME}(): Cannot download $FILENAME"
@@ -660,7 +670,7 @@ function updateDownloadableFiles()
tar xvzf $TARGETFILE -C $INSTALL_TARGET/www/descargas
if [ $? != 0 ]; then
errorAndLog "${FUNCNAME}(): Error uncompressing archive $FILENAME"
- exit 1
+ return 1
fi
}
@@ -672,7 +682,7 @@ function updateInterfaceAdm()
# Crear carpeta y copiar Interface
echoAndLog "${FUNCNAME}(): Copying Administration Interface Folder"
mv $INSTALL_TARGET/client/interfaceAdm $INSTALL_TARGET/client/Interface
- rsync --exclude .svn -irplt $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client
+ rsync -irplt $WORKDIR/opengnsys/admin/Interface $INSTALL_TARGET/client
errcoce=$?
mv $INSTALL_TARGET/client/Interface $INSTALL_TARGET/client/interfaceAdm
if [ $errcode -ne 0 ]; then
@@ -829,7 +839,7 @@ function updateServerFiles()
local i
for (( i = 0; i < ${#SOURCES[@]}; i++ )); do
if [ -d "$INSTALL_TARGET/${TARGETS[i]}" ]; then
- rsync --exclude .svn -irplt "${SOURCES[i]}" $(dirname $(readlink -e "$INSTALL_TARGET/${TARGETS[i]}"))
+ rsync -irplt "${SOURCES[i]}" $(dirname $(readlink -e "$INSTALL_TARGET/${TARGETS[i]}"))
else
rsync -irplt "${SOURCES[i]}" $(readlink -m "$INSTALL_TARGET/${TARGETS[i]}")
fi
@@ -962,7 +972,7 @@ function updateClient()
oglivecli convert
fi
# Comprobar si debe actualizarse el cliente.
- SOURCELENGTH=$(LANG=C wget --spider $SOURCEFILE 2>&1 | awk '/Length:/ {print $2}')
+ SOURCELENGTH=$(curl -sI $SOURCEFILE 2>&1 | awk '/Content-Length:/ {print $2}')
TARGETLENGTH=$(stat -c "%s" $TARGETFILE 2>/dev/null)
[ -z $TARGETLENGTH ] && TARGETLENGTH=0
if [ "$SOURCELENGTH" != "$TARGETLENGTH" ]; then
@@ -1017,8 +1027,9 @@ function checkFiles()
function updateSummary()
{
# Actualizar fichero de versión y revisión.
- local VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt"
- local REVISION=$(LANG=C svn info $SVN_URL|awk '/Rev:/ {print "r"$4}')
+ local VERSIONFILE REVISION
+ VERSIONFILE="$INSTALL_TARGET/doc/VERSION.txt"
+ REVISION=$(curl -s "$API_URL" | jq -r ".commit.commit.committer.date" | awk '{gsub(/[^0-9]/,""); print}')
[ -f $VERSIONFILE ] || echo "OpenGnsys" >$VERSIONFILE
perl -pi -e "s/($| r[0-9]*)/ $REVISION/" $VERSIONFILE
@@ -1112,10 +1123,10 @@ if [ $? -ne 0 ]; then
fi
# Si es necesario, descarga el repositorio de código en directorio temporal
-if [ $USESVN -eq 1 ]; then
- svnExportCode $SVN_URL
+if [ $REMOTE -eq 1 ]; then
+ downloadCode $CODE_URL
if [ $? -ne 0 ]; then
- errorAndLog "Error while getting code from svn server"
+ errorAndLog "Error while getting code from repository"
exit 1
fi
else