Compare commits
2 Commits
18f1bc1543
...
94e7e79c76
| Author | SHA1 | Date | |
|---|---|---|---|
| 94e7e79c76 | |||
| 55e88bd018 |
@@ -33,24 +33,68 @@
|
||||
# * OF SUCH DAMAGE.
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
export UPDT_URL="https://git.geoffray-levasseur.org/fatalerrors/profile"
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Check for profile updates
|
||||
# ------------------------------------------------------------------------------
|
||||
check_updates()
|
||||
{
|
||||
if [[ $1 == "-q" ]]; then
|
||||
# Quiet mode is mostly used internally when profile_upgrade is called
|
||||
quiet=1
|
||||
fi
|
||||
disp I "Checking for updates..."
|
||||
local vfile="/tmp/version"
|
||||
wget "$UPDT_URL/version" -O $vfile 2&>1 /dev/null || {
|
||||
disp E "Can\'t download information file, impossible to proceed!"
|
||||
return 1
|
||||
disp E "Can\'t download version file, impossible to proceed!"
|
||||
return 5
|
||||
}
|
||||
if [[ -s /tmp/version ]]; then
|
||||
local lastver=$(cat /tmp/version)
|
||||
if [[ $lastver != $PROFVERSION ]]; then
|
||||
disp I "You have version $PROFVERSION installed. Version $lastver is available."
|
||||
disp I "You should upgrade to last version when possible."
|
||||
[[ $quiet ]] && disp I "You should upgrade to last version when possible."
|
||||
result=0
|
||||
else
|
||||
disp I "Your version is up-to-date."
|
||||
result=1
|
||||
fi
|
||||
rm -f $vfile
|
||||
else
|
||||
disp E "Impossible to read temporary file, impossible to proceed."
|
||||
fi
|
||||
unset lastver vfile
|
||||
return $result
|
||||
}
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
# Apply update to profile
|
||||
# ------------------------------------------------------------------------------
|
||||
profile_upgrade()
|
||||
{
|
||||
if [[ $(check_updates -q) -eq 0 ]]; then
|
||||
if [[ -s $MYPATH/profile.sh ]]; then
|
||||
disp E "Installation path detection failed, cannot upgrade automatically."
|
||||
return 1
|
||||
fi
|
||||
if [[ -d $MYPATH/.git ]]; then
|
||||
disp I "Git installation detected, applying git pull."
|
||||
local curdir=$(pwd)
|
||||
cd $MYPATH
|
||||
git pull
|
||||
if [[ $? -ne 0 ]]; then
|
||||
disp E "Git pull failed, upgrade not applyed."
|
||||
else
|
||||
disp I "Successfully upgraded using git."
|
||||
disp I "You should now logout and login again to enjoy new profile."
|
||||
cd $curdir
|
||||
fi
|
||||
else
|
||||
disp I "Applying traditionnal upgrade..."
|
||||
# TODO
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# EOF
|
||||
|
||||
Reference in New Issue
Block a user