From a30baf2bb7e15b5c9cb905399c050a7b6c8ff044 Mon Sep 17 00:00:00 2001 From: ramon Date: Tue, 27 Jun 2017 12:13:54 +0000 Subject: #768: Script {{{setsmbpass}}} puede modificar uno o todos los ogLive instalados; script {{{oglivecli}}} usa comando {{{curl}}} en vez de {{{wget}}}. git-svn-id: https://opengnsys.es/svn/branches/version1.1@5386 a21b9725-9963-47de-94b9-378ad31fedc9 --- server/bin/oglivecli | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'server/bin/oglivecli') diff --git a/server/bin/oglivecli b/server/bin/oglivecli index 3feb5901..8ada7f08 100755 --- a/server/bin/oglivecli +++ b/server/bin/oglivecli @@ -13,6 +13,16 @@ #*/ ## +# Global constants definition. +PROG=$(basename "$(realpath "$0")") +OPENGNSYS=/opt/opengnsys +DOWNLOADDIR=$OPENGNSYS/lib +DOWNLOADURL="http://opengnsys.es/downloads" +TFTPDIR=$OPENGNSYS/tftpboot +DEFOGLIVE="ogLive" +INFOFILE=$OPENGNSYS/etc/ogliveinfo.json + + # Auxiliar functions. # Metafunction to check if JSON result exists. @@ -247,7 +257,7 @@ function download() { OGLIVEFILE="$1" else # Show download menu. - OGLIVE=( $(wget $DOWNLOADURL -O - 2>/dev/null | grep $DEFOGLIVE.*iso) ) + OGLIVE=( $(curl --silent $DOWNLOADURL | grep "$DEFOGLIVE.*iso") ) NISOS=${#OGLIVE[@]} echo "Available downloads (+ = installed, * = full compatibility):" for i in $(seq 1 $NISOS); do @@ -260,12 +270,12 @@ function download() { done fi # Get download size. - SOURCELENGTH=$(LANG=C wget --spider $DOWNLOADURL/$OGLIVEFILE 2>&1 | awk '/Length:/ {print $2}') + SOURCELENGTH=$(curl --head --silent $DOWNLOADURL/$OGLIVEFILE | awk -F: '/Content-Length:/ {print $2}') [ -n "$SOURCELENGTH" ] || raiseError download "$OGLIVEFILE" # Download ogLive. TARGETFILE=$DOWNLOADDIR/$OGLIVEFILE trap "rm -f $TARGETFILE" 1 2 3 6 9 15 - wget $DOWNLOADURL/$OGLIVEFILE -O $TARGETFILE || raiseError download "$OGLIVEFILE" + curl $DOWNLOADURL/$OGLIVEFILE -o $TARGETFILE || raiseError download "$OGLIVEFILE" } # Install an ogLive client from a previously downloaded ISO image. @@ -279,15 +289,15 @@ function install() { [ ! -w $(dirname $INFOFILE) ] && raiseError access "Configuration directory." [ ! -w $TFTPDIR ] && raiseError access "Installation directory." [ -z "$(file -b $OGLIVEFILE | grep "ISO.*ogClient")" ] && raiseError access "File is not an ogLive ISO image." - # Working directory (ogLive-Distribution-KernelVersion-CodeRevision). + # Working directory (ogLive-Distribution-KernelVersion-Architecture-CodeRevision). OGLIVEDIST="$(echo $OGLIVEFILE|cut -f2 -d-)" OGLIVEREV="${OGLIVEFILE##*-}"; OGLIVEREV="${OGLIVEREV%.*}" OGLIVEKRNL="$(echo $OGLIVEFILE|cut -f3- -d-)"; OGLIVEKRNL="${OGLIVEKRNL%-$OGLIVEREV.*}" OGLIVEARCH="$(echo $OGLIVEFILE|awk -F- '{print $(NF-1)}')" case "$OGLIVEARCH" in - i386|amd64) + i386|amd64) # Get architecture. OGLIVEKRNL="${OGLIVEKRNL%-$OGLIVEARCH}" ;; - *) + *) # 32-bit by default. OGLIVEARCH="i386" ;; esac OGLIVEDIR="$TFTPDIR/$DEFOGLIVE-$OGLIVEDIST-${OGLIVEKRNL%%-*}-$OGLIVEARCH-$OGLIVEREV" @@ -318,9 +328,9 @@ function install() { fi # Recover or ask for a new Samba access key. if [ -n "$SAMBAPASS" ]; then - echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | $OPENGNSYS/bin/setsmbpass + echo -ne "$SAMBAPASS\n$SAMBAPASS\n" | $OPENGNSYS/bin/setsmbpass "$(basename $OGLIVEDIR)" else - $OPENGNSYS/bin/setsmbpass + $OPENGNSYS/bin/setsmbpass "$(basename $OGLIVEDIR)" fi # Set permissions. find -L $OGLIVEDIR -type d -exec chmod 755 {} \; @@ -376,7 +386,7 @@ function uninstall() { if [ -n "$INDEX" ]; then jq "del(.oglive[$INDEX])" $INFOFILE | sponge $INFOFILE # Decrement default index if needed (removed < default). - [[ $INDEX < $DEFINDEX ]] && jq ".default=$[DEFINDEX-1]" $INFOFILE | sponge $INFOFILE + [[ $INDEX < $DEFINDEX ]] && jq ".default=$((DEFINDEX-1))" $INFOFILE | sponge $INFOFILE fi } @@ -442,15 +452,6 @@ local ISOFILE DIR # Main progrram. -# Global constants definition. -PROG=$(basename $(realpath "$0")) -OPENGNSYS=/opt/opengnsys -DOWNLOADDIR=$OPENGNSYS/lib -DOWNLOADURL="http://opengnsys.es/downloads" -TFTPDIR=$OPENGNSYS/tftpboot -DEFOGLIVE=ogLive -INFOFILE=$OPENGNSYS/etc/ogliveinfo.json - # Access control. [ -r $OPENGNSYS/www/controlacceso.php ] && ACCESS="web" [ "$USER" = "root" ] && ACCESS="root" -- cgit v1.2.3-18-g5258