New version : testing

This commit is contained in:
Cyrille L 2022-03-28 15:43:14 +02:00
parent 1b69849f85
commit 760ac36149
2 changed files with 18 additions and 13 deletions

View File

@ -1,5 +1,5 @@
#!/bin/bash #!/bin/bash
# version: 0.0.12 # version: 0.0.13
# file: upd # file: upd
# Folder: /usr/local/bin # Folder: /usr/local/bin
# By echolib # By echolib

View File

@ -13,14 +13,17 @@ if__command curl
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"` v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'` v_onl=`curl -s "$repo" | awk 'NR==2 {print $3}'`
! [[ $v_onl ]] \ if ! [[ $v_onl ]];then
&& echo "! Unknown available version" \ echo "! Unknown available version"
&& exit 1 upd_err=true
return 1
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)" echo "# $app_name is up to date (version: $v_cur)"
exit 0 upd_err=true
return 0
else else
echo -e "- $app_name $C_Yellow$v_cur$NC -> $C_Green$v_onl$NC" echo -e "- $app_name $C_Yellow$v_cur$NC -> $C_Green$v_onl$NC"
fi fi
@ -32,6 +35,8 @@ fi
Updater() { Updater() {
if__command rsync if__command rsync
script__versions script__versions
[[ $upd_err ]] \
&& return 1
# Get archive # Get archive
cd /tmp cd /tmp
@ -40,16 +45,16 @@ curl -L -o ${app_name}-main.tar.gz "$repo_tar" 2>/dev/null
&& echo "! Download error" \ && echo "! Download error" \
&& return && return
tar -xzf ${app_name}-main.tar.gz tar -xzf "${app_name}-main.tar.gz"
cd ${app_name}-main
rsync -a "usr/local/bin/" "/usr/local/bin" cd "${app_name}-main"
rsync -a "usr/local/bin/$app_name" "/usr/local/bin/$app_name"
rsync -a --delete "var/lib/$app_name/" "/var/lib/$app_name/" rsync -a --delete "var/lib/$app_name/" "/var/lib/$app_name/"
rsync -a --delete "etc/$app_name/" "/etc/$app_name/" rsync -a --delete "etc/$app_name/" "/etc/$app_name/"
# Check upd -v
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
echo "# $app_name updated to: $v_cur"
rm -rf /tmp/${app_name}-main rm -rf "/tmp/${app_name}-main"
rm -f ${app_name}-main.tar.gz cd /tmp
rm -f "${app_name}-main.tar.gz"
} }