Compare commits
5 Commits
v3.3.1
...
94e7e79c76
| Author | SHA1 | Date | |
|---|---|---|---|
| 94e7e79c76 | |||
| 55e88bd018 | |||
|
|
18f1bc1543 | ||
|
|
0d7c7e9ab7 | ||
|
|
64fecf16fb |
@@ -33,24 +33,68 @@
|
|||||||
# * OF SUCH DAMAGE.
|
# * OF SUCH DAMAGE.
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
export UPDT_URL="https://git.geoffray-levasseur.org/fatalerrors/profile"
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Check for profile updates
|
# Check for profile updates
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
check_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..."
|
disp I "Checking for updates..."
|
||||||
local vfile="/tmp/version"
|
local vfile="/tmp/version"
|
||||||
wget "$UPDT_URL/version" -O $vfile 2&>1 /dev/null || {
|
wget "$UPDT_URL/version" -O $vfile 2&>1 /dev/null || {
|
||||||
disp E "Can\'t download information file, impossible to proceed!"
|
disp E "Can\'t download version file, impossible to proceed!"
|
||||||
return 1
|
return 5
|
||||||
}
|
}
|
||||||
if [[ -s /tmp/version ]]; then
|
if [[ -s /tmp/version ]]; then
|
||||||
local lastver=$(cat /tmp/version)
|
local lastver=$(cat /tmp/version)
|
||||||
if [[ $lastver != $PROFVERSION ]]; then
|
if [[ $lastver != $PROFVERSION ]]; then
|
||||||
disp I "You have version $PROFVERSION installed. Version $lastver is available."
|
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
|
fi
|
||||||
|
rm -f $vfile
|
||||||
else
|
else
|
||||||
disp E "Impossible to read temporary file, impossible to proceed."
|
disp E "Impossible to read temporary file, impossible to proceed."
|
||||||
fi
|
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
|
||||||
|
|||||||
16
profile.sh
16
profile.sh
@@ -35,7 +35,7 @@
|
|||||||
# * OF SUCH DAMAGE.
|
# * OF SUCH DAMAGE.
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
if [[ ! $(echo $SHELL | grep bash) ]]; then
|
if [[ ! $SHELL =~ bash|zsh ]]; then
|
||||||
echo "That environmet script is designed to be used with bash or zsh being the shell."
|
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 ;)!"
|
echo "Please consider using bash or zsh instead, or patch me ;)!"
|
||||||
return 1
|
return 1
|
||||||
@@ -80,9 +80,13 @@ pathappend ()
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Store script's path (realpath -s resolve symlinks if profile.sh is a symlink)
|
# Store script's path (realpath -s resolve symlinks if profile.sh is a symlink)
|
||||||
|
if [[ -z $PROFILE_PATH ]]; then
|
||||||
export MYPATH=$(dirname $(realpath -s $0))
|
export MYPATH=$(dirname $(realpath -s $0))
|
||||||
|
else
|
||||||
|
export MYPATH=$PROFILE_PATH
|
||||||
|
fi
|
||||||
if [[ ! -e $MYPATH/profile.sh ]]; then
|
if [[ ! -e $MYPATH/profile.sh ]]; then
|
||||||
echo "[ Warning ] Path detection failed, using pwd..."
|
echo "[ Warning ] Path detection failed, trying to use pwd..."
|
||||||
MYPATH=$(pwd)
|
MYPATH=$(pwd)
|
||||||
if [[ ! -e $MYPATH/profile.sh ]]; then
|
if [[ ! -e $MYPATH/profile.sh ]]; then
|
||||||
echo "[ Error ] Impossible to determine installation path, pretty much nothing will work."
|
echo "[ Error ] Impossible to determine installation path, pretty much nothing will work."
|
||||||
@@ -102,6 +106,10 @@ fi
|
|||||||
[[ -d ~/bin ]] && pathappend ~/bin
|
[[ -d ~/bin ]] && pathappend ~/bin
|
||||||
[[ -d ~/.local/bin ]] && pathappend ~/.local/bin
|
[[ -d ~/.local/bin ]] && pathappend ~/.local/bin
|
||||||
|
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Default values are set here and will be overloaded with config file if any
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Set bash history
|
# Set bash history
|
||||||
export HISTSIZE=50000
|
export HISTSIZE=50000
|
||||||
export HISTIGNORE="&:[bf]g:exit"
|
export HISTIGNORE="&:[bf]g:exit"
|
||||||
@@ -125,14 +133,14 @@ export DEFAULT_CITY="Toulouse"
|
|||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
# Load global configuration
|
# Load global configuration
|
||||||
[[ -f $MYPATH/etc/profile.conf ]] && . ~/.profile.conf
|
[[ -f $MYPATH/etc/profile.conf ]] && . $MYPATH/etc/profile.conf
|
||||||
|
|
||||||
# Load personal configuration
|
# Load personal configuration
|
||||||
[[ -f ~/.profile.conf ]] && . ~/.profile.conf
|
[[ -f ~/.profile.conf ]] && . ~/.profile.conf
|
||||||
|
|
||||||
# Load module scripts
|
# Load module scripts
|
||||||
for script in $MYPATH/profile.d/*.sh ; do
|
for script in $MYPATH/profile.d/*.sh ; do
|
||||||
if [ -r $script ] ; then
|
if [[ -r $script ]]; then
|
||||||
. $script
|
. $script
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
Reference in New Issue
Block a user