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
updates). More functions will be added soon...
# Dependancies
- curl (to check available version and let upd -U update himself)
# How to install
```
git clone https://git.a-lec.org/echolib/upd

View File

@ -8,8 +8,15 @@
# local home
upd_dir_home="$HOME/.config/upd"
# Script
# Files
upd_file_check="$upd_dir_home/check"
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_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
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:"
sudo chown "$setup_user":"$setup_user" "$set_bin_uri" \
&& cmd_res="$?" \
&& 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"
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

View File

@ -1,5 +1,5 @@
#!/bin/bash
# version: 0.0.6
# version: 0.0.7
# file: upd
# Folder: /usr/local/bin
# By echolib
@ -96,9 +96,22 @@ case "$1" in
|| 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|*)
if__file "$upd_script_help" source
upd__help
;;
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
updates). More functions will be added soon...
# Dependancies
- curl (to check available version and let upd -U update himself)
# How to install
```
git clone https://git.a-lec.org/echolib/upd

View File

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

View File

@ -1,6 +1,6 @@
#!/bin/bash
# file: tools
# Folder: /var/lib/filebox/scripts
# Folder: /var/lib/filebox/scripts/
# By echolib
# 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
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:"
sudo chown "$setup_user":"$setup_user" "$set_bin_uri" \
&& cmd_res="$?" \
&& 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"
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