testing debian + new options for arch

This commit is contained in:
Cyrille L 2022-04-06 10:42:01 +02:00
parent eb0946cb87
commit cf31246246
6 changed files with 140 additions and 27 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# version: 0.0.16 # version: 0.0.17
# file: upd # file: upd
# Folder: /usr/local/bin # Folder: /usr/local/bin
# By echolib # By echolib
@ -93,10 +93,10 @@ case "$1" in
echo -ne "# Checking for updates..." echo -ne "# Checking for updates..."
case "$arch" in case "$arch" in
pacman) pacman)
upd__check_arch upd__check arch
;; ;;
apt) apt)
upd__check_deb upd__check deb
;; ;;
esac esac
;; ;;
@ -115,18 +115,31 @@ case "$1" in
script__versions script__versions
;; ;;
-vvv)
verbose=true
script__versions
;;
-U) -U)
Updater Updater
;; ;;
-u) -u)
if__file "$upd_script_upgrader" source if__file "$upd_script_upgrader" source
case "$arch" in sysup="system"
pacman) upg__main
upd__check_arch ;;
upg__arch
;; -f)
esac if__file "$upd_script_upgrader" source
sysup="full"
upg__main
;;
-a)
if__file "$upd_script_upgrader" source
sysup="aur"
upg__main
;; ;;
readme) readme)

View File

@ -7,6 +7,13 @@
#====================================================================== #======================================================================
# Check for updates if archlinux # Check for updates if archlinux
#====================================================================== #======================================================================
upd__check() {
case "$1" in
arch) upd__check_arch ;;
deb) upd__check_deb
esac
}
upd__check_arch() { upd__check_arch() {
checkupdates > "$upd_file_check" checkupdates > "$upd_file_check"
@ -88,7 +95,7 @@ if [[ "$aur" == "yay" ]];then
upd_nbr_aur=`cat "$upd_file_check_aur" | wc -l` upd_nbr_aur=`cat "$upd_file_check_aur" | wc -l`
(( $upd_nbr_aur > 0 )) \ (( $upd_nbr_aur > 0 )) \
&& C_NBR_aur=${C_Yellow} \ && C_NBR_aur=${C_Yellow} \
&& upd_show_aur="$Pp_Grey + AUR=$C_NBR_aur$upd_nbr_aur$NC " \ && upd_show_aur="$Pp_Grey + AUR: $C_NBR_aur$upd_nbr_aur$NC " \
&& upd__show "$upd_file_check_aur" && upd__show "$upd_file_check_aur"
fi fi
@ -101,7 +108,7 @@ fi
# Resume # Resume
printf '%b%b%b\n' \ printf '%b%b%b\n' \
"$upd_inf Updates: - System=$C_NBR$upd_nbr$NC " \ "$upd_inf Updates System: $C_NBR$upd_nbr$NC " \
"$upd_show_aur" \ "$upd_show_aur" \
"$upd_reboot" "$upd_reboot"
} }

View File

@ -12,6 +12,17 @@ cat << EOHELP
list | -l : List updates (Check if none) list | -l : List updates (Check if none)
-v : Show Installed version -v : Show Installed version
-vv : Show if new version available -vv : Show if new version available
-vvv : + online version
-U : Check and Update upd -U : Check and Update upd
[arch]
-u : update system only
-f : update system + AUR
-a : update AUR packages only
[deb]
-u : upgrade
-f : full-upgrade
EOHELP EOHELP
} }

View File

@ -78,7 +78,11 @@ else
isa_c="$I_Yellow" isa_c="$I_Yellow"
fi fi
is__admin_show case "$1" in
show)
is__admin_show
;;
esac
} }
#====================================================================== #======================================================================
@ -88,7 +92,7 @@ upd__sudoroot() {
if__command sudo if__command sudo
# Check if sudo rights # Check if sudo rights
isadmin isadmin "$1"
case "$is_admin" in case "$is_admin" in
user) user)
echo "! No admin rights" echo "! No admin rights"

View File

