New version : testing
This commit is contained in:
parent
1b69849f85
commit
760ac36149
|
@ -1,5 +1,5 @@
|
|||
#!/bin/bash
|
||||
# version: 0.0.12
|
||||
# version: 0.0.13
|
||||
# file: upd
|
||||
# Folder: /usr/local/bin
|
||||
# By echolib
|
||||
|
|
|
@ -13,14 +13,17 @@ 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
|
||||
if ! [[ $v_onl ]];then
|
||||
echo "! Unknown available version"
|
||||
upd_err=true
|
||||
return 1
|
||||
fi
|
||||
|
||||
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
|
||||
upd_err=true
|
||||
return 0
|
||||
else
|
||||
echo -e "- $app_name $C_Yellow$v_cur$NC -> $C_Green$v_onl$NC"
|
||||
fi
|
||||
|
@ -32,6 +35,8 @@ fi
|
|||
Updater() {
|
||||
if__command rsync
|
||||
script__versions
|
||||
[[ $upd_err ]] \
|
||||
&& return 1
|
||||
|
||||
# Get archive
|
||||
cd /tmp
|
||||
|
@ -40,16 +45,16 @@ curl -L -o ${app_name}-main.tar.gz "$repo_tar" 2>/dev/null
|
|||
&& echo "! Download error" \
|
||||
&& return
|
||||
|
||||
tar -xzf ${app_name}-main.tar.gz
|
||||
cd ${app_name}-main
|
||||
rsync -a "usr/local/bin/" "/usr/local/bin"
|
||||
tar -xzf "${app_name}-main.tar.gz"
|
||||
|
||||
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 "etc/$app_name/" "/etc/$app_name/"
|
||||
|
||||
# Check
|
||||
v_cur=`awk 'NR==2 {print $3}' "/usr/local/bin/$app_name"`
|
||||
echo "# $app_name updated to: $v_cur"
|
||||
upd -v
|
||||
|
||||
rm -rf /tmp/${app_name}-main
|
||||
rm -f ${app_name}-main.tar.gz
|
||||
rm -rf "/tmp/${app_name}-main"
|
||||
cd /tmp
|
||||
rm -f "${app_name}-main.tar.gz"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue