Improved comments

This commit is contained in:
fatalerrors
2021-09-06 14:40:35 +02:00
parent 9f584fcd65
commit 66daa05175
5 changed files with 47 additions and 3 deletions

View File

@@ -7,6 +7,8 @@
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Exit with error
function die()
{
@@ -27,6 +29,8 @@ function die()
}
export -f die
# ------------------------------------------------------------------------------
function terminate()
{
prnt E "$1 reçu, sortie immédiate."
@@ -35,6 +39,9 @@ function terminate()
trap "terminate 'Ctrl + C'" SIGINT
trap "terminate 'SIGTERM'" SIGTERM
# ------------------------------------------------------------------------------
# Function triggered on error
function error()
{
local parent_lineno="$1"
@@ -52,10 +59,11 @@ function error()
fi
#awk 'NR>L-4 && NR<L+4 { printf "%-5d%3s%s\n",NR,(NR==L?">>>":""),$0 }' L=$1 $0
}
# Trigger error function on error
trap "error ${LINENO}; backtrace; exit 255" ERR
# ------------------------------------------------------------------------------
# Print a backtrace
function backtrace
{
@@ -70,6 +78,8 @@ function backtrace
echo "=============================="
}
# ------------------------------------------------------------------------------
# Test and exit if not root (or any UID 0 user)
check_root()
{

View File

@@ -7,6 +7,8 @@
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Standard 16 colors display declaration
export DEFAULTFG="\e[0;39m"
export DEFAULTBG="\e[0;49m"
@@ -82,6 +84,8 @@ export On_IPurple='\e[0;105m'
export On_ICyan='\e[0;106m'
export On_IWhite='\e[0;107m'
# ------------------------------------------------------------------------------
# Affiche le status avec en-tête coloré et timestamp
# (valeur de $1 : I=info, W=warning, E=error, m=des espaces (allignement)
# pas d'entête si autre)

View File

@@ -7,6 +7,8 @@
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Define normalised time display, filename friendly
stdtime()
{
@@ -14,6 +16,8 @@ stdtime()
}
export -f stdtime
# ------------------------------------------------------------------------------
# Backup original installation files
# (or any old files if runned several time on same file)
backupdist()
@@ -35,6 +39,8 @@ backupdist()
}
export -f backupdist
# ------------------------------------------------------------------------------
# Install file to the host (specific first then general)
# Todo: implement wildcard support
installfile()

View File

@@ -7,6 +7,8 @@
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Upgrade package database
pkgupdt()
{
@@ -15,6 +17,8 @@ pkgupdt()
}
export -f pkgupdt
# ------------------------------------------------------------------------------
# Installation
pkginst()
{
@@ -30,6 +34,8 @@ pkginst()
}
export -f pkginst
# ------------------------------------------------------------------------------
# Upgrade
pkgupgd()
{
@@ -38,6 +44,8 @@ pkgupgd()
}
export -f pkgupgd
# ------------------------------------------------------------------------------
# Uninstallation
pkgrem()
{
@@ -53,6 +61,8 @@ pkgrem()
}
export -f pkgrem
# ------------------------------------------------------------------------------
# Cleanup
pkgautorem()
{
@@ -60,3 +70,5 @@ pkgautorem()
$PKG_MAN $COM_AUTOREM
}
export -f pkgautorem
#EOF

View File

@@ -7,6 +7,9 @@
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# Common code controling services scripts
# Syntax exec_serv svcname command
exec_serv()
{
@@ -25,22 +28,31 @@ exec_serv()
$lineexec
}
# ------------------------------------------------------------------------------
# Start one or more service
svc_start()
{
for svc in $@; do
exec_serv $svc start
exec_serv $svc start
done
}
export -f svc_start
# ------------------------------------------------------------------------------
# Restart one or more services
svc_restart()
{
for svc in $@; do
exec_serv $svc restart
exec_serv $svc restart
done
}
export -f svc_restart
# ------------------------------------------------------------------------------
# Stop one or more services
svc_stop()
{
for svc in $@; do