Skip to content
Snippets Groups Projects
Commit b86ace69 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

v0.2 - handle a deb file directly

parent f7a749bc
No related branches found
No related tags found
No related merge requests found
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## Description ## Description
This is an installer for Linux. 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 * Its files will be moved to /opt/snow/ and
* the pre install and post install script will be executed. * the pre install and post install script will be executed.
...@@ -40,6 +40,15 @@ In the config.sh you can make your changes ...@@ -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. * Watch the PDF file and search for the correct sitename for your institution.
* Set your sitename in the line `SITENAME="unibe..."` * 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 ## Install
Start `./installer_samagent.sh` Start `./installer_samagent.sh`
...@@ -9,10 +9,13 @@ PLATFORM="amd64" ...@@ -9,10 +9,13 @@ PLATFORM="amd64"
# source file in download folder # source file in download folder
SOURCEZIP=~/Downloads/SAM\ Agent.zip 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 # temp dir to extract package before installing
EXTRACTDIR=/tmp/SAM_AGENT.tmp EXTRACTDIR=/tmp/SAM_AGENT.tmp
# target dir # target dir - a subdir "snow" will be created
INSTALLDIR=/opt INSTALLDIR=/opt
URLSITENAMNE=https://sam.intern.unibe.ch/e1498122/e1502084/SiteName_Uebersicht.pdf URLSITENAMNE=https://sam.intern.unibe.ch/e1498122/e1502084/SiteName_Uebersicht.pdf
......
...@@ -7,9 +7,10 @@ ...@@ -7,9 +7,10 @@
# #
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# 2024-04-19 v0.1 <axel.hahn@unibe.ch> # 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 # FUNCTIONS
...@@ -46,7 +47,7 @@ if [ -z "$SITENAME" ]; then ...@@ -46,7 +47,7 @@ if [ -z "$SITENAME" ]; then
exit 1 exit 1
fi fi
if [ -z "$DEBFILE" ]; then
echo "Source file: $SOURCEZIP" echo "Source file: $SOURCEZIP"
ls -l "$SOURCEZIP" || exit 1 ls -l "$SOURCEZIP" || exit 1
...@@ -54,6 +55,7 @@ h2 "Detect DEB package for ${PLATFORM} from $SOURCEZIP ..." ...@@ -54,6 +55,7 @@ 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 ) DEBFILE=$( unzip -l "$SOURCEZIP" "SAM Agent/*${PLATFORM}.deb" | grep -v "/._" | grep "${PLATFORM}" | rev | cut -f 1,2 -d " " | rev )
echo "Found debian file: $DEBFILE" echo "Found debian file: $DEBFILE"
test -z "$DEBFILE" && echo "Debian Paket nicht gefunden. Paket korrupt oder Skript findet es nicht." test -z "$DEBFILE" && echo "Debian Paket nicht gefunden. Paket korrupt oder Skript findet es nicht."
test -z "$DEBFILE" && exit 2 test -z "$DEBFILE" && exit 2
echo "OK" echo "OK"
...@@ -68,6 +70,11 @@ pwd ...@@ -68,6 +70,11 @@ pwd
h2 "Extracting $DEBFILE from $SOURCEZIP ..." h2 "Extracting $DEBFILE from $SOURCEZIP ..."
unzip -o "$SOURCEZIP" -d . "$DEBFILE" || exit 4 unzip -o "$SOURCEZIP" -d . "$DEBFILE" || exit 4
echo "Result:" echo "Result:"
else
test -d "$EXTRACTDIR" || mkdir "$EXTRACTDIR"
cd "$EXTRACTDIR" || exit 3
fi
ls -l "$DEBFILE" || exit 5 ls -l "$DEBFILE" || exit 5
...@@ -90,7 +97,7 @@ echo "Found subdir: opt/$subdirname" ...@@ -90,7 +97,7 @@ echo "Found subdir: opt/$subdirname"
h2 "Get version ..." 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 " " ) SWVERSION=$( grep "^Version: " "$INSTALLDIR/$subdirname/control" | cut -f 2- -d " " )
echo "To install: $PKGVERSION" echo "To install: $PKGVERSION"
echo "Installed : $SWVERSION" echo "Installed : $SWVERSION"
...@@ -113,23 +120,26 @@ else ...@@ -113,23 +120,26 @@ else
h2 "Put files to opt ..." h2 "Put files to opt ..."
test -d "$INSTALLDIR/$subdirname" && ( echo "Removing $INSTALLDIR/$subdirname"; sudo rm -rf "$INSTALLDIR/$subdirname" ) 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 -r "opt/$subdirname" "$INSTALLDIR" || exit 6
sudo cp "control" "$INSTALLDIR/$subdirname" || exit 6 sudo cp "control" "$INSTALLDIR/$subdirname" || exit 6
echo
echo "Result"
sudo find $INSTALLDIR/$subdirname
h2 "Run debian scripts ..." h2 "Run debian scripts ..."
for myscript in preinst postinst # prerm postrm for myscript in preinst postinst # prerm postrm
do do
echo "----- $myscript $PKGNAME" echo "----- Executing '$myscript $PKGNAME'"
sudo ./$myscript "$PKGNAME" || exit 7 sudo ./$myscript "$PKGNAME" || ( echo ; read -p "--> Exitcode was non zero. Press RETURN to continue or Ctrl+C to abort" )
echo
done done
fi fi
h2 "Cleanup ..." h2 "Cleanup ..."
echo "Deleting workdir $EXTRACTDIR ..." echo "Deleting workdir $EXTRACTDIR ..."
# rm -rf "$EXTRACTDIR" rm -rf "$EXTRACTDIR"
echo echo
echo "Done." echo "Done."
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment