Glacier v3.2.0 - Changes to package removal
This commit is contained in:
83
src/glacier
83
src/glacier
@@ -37,7 +37,7 @@ int_check() {
|
||||
unpack_pkg() {
|
||||
printf "$blue[ i ]$reset Unpacking $2.tar.gz...\n"
|
||||
mkdir $2 && mv $2.tar.gz $2 && cd $2
|
||||
tar -xvf $2.tar.gz
|
||||
tar -xf $2.tar.gz
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "$red[ $error ]$reset Could not unpack $2.tar.gz.\n"
|
||||
cd .. && rm -rf $2
|
||||
@@ -76,7 +76,7 @@ removepkg() {
|
||||
printf "$blue[ i ]$reset Removing $2...\n"
|
||||
sleep 1
|
||||
chmod +x *
|
||||
./REMOVE.sh
|
||||
/etc/glacier/pkginfo/$2.remove
|
||||
if [ "$?" != "0" ]; then
|
||||
printf "$red[ $error ]$reset Failed to remove $2.\n"
|
||||
cd .. && rm -rf $2
|
||||
@@ -108,8 +108,12 @@ clear_cache() {
|
||||
fi
|
||||
}
|
||||
|
||||
#
|
||||
# Show Glacier debugging info
|
||||
#
|
||||
|
||||
debug_info() {
|
||||
printf "$blue>> Glacier v3.1.1$reset\n"
|
||||
printf "$blue>> Glacier v3.2.0$reset\n"
|
||||
printf ">> Checking for valid download backend...\n"
|
||||
whereis wget
|
||||
whereis curl
|
||||
@@ -148,6 +152,10 @@ debug_info() {
|
||||
printf ">> $ glacier --debuginfo > glacier.debug\n"
|
||||
}
|
||||
|
||||
#
|
||||
# Parses JSON from pkginfo files and outputs it
|
||||
#
|
||||
|
||||
query() {
|
||||
printf "$blue[ i ]$reset Showing information for package '$2'.\n"
|
||||
printf "$blue>> Package name:$reset " && cat /etc/glacier/pkginfo/$2-pkginfo.json | jq .package_name
|
||||
@@ -159,15 +167,42 @@ query() {
|
||||
printf "$blue>> Installation date:$reset " && cat /var/log/glacier/$2.timestamp
|
||||
}
|
||||
|
||||
cleanup () {
|
||||
#
|
||||
# Will either keep removal script, update it with a new one, or delete it alltogether
|
||||
#
|
||||
|
||||
cleanup_keep_rm () {
|
||||
printf "$blue[ i ]$reset Cleaning up...\n"
|
||||
mv REMOVE.sh /etc/glacier/pkginfo/$2.remove
|
||||
cd .. && rm -rf *.checksum *.tar.* $2
|
||||
}
|
||||
|
||||
cleanup_update_rm () {
|
||||
printf "$blue[ i ]$reset Cleaning up...\n"
|
||||
rm /etc/glacier/pkginfo/$2.remove
|
||||
mv REMOVE.sh /etc/glacier/pkginfo/$2.remove
|
||||
cd .. && rm -rf *.checksum *.tar.* $2
|
||||
}
|
||||
|
||||
cleanup_del_rm () {
|
||||
printf "$blue[ i ]$reset Cleaning up...\n"
|
||||
rm /etc/glacier/pkginfo/$2.remove
|
||||
cd .. && rm -rf *.checksum *.tar.* $2
|
||||
}
|
||||
|
||||
#
|
||||
# Execute pre and posr hooks from files
|
||||
#
|
||||
|
||||
pre_hooks() {
|
||||
source /etc/glacier/hooks
|
||||
}
|
||||
|
||||
pre_op_hooks() {
|
||||
printf "$blue[ i ]$reset Executing pre-operation hooks...\n"
|
||||
/etc/glacier/pre-hooks
|
||||
}
|
||||
|
||||
post_hooks () {
|
||||
printf "$blue[ i ]$reset Executing post-operation hooks...\n"
|
||||
/etc/glacier/post-hooks
|
||||
@@ -176,7 +211,7 @@ post_hooks () {
|
||||
case $1 in
|
||||
-h|--help)
|
||||
printf "$blue[ * ] Glacier - Manage installed packages on the system$reset\n"
|
||||
printf "usage: glacier {action} {package-name}\n"
|
||||
printf "usage: glacier [-f] [-u] [-x] [-q] [-c] [-ci] [-cc] [--debuginfo]\n"
|
||||
printf "\n"
|
||||
printf "$blue=== Information ===$reset\n"
|
||||
printf "glacier {-h/--help} - Show this message and exit\n"
|
||||
@@ -201,10 +236,10 @@ case $1 in
|
||||
exit 0
|
||||
;;
|
||||
-v|--version)
|
||||
printf "$blue Glacier v3.1.1$reset\n"
|
||||
printf "${blue}Glacier v3.2.0${reset}\n"
|
||||
exit 0
|
||||
;;
|
||||
-f|-install)
|
||||
-f|install)
|
||||
if [[ $(/usr/bin/id -u) -ne 0 ]]; then
|
||||
printf "$red[ $error ]$reset Please run Glacier as root.\n"
|
||||
exit 1
|
||||
@@ -224,11 +259,16 @@ case $1 in
|
||||
get_pkg "$@"
|
||||
int_check "$@"
|
||||
unpack_pkg "$@"
|
||||
pre_op_hooks "$@"
|
||||
installpkg "$@"
|
||||
post_hooks "$@"
|
||||
cleanup "$@"
|
||||
cleanup_keep_rm "$@"
|
||||
printf "$green[ $check ]$reset Operation completed.\n"
|
||||
exit 0
|
||||
elif [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
printf "\n"
|
||||
printf "${red}[ $error ]${reset} Aborting.\n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-u|update)
|
||||
@@ -251,11 +291,16 @@ case $1 in
|
||||
get_pkg "$@"
|
||||
int_check "$@"
|
||||
unpack_pkg "$@"
|
||||
pre_op_hooks "$@"
|
||||
updatepkg "$@"
|
||||
post_hooks "$@"
|
||||
cleanup "$@"
|
||||
cleanup_update_rm "$@"
|
||||
printf "$green[ $check ]$reset Operation completed.\n"
|
||||
exit 0
|
||||
elif [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
printf "\n"
|
||||
printf "${red}[ $error ]${reset} Aborting.\n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-x|remove)
|
||||
@@ -275,14 +320,15 @@ case $1 in
|
||||
cd /opt/glacier/workspace
|
||||
printf "\n"
|
||||
pre_hooks "$@"
|
||||
get_pkg "$@"
|
||||
int_check "$@"
|
||||
unpack_pkg "$@"
|
||||
removepkg "$@"
|
||||
post_hooks "$@"
|
||||
cleanup "$@"
|
||||
cleanup_del_rm "$@"
|
||||
printf "$green[ $check ]$reset Operation completed.\n"
|
||||
exit 0
|
||||
elif [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
printf "\n"
|
||||
printf "${red}[ $error ]${reset} Aborting.\n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-q|query)
|
||||
@@ -314,6 +360,10 @@ case $1 in
|
||||
int_check "$@"
|
||||
printf "$green[ $check ]$reset Operation completed.\n"
|
||||
exit 0
|
||||
elif [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
printf "\n"
|
||||
printf "${red}[ $error ]${reset} Aborting.\n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-ci|cache-install)
|
||||
@@ -336,11 +386,16 @@ case $1 in
|
||||
printf "\n"
|
||||
pre_hooks "$@"
|
||||
unpack_pkg "$@"
|
||||
pre_op_hooks "$@"
|
||||
installpkg "$@"
|
||||
post_hooks "$@"
|
||||
cleanup "$@"
|
||||
cleanup_keep_rm "$@"
|
||||
printf "$green[ $check ]$reset Operation completed.\n"
|
||||
exit 0
|
||||
elif [[ $REPLY =~ ^[Nn]$ ]]; then
|
||||
printf "\n"
|
||||
printf "${red}[ $error ]${reset} Aborting.\n"
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
-cc|cache-clear)
|
||||
|
||||
Reference in New Issue
Block a user