13 Commits

19 changed files with 791 additions and 545 deletions

View File

@@ -7,6 +7,17 @@ Current version from Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
Version history: Version history:
------------------------------------------------------------------------------ ------------------------------------------------------------------------------
# 24/02/2022 v3.3.1
Fixed version detection
Added "busy" function
Fixed use of library functions before it's loaded
# 28/11/2022 v3.3.0
Initial version update support
Changed versioning code
Added installation path detection
# 28/11/2022 v3.2.3 # 28/11/2022 v3.2.3
Made proper readme file, to improve Made proper readme file, to improve

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -170,7 +171,7 @@ taz ()
local procopt="" local procopt=""
[[ $2 -gt 1 ]] && [[ $2 -gt 1 ]] &&
disp W "lzip doesn't support multithreading, falling back to 1 thread." && disp W "lzip doesn't support multithreading, falling back to 1 thread." &&
disp W "Consitder installing plzip to obtain multithreading abilities." disp W "Consider installing plzip to obtain multithreading abilities."
} }
[[ $4 ]] && local verb="-vv" [[ $4 ]] && local verb="-vv"
@@ -359,3 +360,6 @@ taz ()
unset QUIET unset QUIET
} }
export -f taz export -f taz
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -63,7 +64,6 @@ function error ()
return $errcode return $errcode
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Activate or deactivate error trapping to display backtrace # Activate or deactivate error trapping to display backtrace
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -105,3 +105,6 @@ settrace ()
unset status unset status
} }
export -f settrace export -f settrace
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -111,7 +112,6 @@ export On_IPurple='\e[0;105m'
export On_ICyan='\e[0;106m' export On_ICyan='\e[0;106m'
export On_IWhite='\e[0;107m' export On_IWhite='\e[0;107m'
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Display a message # Display a message
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -146,3 +146,6 @@ disp()
unset heads unset heads
} }
export -f disp export -f disp
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -47,7 +48,6 @@ expandlist()
echo $result echo $result
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Clean a directory or a tree from temporary or backup files # Clean a directory or a tree from temporary or backup files
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -100,7 +100,7 @@ clean ()
unset recursive force unset recursive force
for dir in $dirlist; do for dir in $dirlist; do
local dellist=$(find $dir $findopt -type f -name "*~" -o -name "#*#" \ local dellist=$(find "$dir" $findopt -type f -name "*~" -o -name "#*#" \
-o -name "*.bak" -o -name ".~*#") -o -name "*.bak" -o -name ".~*#")
for f in $dellist; do for f in $dellist; do
if [[ ! $outshell ]]; then if [[ ! $outshell ]]; then
@@ -114,7 +114,6 @@ clean ()
} }
export -f clean export -f clean
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Create a directory then goes inside # Create a directory then goes inside
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -125,11 +124,10 @@ mcd ()
disp E "Usage: mcd <directory>" disp E "Usage: mcd <directory>"
return 1 return 1
fi fi
mkdir -pv $1 && cd $1 mkdir -pv "$1" && cd "$1" || echo "Failed create or change directory."
} }
export -f mcd export -f mcd
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Rename all files in current directory to replace spaces with _ # Rename all files in current directory to replace spaces with _
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -212,3 +210,6 @@ rmspc ()
unset lst substchar verb shell newf command mvopt unset lst substchar verb shell newf command mvopt
} }
export -f rmspc export -f rmspc
# ------------------------------------------------------------------------------
# EOF

52
profile.d/fun.sh Normal file
View File