@ -21,7 +21,9 @@ fi
printf -v versions '%s\n%s' "$v_cur" "$v_onl" printf -v versions '%s\n%s' "$v_cur" "$v_onl"
if [[ `sort -V <<< "$versions" | tail -1` == $v_cur ]];then if [[ `sort -V <<< "$versions" | tail -1` == $v_cur ]];then
echo "# $app_name is up to date (version: $v_cur)" [[ $verbose ]] \
&& s_onl=" > online: $v_onl"
echo "# $app_name is up to date (version: $v_cur$s_onl)"
upd_err=true upd_err=true
return 0 return 0
else else

View File

@ -5,38 +5,114 @@
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#====================================================================== #======================================================================
# script version checker # Upgrade system
#====================================================================== #======================================================================
upg__arch() { upg__main() {
case "$sysup" in
system)
case "$arch" in
pacman)
clear
upd__check_arch
(( $upd_nbr == 0 )) \
&& exit 0
upg__arch_system
;;
apt)
clear
upd__check_deb
(( $upd_nbr == 0 )) \
&& exit 0
(( $upd_nbr == 0 )) && (( $upd_nbr_aur == 0 )) \ upg__deb_upgrade
&& echo "# No updates available" \ ;;
&& exit 0 esac
;;
full)
case "$arch" in
pacman)
clear
upd__check_arch
(( $upd_nbr == 0 )) && (( $upd_nbr_aur == 0 )) \
&& exit 0
upg__arch_system
upg__arch_aur
;;
apt)
clear
upd__check_deb
(( $upd_nbr == 0 )) \
&& exit 0
upg__deb_full_upgrade
;;
esac
;;
aur)
[[ $arch == "apt" ]] \
&& echo "# Invalid option for this system" \
&& exit 0
upd__check_arch
(( $upd_nbr_aur == 0 )) \
&& exit 0
#clear
upg__arch_aur
;;
*)
exit
;;
esac
# Cleaning
rm -f "$upd_file_check"
rm -f "$upd_file_check_aur"
}
upg__arch_system() {
[[ -f /var/lib/pacman/db.lck ]] \ [[ -f /var/lib/pacman/db.lck ]] \
&& printf '%b%b\n' \ && echo -e "$I_Red System is locked: /var/lib/pacman/db.lck" \
"$I_Red System is upgrading... " \
"or pacman is locked (/var/lib/pacman/db.lck)" \
&& return && return
upd__sudoroot # Tools: Check if user is admin upd__sudoroot # Tools: Check if user is admin
echo "# Syncing..." echo "# Syncing..."
sudo pacman -Sy &>/dev/null sudo pacman -Sy &>/dev/null
echo -ne "\r\033[2K" echo -ne "\r\033[2K"
upd_pkg_upg="--ignore=linux --ignore=linux-headers" upd_pkg_upg="--ignore=linux --ignore=linux-headers"
if [[ `grep "^linux-" "$upd_file_check"` ]];then if [[ `grep "^linux-" "$upd_file_check"` ]];then
read -rp "! Upgrade Kernel (y|N)? " upd_arch_ask read -rp "$I_Red Upgrade Kernel (y|N)? " upd_arch_ask
case "$upd_arch_ask" in case "$upd_arch_ask" in
Y|y) unset upd_pkg_upg ;; Y|y) unset upd_pkg_upg ;;
*) true ;; *) true ;;
esac esac
fi fi
echo -e "${I_Yellow} Upgrading System...\n" echo -e "$I_Yellow Upgrading System...\n"
sudo pacman -Su --needed $upd_pkg_upg sudo pacman -Su --noconfirm --needed "$upd_pkg_upg"
}
if [[ "$aur" == "yay" ]] && (( $upd_nbr_aur > 0 ));then upg__arch_aur() {
yay -Syu --save --sudoloop --nocleanmenu --nodiffmenu upd__sudoroot # Tools: Check if user is admin
if [[ "$aur" == "yay" ]];then
echo -e "$I_Yellow Upgrading AUR packages...\n"
yay -Syu --save --sudoloop --nocleanmenu --nodiffmenu --noeditmenu
else
echo "$I_Red Not using yay ; abandon"
fi fi
} }
upg__deb_upgrade() {
sudo apt upgrade -y
}
upg__deb_full_upgrade() {
sudo apt full-upgrade -y
}