diff --git a/conf/includes/debian.conf.sh b/conf/includes/debian.conf.sh index a113c9f..7d980b7 100644 --- a/conf/includes/debian.conf.sh +++ b/conf/includes/debian.conf.sh @@ -17,4 +17,4 @@ export RC_SCRIPTS_PATH="/etc/init.d" # Init Systemd: #export INIT_COM="systemctl %comm% %srv%" # Init Upstart (plus ou moins universel) -export INIT_COM="service %srv% %comm%" +export INIT_COM="service %srv% %com%" diff --git a/lib/services.sh b/lib/services.sh new file mode 100644 index 0000000..99a0e17 --- /dev/null +++ b/lib/services.sh @@ -0,0 +1,43 @@ +# Services manipulation functions + +# 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 diff --git a/modules/conf_ntp.sh b/modules/conf_ntp.sh index 8fdfa18..42c0547 100644 --- a/modules/conf_ntp.sh +++ b/modules/conf_ntp.sh @@ -1,9 +1,12 @@ # NTP -export VER_conf_ntp="0.0.1" +export VER_conf_ntp="0.0.2" conf_ntp() { + prnt I "Arrêt du service ntp..." + svc_stop ntp + prnt I "Installation du fichier de configuration de NTP." dest="/etc/ntp.conf.work" backupdist /etc/ntp.conf @@ -15,6 +18,9 @@ conf_ntp() sed -i -e "s/@SERVERLIST@/$line/" $dest && echo "# Generated on $(date --rfc-3339=seconds)" >> $dest && mv -fv $dest /etc/ntp.conf + + prnt I "Démarrage du service ntp..." + svc_start ntp } # NTP diff --git a/modules/conf_ssh.sh b/modules/conf_ssh.sh new file mode 100644 index 0000000..d002a5a --- /dev/null +++ b/modules/conf_ssh.sh @@ -0,0 +1,35 @@ +# Configuration des client et serveur SSH + +export VER_conf_ssh="0.0.1" + +conf_ssh() +{ + prnt I "Installation du serveur OpenSSH..." + pkginst openssh-server + + prnt I "Arrêt du service SSH..." + svc_stop ssh + + prnt I "Installation des fichiers de configuration de SSH..." + for f in /etc/ssh/ssh{,d}_config; do + dest="$f.work" + backupdist $f + installfile $(basename $f) $dest + + # A finir + + echo "# Generated on $(date --rfc-3339=seconds)" >> $dest && + mv -fv $dest $f + done + + prnt I "Démarrage du sevice ssh..." + svc_start ssh +} + +precheck_conf_ssh() +{ + # A finir +} + +export -f conf_ssh +export -f precheck_conf_ssh