@@ -0,0 +1,52 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# 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.
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Make non-IT peoples think you're busy doing something hard
# ------------------------------------------------------------------------------
busy()
{
if [[ -n $1 ]]; then
local pattern="$@"
else
local pattern="ca fe"
fi
cat /dev/urandom | hexdump -C | grep "$pattern"
unset pattern
}
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -66,3 +67,5 @@ EOF
} }
export -f help export -f help
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -42,7 +43,6 @@ ver ()
} }
export -f ver export -f ver
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Display weather of the given city (or default one) # Display weather of the given city (or default one)
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -57,7 +57,6 @@ meteo ()
} }
export -f meteo export -f meteo
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Display system general information # Display system general information
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -88,3 +87,6 @@ showinfo()
fi fi
} }
export -f showinfo export -f showinfo
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -68,3 +69,6 @@ setus ()
export LC_ALL=en_US.UTF-8 export LC_ALL=en_US.UTF-8
} }
export -f setus export -f setus
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -47,8 +48,8 @@ isipv4 ()
IFS="." IFS="."
ip=($ip) ip=($ip)
IFS=$old_ifs IFS=$old_ifs
if [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \ if [[ ${ip[0]} -le 255 && ${ip[1]} -le 255 &&
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]; then ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]; then
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
disp "The given IPv4 is valid." disp "The given IPv4 is valid."
fi fi
@@ -62,7 +63,6 @@ isipv4 ()
} }
export -f isipv4 export -f isipv4
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Determine if parameter is a valid IPv4 address # Determine if parameter is a valid IPv4 address
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -82,3 +82,6 @@ isipv6 ()
return 1 return 1
} }
export -f isipv6 export -f isipv6
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -36,7 +37,7 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Look for a package within installed one # Look for a package within installed one
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
dpkgs () pkgs()
{ {
local count=0 local count=0
for opt in $@; do for opt in $@; do
@@ -68,13 +69,15 @@ dpkgs ()
disp E "Please specify a package name, without space, eventually partial." && disp E "Please specify a package name, without space, eventually partial." &&
return 1 return 1
if [[ $(command -v dpkg >/dev/null 2>&1) ]]; then command -v dpkg >/dev/null 2>&1 && local cmd="dpkg -l"
dpkg -l | grep $pkg command -v rpm >/dev/null 2>&1 && local cmd="rpm -qa"
elif [[ $(command -v rpm >/dev/null 2>&1) ]]; then if [[ -z $cmd ]]; then
rpm -qa | grep $pkg
else
disp E "No usable package manager seems unavialable." disp E "No usable package manager seems unavialable."
return 2 return 2
fi fi
$cmd | grep $pkg
} }
export -f dpkgs export -f pkgs
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/bin/bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -38,11 +39,10 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
ppg() ppg()
{ {
ps -edf | grep $@ | grep -v "grep $@" ps -edf | grep "$@" | grep -v "grep $@"
} }
export -f ppg export -f ppg
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Get PID list of the given process name # Get PID list of the given process name
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -62,14 +62,33 @@ gpid ()
} }
export -f gpid export -f gpid
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Kill all processes owned by the given users # Kill all processes owned by the given users
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
ku() ku()
{ {
for u in $@; do for u in $@; do
killall -u $u killall -u "$u"
done done
} }
export -f ku export -f ku
# ------------------------------------------------------------------------------
# Kill all children of a process then the process
# ------------------------------------------------------------------------------
kt()
{
[[ -z $1 ]] && echo -e "Usage:\n\tkt <pid> [kill_options]"
local parent_pid="$1" children_pids
shift
children_pids=$(pgrep -P "$parent_pid")
for pid in $children_pids; do
kill_tree "$pid" "$@"
done
kill "$@" "$parent_pid"
}
# ------------------------------------------------------------------------------
# EOF

View File

