# ------------------------------------------------------------------------------ # Services manipulation functions # This file is part of the init.sh project # Copyright (c) 2019-2021 Geoffray Levasseur # ------------------------------------------------------------------------------ # This file is distributed under 3-clause BSD license. # The complete license agreement can be obtained at: # https://opensource.org/licenses/BSD-3-Clause # ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------ # Common code controling services scripts # Syntax exec_serv svcname command exec_serv() { if [[ $# -lt 2 ]]; then prnt E "exec_serv(): Erreur de syntaxe !" exit 11 fi local svcname=$1 command=$2 shift 2 local lineexec=$(echo $INIT_COM | sed -e s/%srv%/$svcname/ \ -e s/%com%/$command/) unset svcname command prnt I "Lancement de la commande $command du services $svcname" $lineexec unset lineexec } export exec_serv # ------------------------------------------------------------------------------ # Start one or more service svc_start() { local svc= for svc in $@; do exec_serv $svc start done unset svc } export -f svc_start # ------------------------------------------------------------------------------ # Restart one or more services svc_restart() { local svc= for svc in $@; do exec_serv $svc restart done unset svc } export -f svc_restart # ------------------------------------------------------------------------------ # Stop one or more services svc_stop() { local svc= for svc in $@; do exec_serv $svc stop done unset svc } export -f svc_stop # EOF