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

View File

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

View File

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

View File

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

View File

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