New version : fixes
This commit is contained in:
parent
df9a099520
commit
1b69849f85
|
@ -16,6 +16,7 @@ upd_file_check_aur="$upd_dir_home/check_aur"
|
|||
# Script
|
||||
upd_script_check="/var/lib/upd/scripts/check"
|
||||
upd_script_help="/var/lib/upd/scripts/help"
|
||||
upd_script_tools="/var/lib/upd/scripts/tools"
|
||||
upd_script_updater="/var/lib/upd/scripts/updater"
|
||||
|
||||
# Onlinde Repo
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# version: 0.0.11
|
||||
# version: 0.0.12
|
||||
# file: upd
|
||||
# Folder: /usr/local/bin
|
||||
# By echolib
|
||||
|
@ -70,17 +70,20 @@ fi
|
|||
#======================================================================
|
||||
# Main
|
||||
#======================================================================
|
||||
if__file "/etc/upd/upd.conf" source
|
||||
if__file "/var/lib/upd/scripts/tools" source
|
||||
if__arch
|
||||
|
||||
if__file "/etc/upd/upd.conf" source
|
||||
if__file "$upd_script_tools" source
|
||||
if__file "$upd_script_updater" source
|
||||
if__file "$upd_script_check" source
|
||||
|
||||
if__folder "$upd_dir_home" make
|
||||
if__file "$upd_file_check" create
|
||||
|
||||
# create specific db file for aur packages
|
||||
[[ "$aur" == "yay" ]] \
|
||||
&& if__file "$upd_file_check_aur" create
|
||||
|
||||
if__file "$upd_script_check" source
|
||||
|
||||
case "$1" in
|
||||
"")
|
||||
upd check
|
||||
|
@ -109,19 +112,14 @@ case "$1" in
|
|||
;;
|
||||
|
||||
-vv)
|
||||
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
|
||||
echo -n "# $app_name Current: $v_cur | "
|
||||
if__command curl
|
||||
v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'`
|
||||
echo -ne "Online: $v_onl\n"
|
||||
script__versions
|
||||
;;
|
||||
|
||||
-U)
|
||||
if__file "$upd_script_updater" source
|
||||
Updater
|
||||
;;
|
||||
|
||||
--readme)
|
||||
readme)
|
||||
if__file "/var/lib/upd/README.md" read
|
||||
;;
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ upd__prepare_show
|
|||
# Check for updates if debian (apt based)
|
||||
#======================================================================
|
||||
upd__check_deb() {
|
||||
upd__sudoroot # Tools: Check if user is admin
|
||||
|
||||
sudo apt-get update -qq
|
||||
|
||||
upd_file_tmp_apt=`mktemp`
|
||||
|
@ -46,6 +48,13 @@ upd__prepare_show
|
|||
#======================================================================
|
||||
upd__prepare_show() {
|
||||
echo -ne "\r\033[2K"
|
||||
upd -vv
|
||||
echo
|
||||
|
||||
upd__reboot_set() {
|
||||
upd_reboot="$Pp_Grey ${C_Red}Reboot$NC required"
|
||||
upd_inf="$I_Red"
|
||||
}
|
||||
|
||||
# if erboot
|
||||
case "$arch" in
|
||||
|
@ -53,12 +62,11 @@ case "$arch" in
|
|||
[[ `uname -r | sed 's/-/./'` \
|
||||
!= `pacman -Q linux | sed 's/linux //'` \
|
||||
]] \
|
||||
&& upd_reboot="$Pp_Grey ${C_Red}Reboot$NC needed" \
|
||||
&& upd_inf="$I_Red"
|
||||
&& upd__reboot_set
|
||||
;;
|
||||
apt)
|
||||
[[ -f /var/run/reboot-required ]] \
|
||||
&& upd_reboot="$Pp_Grey ${C_Red}Reboot$NC needed"
|
||||
&& upd__reboot_set
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -100,11 +108,11 @@ upd__show() {
|
|||
|
||||
upd__filters() {
|
||||
printf '%b%b%b%b%b\n' \
|
||||
"${C_Color}$list${NC} " \
|
||||
"${C_Color}$pkg${NC}|" \
|
||||
"${C_Yellow}$old${NC}|" \
|
||||
"${C_Grey}$sep${NC}|" \
|
||||
"${C_Green}$new${NC}" \
|
||||
"$C_Color$list$NC " \
|
||||
"$C_Color$pkg$NC|" \
|
||||
"$C_Yellow$old$NC|" \
|
||||
"$C_Grey$sep$NC|" \
|
||||
"$C_Green$new$NC" \
|
||||
>> "$upd_file_tmp"
|
||||
}
|
||||
|
||||
|
@ -114,7 +122,7 @@ do
|
|||
case "$pkg" in
|
||||
linux*)
|
||||
list="!"
|
||||
C_Color="${C_Yellow}"
|
||||
C_Color="$C_Yellow"
|
||||
upd__filters
|
||||
;;
|
||||
*)
|
||||
|
@ -126,7 +134,7 @@ do
|
|||
list="+"
|
||||
;;
|
||||
esac
|
||||
C_Color="${NC}"
|
||||
C_Color="$NC"
|
||||
upd__filters
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -7,11 +7,11 @@
|
|||
upd__help() {
|
||||
cat << EOHELP
|
||||
# upd : System Updater
|
||||
--readme : Show readme
|
||||
readme : Show readme
|
||||
check | -c : Check for updates (or just type upd)
|
||||
list | -l : List updates (Check if none)
|
||||
-v : Show Installed version
|
||||
-vv : Show Installed and Available versions
|
||||
-vv : Show if new version available
|
||||
-U : Check and Update upd
|
||||
EOHELP
|
||||
}
|
||||
|
|
|
@ -39,3 +39,60 @@ Bo_Grey="\e[2m(\e[0m"
|
|||
Bc_Grey="\e[2m)\e[0m"
|
||||
Pp_Grey="\e[2m|\e[0m"
|
||||
Dp_Grey="\e[2m:\e[0m"
|
||||
|
||||
#======================================================================
|
||||
# Set $is_admin : Is user Root or Sudo ?
|
||||
#======================================================================
|
||||
isadmin() {
|
||||
|
||||
is__admin_show() {
|
||||
echo -e "$isa_c $USER ${C_Grey}has$NC $user_admin"
|
||||
}
|
||||
|
||||
if_admin=`id -u`
|
||||
if (( $if_admin )) && (( $if_admin == 0 ));then
|
||||
is_admin="${C_Red}root$NC"
|
||||
user_admin=$is_admin
|
||||
isa_c="$I_Red"
|
||||
is__admin_show
|
||||
return
|
||||
fi
|
||||
|
||||
if ! [[ `command -v sudo` ]];then
|
||||
is_admin="user"
|
||||
user_admin="${C_Cyan}NO rights$NC"
|
||||
isa_c="$I_Cyan"
|
||||
is__admin_show
|
||||
return
|
||||
fi
|
||||
|
||||
user_prompt=`sudo -nv 2>&1`
|
||||
code_return="$?"
|
||||
if (( $code_return == 1 ));then
|
||||
is_admin="sudo-1"
|
||||
user_admin="${C_Green}no rights yet$NC"
|
||||
isa_c="$I_Green"
|
||||
else
|
||||
is_admin="sudo-0"
|
||||
user_admin="${C_Yellow}rights$NC"
|
||||
isa_c="$I_Yellow"
|
||||
fi
|
||||
|
||||
is__admin_show
|
||||
}
|
||||
|
||||
#======================================================================
|
||||
# Continue if root / sudo
|
||||
#======================================================================
|
||||
upd__sudoroot() {
|
||||
if__command sudo
|
||||
|
||||
# Check if sudo rights
|
||||
isadmin
|
||||
case "$is_admin" in
|
||||
user)
|
||||
echo "! No admin rights"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
|
@ -4,26 +4,34 @@
|
|||
# By echolib
|
||||
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
|
||||
|
||||
#======================================================================
|
||||
# script version checker
|
||||
#======================================================================
|
||||
script__versions() {
|
||||
if__command curl
|
||||
|
||||
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
|
||||
v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'`
|
||||
|
||||
! [[ $v_onl ]] \
|
||||
&& echo "! Unknown available version" \
|
||||
&& exit 1
|
||||
|
||||
printf -v versions '%s\n%s' "$v_cur" "$v_onl"
|
||||
if [[ `sort -V <<< "$versions" | tail -1` == $v_cur ]];then
|
||||
echo "# $app_name is up to date (version: $v_cur)"
|
||||
exit 0
|
||||
else
|
||||
echo -e "- $app_name $C_Yellow$v_cur$NC -> $C_Green$v_onl$NC"
|
||||
fi
|
||||
}
|
||||
|
||||
#======================================================================
|
||||
# Automatic Updater
|
||||
#======================================================================
|
||||
Updater() {
|
||||
if__command curl
|
||||
if__command rsync
|
||||
|
||||
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
|
||||
echo -n "# $app_name Current: $v_cur | "
|
||||
v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'`
|
||||
if ! [[ $v_onl ]];then
|
||||
echo -ne "Online: Unknown\n"
|
||||
exit 1
|
||||
else
|
||||
echo -ne "Online: $v_onl\n"
|
||||
fi
|
||||
|
||||
printf -v versions '%s\n%s' "$v_cur" "$v_onl"
|
||||
[[ `sort -V <<< "$versions" | tail -1` == $v_cur ]] \
|
||||
&& return
|
||||
script__versions
|
||||
|
||||
# Get archive
|
||||
cd /tmp
|
||||
|
@ -34,9 +42,9 @@ curl -L -o ${app_name}-main.tar.gz "$repo_tar" 2>/dev/null
|
|||
|
||||
tar -xzf ${app_name}-main.tar.gz
|
||||
cd ${app_name}-main
|
||||
rsync -a --delete "usr/local/bin/" "/usr/local/bin"
|
||||
rsync -a --delete "var/lib/${app_name}/" "/var/lib/${app_name}/"
|
||||
rsync -a --delete "etc/${app_name}/" "/etc/${app_name}/"
|
||||
rsync -a "usr/local/bin/" "/usr/local/bin"
|
||||
rsync -a --delete "var/lib/$app_name/" "/var/lib/$app_name/"
|
||||
rsync -a --delete "etc/$app_name/" "/etc/$app_name/"
|
||||
|
||||
# Check
|
||||
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
|
||||
|
|
Loading…
Reference in New Issue