Initial version update support, changed versioning code, add installation path detection

This commit is contained in:
2023-02-03 07:55:06 +01:00
parent dc64123fd9
commit c2a0ef0bd2
3 changed files with 72 additions and 6 deletions

56
profile.d/updates.sh Normal file
View File

@@ -0,0 +1,56 @@
# ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details.
#
# * Redistribution and use in source and binary forms,
# * with or without modification, are permitted provided
# * that the following conditions are met:
# *
# * Redistributions of source code must retain the above
# * copyright notice, this list of conditions and the
# * following disclaimer.
# *
# * Redistributions in binary form must reproduce the above
# * copyright notice, this list of conditions and the following
# * disclaimer in the documentation and/or other materials
# * provided with the distribution.
# *
# * Neither the name of the copyright holder nor the names
# * of any other contributors may be used to endorse or
# * promote products derived from this software without
# * specific prior written permission.
# *
# * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
# * CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
# * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# * OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Check for profile updates
# ------------------------------------------------------------------------------
check_updates()
{
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
}
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."
fi
else
disp E "Impossible to read temporary file, impossible to proceed."
fi
}

View File

@@ -35,10 +35,6 @@
# * OF SUCH DAMAGE.
# ------------------------------------------------------------------------------
export PROFVERSION="3.2.3"
export DEFAULT_CITY="Toulouse"
if [[ ! $(echo $SHELL | grep bash) ]]; then
echo "That environmet script is designed to be used with bash or zsh being the shell."
echo "Please consider using bash or zsh instead, or patch me ;)!"
@@ -83,6 +79,14 @@ pathappend ()
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Store script's path (realpath -s resolve symlinks if profile.sh is a symlink)
export MYPATH=$(dirname $(realpath -s $0))
if [[ ! -s $MYPATH/version ]]; then
echo "Impossible to determine running version of profile, your installation might be broken."
fi
export PROFVERSION=$(cat $MYPATH/version)
# Build PATH environment variable
if [[ $EUID -eq 0 ]] ; then
pathappend /sbin:/usr/sbin
@@ -106,16 +110,21 @@ export CFLAGS="-O2 -pipe -march=native"
export MAKEFLAGS='-j12'
export PKGSOURCES='/share/src/archives'
# Default city for weather forcast
export DEFAULT_CITY="Toulouse"
# ------------------------------------------------------------------------------
# Default values could be altered after this line
# ------------------------------------------------------------------------------
# Load global configuration
[[ -f $MYPATH/etc/profile.conf ]] && . ~/.profile.conf
# Load personal configuration
[[ -f ~/.profile.conf ]] && . ~/.profile.conf
# Execute optionnal config script if any
for script in ~/profile.d/*.sh ; do
# Load module scripts
for script in $MYPATH/profile.d/*.sh ; do
if [ -r $script ] ; then
. $script
fi

1
version Normal file
View File

@@ -0,0 +1 @@
3.3.0