@@ -123,3 +123,6 @@ set_prompt ()
# the text color to the default. # the text color to the default.
PS1+="$ICyan\\w \\\$$Default " PS1+="$ICyan\\w \\\$$Default "
} }
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -120,12 +121,11 @@ genpwd()
done done
# Function selecting a random caracter from the list in parameter # Function selecting a random caracter from the list in parameter
pickcar() pickcar() {
{
# When a character is picked we check if it's not appearing already twice # When a character is picked we check if it's not appearing already twice
# elsewhere, we choose an other char, to compensate weak bash randomizer # elsewhere, we choose an other char, to compensate weak bash randomizer
while [[ -z $char ]]; do while [[ -z $char ]]; do
local char=$(echo ${1:RANDOM%${#1}:1} $RANDOM) local char="${1:RANDOM%${#1}:1} $RANDOM"
if [[ $(awk -F"$char" '{print NF-1}' <<<"$picked") -gt $occurs ]]; then if [[ $(awk -F"$char" '{print NF-1}' <<<"$picked") -gt $occurs ]]; then
unset char unset char
fi fi
@@ -184,3 +184,6 @@ genpwd()
done done
} }
export -f genpwd export -f genpwd
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -54,7 +55,6 @@ rain()
local X=0 Y=0 drop_length=0 rain_drop=0 local X=0 Y=0 drop_length=0 rain_drop=0
local max_rain_width=0 new_rain_odd=0 falling_odd=0 local max_rain_width=0 new_rain_odd=0 falling_odd=0
sigwinch() { sigwinch() {
term_width=$(tput cols) term_width=$(tput cols)
term_height=$(tput lines) term_height=$(tput lines)
@@ -152,3 +152,6 @@ rain()
trap - WINCH trap - WINCH
} }
export -f rain export -f rain
# ------------------------------------------------------------------------------
# EOF

View File

@@ -1,3 +1,4 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org> # Copyright (c) 2013-2022 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# Protected by the BSD3 license. Please read bellow for details. # Protected by the BSD3 license. Please read bellow for details.
@@ -77,7 +78,6 @@ rmhost ()
} }
export -f rmhost export -f rmhost
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Login root via SSH on the given machine # Login root via SSH on the given machine
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@@ -103,3 +103,6 @@ ssr ()
ssh -Y root@$srv $@ ssh -Y root@$srv $@
} }
export -f ssr export -f ssr
# ------------------------------------------------------------------------------
# EOF

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

@@ -0,0 +1,102 @@
#!/usr/bin/env bash
# ------------------------------------------------------------------------------
# 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.
# ------------------------------------------------------------------------------
export UPDT_URL="https://git.geoffray-levasseur.org/fatalerrors/profile/raw/branch/master"
# ------------------------------------------------------------------------------
# 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 >/dev/null 2>&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."
[[ $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

View File

@@ -35,11 +35,7 @@
# * OF SUCH DAMAGE. # * OF SUCH DAMAGE.
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
export PROFVERSION="3.2.3" if [[ ! $SHELL =~ bash|zsh ]]; then
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 "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
@@ -76,13 +72,31 @@ pathappend ()
export $pathvar="${!pathvar:+${!pathvar}:}$1" export $pathvar="${!pathvar:+${!pathvar}:}$1"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# ********************************** MAIN PROGRAM ****************************** # ********************************** MAIN PROGRAM ******************************
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# 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))
else
export MYPATH=$PROFILE_PATH
fi
if [[ ! -e $MYPATH/profile.sh ]]; then
echo "[ Warning ] Path detection failed, trying to use pwd..."
MYPATH=$(pwd)
if [[ ! -e $MYPATH/profile.sh ]]; then
echo "[ Error ] Impossible to determine installation path, pretty much nothing will work."
fi
fi
if [[ ! -s $MYPATH/version ]]; then
echo "[ Warning ] Impossible to determine running version of profile, your installation might be broken."
fi
export PROFVERSION=$(cat $MYPATH/version)
# Build PATH environment variable # Build PATH environment variable
if [[ $EUID -eq 0 ]]; then if [[ $EUID -eq 0 ]]; then
pathappend /sbin:/usr/sbin pathappend /sbin:/usr/sbin
@@ -91,6 +105,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"
@@ -106,17 +124,22 @@ export CFLAGS="-O2 -pipe -march=native"
export MAKEFLAGS='-j12' export MAKEFLAGS='-j12'
export PKGSOURCES='/share/src/archives' export PKGSOURCES='/share/src/archives'
# Default city for weather forcast
export DEFAULT_CITY="Toulouse"
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Default values could be altered after this line # Default values could be altered after this line
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Load global configuration
[[ -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
# Execute optionnal config script if any # Load module scripts
for script in ~/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

1
version Normal file
View File

@@ -0,0 +1 @@
3.3.2