New: updater ; fix setup

This commit is contained in:
Cyrille L 2022-03-24 11:40:21 +01:00
parent 60a8368d18
commit 909bfe6de6
9 changed files with 95 additions and 20 deletions

View File

@ -12,6 +12,9 @@ doing for now, is checking for updates and showing packages old and new
version for debian and archlinux (separrating AUR and System available version for debian and archlinux (separrating AUR and System available
updates). More functions will be added soon... updates). More functions will be added soon...
# Dependancies
- curl (to check available version and let upd -U update himself)
# How to install # How to install
``` ```
git clone https://git.a-lec.org/echolib/upd git clone https://git.a-lec.org/echolib/upd

View File

@ -8,8 +8,15 @@
# local home # local home
upd_dir_home="$HOME/.config/upd" upd_dir_home="$HOME/.config/upd"
# Script # Files
upd_file_check="$upd_dir_home/check" upd_file_check="$upd_dir_home/check"
upd_file_check_aur="$upd_dir_home/check_aur" upd_file_check_aur="$upd_dir_home/check_aur"
# Script
upd_script_check="/var/lib/upd/scripts/check" upd_script_check="/var/lib/upd/scripts/check"
upd_script_help="/var/lib/upd/scripts/help" upd_script_help="/var/lib/upd/scripts/help"
upd_script_updater="/var/lib/upd/scripts/updater"
# Onlinde Repo
upd_repo_upd="https://git.a-lec.org/echolib/upd/-/raw/main/usr/local/bin/upd"
upd_repo_tar="https://git.a-lec.org/echolib/upd/-/archive/main/upd-main.tar.gz"

View File

@ -86,19 +86,23 @@ sudo mkdir -p "$setup_dir_bin" \
&& setup__check_err && setup__check_err
echo "- File: $setup_file_bin" echo "- File: $setup_file_bin"
echo -ne " Copy $PWD$set_bin_uri + chmod 755:"
sudo cp -f "$PWD$set_bin_uri" \
"$set_bin_uri" \
&& cmd_res="$?" \
&& setup__check_err
echo -ne " Owner $setup_user:" echo -ne " Owner $setup_user:"
sudo chown "$setup_user":"$setup_user" "$set_bin_uri" \ sudo chown "$setup_user":"$setup_user" "$set_bin_uri" \
&& cmd_res="$?" \ && cmd_res="$?" \
&& setup__check_err && setup__check_err
echo -ne " Copy $PWD$set_bin_uri:"
sudo cp -f "$PWD$set_bin_uri" \
"$set_bin_uri" \
&& cmd_res="$?" \
&& setup__check_err
sudo chmod 755 "$set_bin_uri" sudo chmod 755 "$set_bin_uri"
echo -e "\n# Thank you for installing upd. Have fun !" printf '\n%b\n%b\n%b\n' \
"# Thank you for installing upd." \
" (You can remove the repo and use upd -U to update)" \
" Have fun !"
} }
# PWD is Not a repo # PWD is Not a repo

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# version: 0.0.6 # version: 0.0.7
# file: upd # file: upd
# Folder: /usr/local/bin # Folder: /usr/local/bin
# By echolib # By echolib
@ -96,9 +96,22 @@ case "$1" in
|| upd -c || upd -c
;; ;;
version|-v)
awk 'NR==2 {print "# Installed:",$3}' "/usr/local/bin/upd"
;;
-vv)
awk 'NR==2 {print "# Installed:",$3}' "/usr/local/bin/upd"
curl -s "$upd_repo_upd" | awk 'NR==2 {print "# Available:",$3}'
;;
-U)
if__file "$upd_script_updater" source
upd__Updater
;;
help|--help|-h|*) help|--help|-h|*)
if__file "$upd_script_help" source if__file "$upd_script_help" source
upd__help upd__help
;; ;;
esac esac

View File

@ -12,6 +12,9 @@ doing for now, is checking for updates and showing packages old and new
version for debian and archlinux (separrating AUR and System available version for debian and archlinux (separrating AUR and System available
updates). More functions will be added soon... updates). More functions will be added soon...
# Dependancies
- curl (to check available version and let upd -U update himself)
# How to install # How to install
``` ```
git clone https://git.a-lec.org/echolib/upd git clone https://git.a-lec.org/echolib/upd

View File

@ -1,7 +1,6 @@
#!/bin/bash #!/bin/bash
# version: 0.0.1
# file: help # file: help
# Folder: /var/lib/upd/scripts # Folder: /var/lib/upd/scripts/
# By echolib # By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
@ -10,5 +9,8 @@ cat << EOHELP
# upd : System Updater # upd : System Updater
check | -c : Check for updates check | -c : Check for updates
list | -l : List updates (Check if none) list | -l : List updates (Check if none)
-v : Show Installeed version
-vv : Show Installed and Available versions
-U : Check and Update upd
EOHELP EOHELP
} }

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# file: tools # file: tools
# Folder: /var/lib/filebox/scripts # Folder: /var/lib/filebox/scripts/
# By echolib # By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 # License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007

View File

@ -0,0 +1,39 @@
#!/bin/bash
# file: updater
# Folder: /var/lib/upd/scripts/
# By echolib
# License: GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007
#======================================================================
# Automatic Updater
#======================================================================
upd__Updater() {
upd_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/upd"`
upd_onl=`curl -s "$upd_repo_upd" | awk 'NR==2 {print $3}'`
printf -v versions '%s\n%s' "$upd_cur" "$upd_onl"
[[ `sort -V <<< "$versions" | tail -1` == $upd_cur ]] \
&& echo "# upd is up to date. Current: $upd_cur | Online: $upd_onl" \
&& return
# Get archive
cd /tmp
curl -L -o upd-main.tar.gz "$upd_repo_tar" 2>/dev/null
if [[ -f "upd-main.tar.gz" ]];then
tar -xzf upd-main.tar.gz
cd upd-main
rsync -a --delete "usr/local/bin/" "/usr/local/bin"
rsync -a --delete "var/lib/upd/" "/var/lib/upd/"
rsync -a --delete "etc/upd/" "/etc/upd/"
# Check
upd_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/upd"`
echo "# upd updated to: $upd_cur"
rm -rf /tmp/upd-main
rm -f upd-main.tar.gz
else
echo "! Download error"
fi
}

View File

@ -86,19 +86,23 @@ sudo mkdir -p "$setup_dir_bin" \
&& setup__check_err && setup__check_err
echo "- File: $setup_file_bin" echo "- File: $setup_file_bin"
echo -ne " Copy $PWD$set_bin_uri + chmod 755:"
sudo cp -f "$PWD$set_bin_uri" \
"$set_bin_uri" \
&& cmd_res="$?" \
&& setup__check_err
echo -ne " Owner $setup_user:" echo -ne " Owner $setup_user:"
sudo chown "$setup_user":"$setup_user" "$set_bin_uri" \ sudo chown "$setup_user":"$setup_user" "$set_bin_uri" \
&& cmd_res="$?" \ && cmd_res="$?" \
&& setup__check_err && setup__check_err
echo -ne " Copy $PWD$set_bin_uri:"
sudo cp -f "$PWD$set_bin_uri" \
"$set_bin_uri" \
&& cmd_res="$?" \
&& setup__check_err
sudo chmod 755 "$set_bin_uri" sudo chmod 755 "$set_bin_uri"
echo -e "\n# Thank you for installing upd. Have fun !" printf '\n%b\n%b\n%b\n' \
"# Thank you for installing upd." \
" (You can remove the repo and use upd -U to update)" \
" Have fun !"
} }
# PWD is Not a repo # PWD is Not a repo