Files
init.sh/lib/services.sh
2021-07-29 15:58:44 +02:00

51 lines
1.1 KiB
Bash

# ------------------------------------------------------------------------------
# Services manipulation functions
# Copyright (c) 2019-2021 Geoffray Levasseur <fatalerrors@geoffray-levasseur.org>
# ------------------------------------------------------------------------------
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# https://opensource.org/licenses/BSD-3-Clause
# ------------------------------------------------------------------------------
# Syntax exec_serv svcname command
exec_serv()
{
[[ $# -lt 2 ]] && (
prnt E "exec_serv(): Erreur de syntaxe !"
exit 11
)
local svcname=$1 command=$2
shift 2
local lineexec=$(echo $INIT_COM |
sed -e s/%srv%/$svcname/ \
-e s/%com%/$command/)
prnt I "Lancement de la commande $command du services $svcname"
$lineexec
}
svc_start()
{
for svc in $@; do
exec_serv $svc start
done
}
export -f svc_start
svc_restart()
{
for svc in $@; do
exec_serv $svc restart
done
}
export -f svc_restart
svc_stop()
{
for svc in $@; do
exec_serv $svc stop
done
}
export -f svc_stop