update360TotalSecurity

By Thomas_H 2021/02/14

#!/bin/bash
#
##############################################################################
# first we declare some variables. A good programmer is a lazy programmer :)
##############################################################################
opsiproduct_path="/home/opsiproducts"
product="360TotalSecurity"
setupname="360TS_Setup.exe"
geturl="https://www.360totalsecurity.com/en/download-free-antivirus/360-total-security/?offline=1"
# Attention! following grepvar-string is a regular expression!! Leave the [^"]* at the end!!
grepvar='free\.360totalsecurity\.com/totalsecurity/360TS_Setup_.*\.exe[^"]*'
# Where is the first digit of the version-number?
startpos=53
##############################################################################
#
#
# first, let's remove the last valid exe-file
rm $opsiproduct_path/$product/CLIENT_DATA/$setupname
# get the new setup-file from website and rename it to a standard file name (so no need to change the setup.ins :P )
url=$(wget --no-check-certificate $geturl  -q -O- | grep -o $grepvar )
wget --no-check-certificate "https://$url" -O $opsiproduct_path/$product/CLIENT_DATA/$setupname
# let's change the directory to the package
cd $opsiproduct_path/$product/
# remove the *.opsi-files
rm *.opsi
rm *.md5
rm *.zsync
# to find out, which version it is, we do a little bit of awk
pos=$(echo $url | grep -b -o .exe | awk 'BEGIN {FS=":"}{print $1}')
# well done, we found it.
version=$(echo $url | cut -c$startpos-$pos)
# now let's change the /OPSI/control file
sed "s/version:.*/version: $version /g" $opsiproduct_path/$product/OPSI/control > $opsiproduct_path/$product/OPSI/control.new
mv $opsiproduct_path/$product/OPSI/control.new $opsiproduct_path/$product/OPSI/control
# make new package, but quiet
opsi-makepackage -q
opsi-package-manager -i *.opsi