glacier-old/src/gscripts
2022-10-06 20:16:48 -04:00

59 lines
2.4 KiB
Bash
Executable File

#!/bin/sh
# gscripts - Scripts for Glacier operations
source /etc/glacier.conf
while [[ $# -gt 0 ]]; do
case $1 in
help)
printf "gscripts - backend for many Glacier functionalities since v3\n"
printf "gscripts {help} show this message\n"
printf "gscripts {integrity-check} verify package integrity\n"
printf "gscripts {download} download a package\n"
printf "gscripts {post-install} run post installation cleanup hooks\n"
printf "\n"
printf "this program can be distributed under the terms of the GNU General\n"
printf "Public License version 3 or higher\n"
exit 0
;;
preload)
/etc/glacier/hooks
if [ "$?" != "0" ]; then
exit 1
fi
exit 0
;;
integrity-check)
$GLACIER_DOWNLOAD_BACKEND $WORLD_SUM/$input.checksum || $GLACIER_DOWNLOAD_BACKEND $GALAXY_SUM/$input.checksum || $GLACIER_DOWNLOAD_BACKEND $UNIVERSE_SUM/$input.checksum || $GLACIER_DOWNLOAD_BACKEND $MULTIVERSE_SUM/$input.checksum || $GLACIER_DOWNLOAD_BACKEND $WORLD_TESTING_SUM/$input.checksum || $GLACIER_DOWNLOAD_BACKEND $GALAXY_TESTING_SUM/$input.checksum || $GLACIER_DOWNLOAD_BACKEND $UNIVERSE_TESTING_SUM/$input.checksum || $GLACIER_DOWNLOAD_BACKEND $MULTIVERSE_TESTING_SUM/$input.checksum
exit 0
LOCAL_SUM=$(sha256sum $input.tar.gz)
if [ $input.checksum = $LOCAL_SUM ]; then
printf "$green [ $check ]$reset Integrity check passed.\n"
rm $input.checksum
exit 0
else
printf "$red [ $error ]$reset Integrity check failed.\n"
rm $input.checksum
exit 1
fi
;;
download)
$GLACIER_DOWNLOAD_BACKEND $GREPO1/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO2/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO3/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO4/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO5/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO6/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO7/$input.tar.gz || $GLACIER_DOWNLOAD_BACKEND $GREPO8/$input.tar.gz
exit 0
;;
post-install)
mv -vf -- $input-pkginfo.json /etc/glacier/pkginfo || printf "error in subprocess /usr/bin/gscripts: could not stat $input-pkginfo.json\n" && exit 1
cd ..
rm -rf $input || printf "error in subprocess /usr/bin/gscripts: could not remove package source\n" && exit 1
;;
-*|--*)
printf "gscripts - no valid option was passed, see 'help' for details\n"
exit 1
;;
esac
done
printf "gscripts - no option was passed, see 'help' for details\n"