Added services management, first shot on ssh module
This commit is contained in:
@@ -17,4 +17,4 @@ export RC_SCRIPTS_PATH="/etc/init.d"
|
|||||||
# Init Systemd:
|
# Init Systemd:
|
||||||
#export INIT_COM="systemctl %comm% %srv%"
|
#export INIT_COM="systemctl %comm% %srv%"
|
||||||
# Init Upstart (plus ou moins universel)
|
# Init Upstart (plus ou moins universel)
|
||||||
export INIT_COM="service %srv% %comm%"
|
export INIT_COM="service %srv% %com%"
|
||||||
|
|||||||
43
lib/services.sh
Normal file
43
lib/services.sh
Normal file
@@ -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
|
||||||
@@ -1,9 +1,12 @@
|
|||||||
# NTP
|
# NTP
|
||||||
|
|
||||||
export VER_conf_ntp="0.0.1"
|
export VER_conf_ntp="0.0.2"
|
||||||
|
|
||||||
conf_ntp()
|
conf_ntp()
|
||||||
{
|
{
|
||||||
|
prnt I "Arrêt du service ntp..."
|
||||||
|
svc_stop ntp
|
||||||
|
|
||||||
prnt I "Installation du fichier de configuration de NTP."
|
prnt I "Installation du fichier de configuration de NTP."
|
||||||
dest="/etc/ntp.conf.work"
|
dest="/etc/ntp.conf.work"
|
||||||
backupdist /etc/ntp.conf
|
backupdist /etc/ntp.conf
|
||||||
@@ -15,6 +18,9 @@ conf_ntp()
|
|||||||
sed -i -e "s/@SERVERLIST@/$line/" $dest &&
|
sed -i -e "s/@SERVERLIST@/$line/" $dest &&
|
||||||
echo "# Generated on $(date --rfc-3339=seconds)" >> $dest &&
|
echo "# Generated on $(date --rfc-3339=seconds)" >> $dest &&
|
||||||
mv -fv $dest /etc/ntp.conf
|
mv -fv $dest /etc/ntp.conf
|
||||||
|
|
||||||
|
prnt I "Démarrage du service ntp..."
|
||||||
|
svc_start ntp
|
||||||
}
|
}
|
||||||
|
|
||||||
# NTP
|
# NTP
|
||||||
|
|||||||
35
modules/conf_ssh.sh
Normal file
35
modules/conf_ssh.sh
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user