diff --git a/README.md b/README.md index 0eb69d26e456706edca8c44716913a52d505f205..aebdb2f855a4996546f9324c15f142c8f03a5dc2 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Description This is an installer for Linux. -* It extracts the debian 64 package +* It extracts the debian 64 package from * Its files will be moved to /opt/snow/ and * the pre install and post install script will be executed. @@ -40,6 +40,15 @@ In the config.sh you can make your changes * Watch the PDF file and search for the correct sitename for your institution. * Set your sitename in the line `SITENAME="unibe..."` +## Get the DEB package + +Put the amd64 DEB package into ~/Downloads/. +In config.sh set + +```shell +DEBFILE=~/Downloads/04788015-Lin_C_V2-snowagent-7.0.1-x64.deb +``` + ## Install Start `./installer_samagent.sh` diff --git a/config.sh.dist b/config.sh.dist index 0363862c7513e4492fa1ec3d4c9c3aae2dfc6003..61c9df47c9c317eee07732fc1fd73505eae4a395 100644 --- a/config.sh.dist +++ b/config.sh.dist @@ -9,10 +9,13 @@ PLATFORM="amd64" # source file in download folder SOURCEZIP=~/Downloads/SAM\ Agent.zip +# or better: filename of deb file +DEBFILE=~/Downloads/04788015-Lin_C_V2-snowagent-7.0.1-x64.deb + # temp dir to extract package before installing EXTRACTDIR=/tmp/SAM_AGENT.tmp -# target dir +# target dir - a subdir "snow" will be created INSTALLDIR=/opt URLSITENAMNE=https://sam.intern.unibe.ch/e1498122/e1502084/SiteName_Uebersicht.pdf diff --git a/installer_samagent.sh b/installer_samagent.sh index de65b38ae57144bda4df5e2f15fe68789059098c..a2495a3def6a3021c28893ccecf4cb09c55c1e85 100755 --- a/installer_samagent.sh +++ b/installer_samagent.sh @@ -7,9 +7,10 @@ # # ---------------------------------------------------------------------- # 2024-04-19 v0.1 <axel.hahn@unibe.ch> +# 2024-05-22 v0.2 <axel.hahn@unibe.ch> handle deb file directly # ====================================================================== -_version="0.1" +_version="0.2" # ---------------------------------------------------------------------- # FUNCTIONS @@ -46,28 +47,34 @@ if [ -z "$SITENAME" ]; then exit 1 fi +if [ -z "$DEBFILE" ]; then + echo "Source file: $SOURCEZIP" + ls -l "$SOURCEZIP" || exit 1 -echo "Source file: $SOURCEZIP" -ls -l "$SOURCEZIP" || exit 1 + h2 "Detect DEB package for ${PLATFORM} from $SOURCEZIP ..." + DEBFILE=$( unzip -l "$SOURCEZIP" "SAM Agent/*${PLATFORM}.deb" | grep -v "/._" | grep "${PLATFORM}" | rev | cut -f 1,2 -d " " | rev ) + echo "Found debian file: $DEBFILE" -h2 "Detect DEB package for ${PLATFORM} from $SOURCEZIP ..." -DEBFILE=$( unzip -l "$SOURCEZIP" "SAM Agent/*${PLATFORM}.deb" | grep -v "/._" | grep "${PLATFORM}" | rev | cut -f 1,2 -d " " | rev ) -echo "Found debian file: $DEBFILE" -test -z "$DEBFILE" && echo "Debian Paket nicht gefunden. Paket korrupt oder Skript findet es nicht." -test -z "$DEBFILE" && exit 2 -echo "OK" -echo -test -d "$EXTRACTDIR" || mkdir "$EXTRACTDIR" -cd "$EXTRACTDIR" || exit 3 + test -z "$DEBFILE" && echo "Debian Paket nicht gefunden. Paket korrupt oder Skript findet es nicht." + test -z "$DEBFILE" && exit 2 + echo "OK" + echo + test -d "$EXTRACTDIR" || mkdir "$EXTRACTDIR" + cd "$EXTRACTDIR" || exit 3 -echo "Switched to workdir to extract data:" -pwd + echo "Switched to workdir to extract data:" + pwd -h2 "Extracting $DEBFILE from $SOURCEZIP ..." -unzip -o "$SOURCEZIP" -d . "$DEBFILE" || exit 4 -echo "Result:" + h2 "Extracting $DEBFILE from $SOURCEZIP ..." + unzip -o "$SOURCEZIP" -d . "$DEBFILE" || exit 4 + echo "Result:" +else + test -d "$EXTRACTDIR" || mkdir "$EXTRACTDIR" + cd "$EXTRACTDIR" || exit 3 +fi + ls -l "$DEBFILE" || exit 5 @@ -90,7 +97,7 @@ echo "Found subdir: opt/$subdirname" h2 "Get version ..." -PKGVERSION=$( grep "^Version: " "control" | cut -f 2- -d " " ) +PKGVERSION=$( grep "^Version: " "control" 2>/dev/null | cut -f 2- -d " " ) SWVERSION=$( grep "^Version: " "$INSTALLDIR/$subdirname/control" | cut -f 2- -d " " ) echo "To install: $PKGVERSION" echo "Installed : $SWVERSION" @@ -113,23 +120,26 @@ else h2 "Put files to opt ..." test -d "$INSTALLDIR/$subdirname" && ( echo "Removing $INSTALLDIR/$subdirname"; sudo rm -rf "$INSTALLDIR/$subdirname" ) - echo "Copy opt/$subdirname to $INSTALLDIR" + echo "Copy opt/$subdirname to $INSTALLDIR ..." sudo cp -r "opt/$subdirname" "$INSTALLDIR" || exit 6 sudo cp "control" "$INSTALLDIR/$subdirname" || exit 6 - + echo + echo "Result" + sudo find $INSTALLDIR/$subdirname h2 "Run debian scripts ..." for myscript in preinst postinst # prerm postrm do - echo "----- $myscript $PKGNAME" - sudo ./$myscript "$PKGNAME" || exit 7 + echo "----- Executing '$myscript $PKGNAME'" + sudo ./$myscript "$PKGNAME" || ( echo ; read -p "--> Exitcode was non zero. Press RETURN to continue or Ctrl+C to abort" ) + echo done fi h2 "Cleanup ..." echo "Deleting workdir $EXTRACTDIR ..." -# rm -rf "$EXTRACTDIR" +rm -rf "$EXTRACTDIR" echo echo "Done."