- Ajout de la mise à jour automatique du script

This commit is contained in:
Frogg 2026-05-12 14:53:06 +02:00
parent 292792195a
commit 1ed7cf6845
6 changed files with 71 additions and 28 deletions

View File

@ -5,11 +5,10 @@ WELCOME_SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
#region INCLUDES
. "${WELCOME_SCRIPT_PATH}/config/config_colors.sh"
. "${WELCOME_SCRIPT_PATH}/inc/vars.sh"
#. "${WELCOME_SCRIPT_PATH}/inc/vars.sh"
. "${WELCOME_SCRIPT_PATH}/func/common.sh"
. "${WELCOME_SCRIPT_PATH}/func/message_display.sh"
. "${WELCOME_SCRIPT_PATH}/func/system_info.sh"
. "${WELCOME_SCRIPT_PATH}/func/git.sh"
#endregion
##################
@ -58,7 +57,7 @@ display_dashboard
### UPDATE SCRIPT ###
######################
script_update
. "${WELCOME_SCRIPT_PATH}/script/update.sh"
################
### INSTALL ###

13
TODO.md
View File

@ -1,3 +1,6 @@
>>> AJOUTER LE SCRIPT D UPDATE DANS LE CRON 1 fois par jour ?
BUG SMTP PROXMOX
# BUG SCRIPT
@ -6,14 +9,12 @@ BUG SMTP PROXMOX
mkdir: cannot create directory /etc/ssl/wildcard: Permission denied
/etc/profile.d/func/deb_sys.sh: line 604: step: command not found
🚀 Configuration de l'heure (Paris) et du NTP...
Failed to create bus connection: No such file or directory
🚀 Fuseau horaire réglé sur Europe/Paris.
Failed to create bus connection: No such file or directory
Failed to restart systemd-timesyncd.service: Unit systemd-timesyncd.service not found.
--- Changer le Hostname ---
Nom actuel : zabbix
Nouveau Hostname (FQDN recommandé, ex: machine.domaine.com) : zabbix.server.home
@ -21,16 +22,8 @@ Failed to create bus connection: No such file or directory
> PB GIT SUR LE 100 avec les sync a voir
## Passer à ZABBIX
> mettre le script
>
> mettre les infos dans le read me pour l install du depart

View File

@ -6,6 +6,7 @@ CONFIG_DEB_INSTALL_DEFAULT_CA_SERVER="192.168.0.110"
CONFIG_DEB_INSTALL_DEFAULT_CA_WILDCARD="*.server.home"
CONFIG_DEB_INSTALL_DEFAULT_CA_SERVICES="gitea nginx apache2 mysql postgresql jellyfin"
CONFIG_DEB_INSTALL_DEFAULT_CA_CRON="STEP-CA-RENEWAL"
CONFIG_DEB_INSTALL_CRON_UPDATE="CONFIG_DEB_INSTALL_CRON_UPDATE"
CONFIG_DEB_INSTALL_JSON='[
{"id": "git_pkg", "label": "Installer Git", "type": "pkg", "params": "git"},
@ -18,6 +19,7 @@ CONFIG_DEB_INSTALL_JSON='[
{"id": "apparmor_pkg", "label": "Installer AppArmor (Paquets)", "type": "pkg", "params": "apparmor"},
{"id": "fail2ban_pkg", "label": "Installer Fail2Ban", "type": "pkg", "params": "fail2ban"},
{"id": "ufw_pkg", "label": "Installer Firewall (UFW)", "type": "pkg", "params": "ufw"},
{"id": "script_update", "label": "Installer script de mise à jour automatique", "type": "sys", "params": "script_update"},
{"id": "gen_ssh_key", "label": "Creer une clé RSA pour SSH", "type": "sys", "params": "gen_ssh_key"},
{"id": "ipv6", "label": "Désactiver IPv6", "type": "sys", "params": "ipv6"},
{"id": "motd", "label": "Désactiver les messages MOTD", "type": "sys", "params": "motd"},

View File

@ -12,6 +12,23 @@ check_deb_status() {
esac
}
update_cron_marker()
{
# ------------------------------------------------------------------
# Installation du cron
# ------------------------------------------------------------------
local marker="# $1"
(
crontab -l 2>/dev/null | sed "/^${marker//\//\\/}$/,/^${marker//\//\\/}$/d"
echo "$marker"
echo "$2"
echo "$marker"
) | crontab -
msg_success "Tâche cron installée avec succès."
}
do_deb_install_action() {
local type="$1" params="$2" func
case "$type" in
@ -127,6 +144,32 @@ check_deb_sys_cert_install(){
fi
}
check_deb_sys_script_update(){
local MARKER="# $CONFIG_DEB_INSTALL_CRON_UPDATE"
if crontab -l 2>/dev/null | grep -q "$MARKER"; then
#return 0
return 1
else
return 1
fi
}
do_deb_sys_script_update(){
local full_command script_path
WELCOME_SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &>/dev/null && pwd)"
script_path="${WELCOME_SCRIPT_PATH}/script/update.sh"
chmod +x "$script_path"
full_command="${WELCOME_SCRIPT_PATH}/script/update.sh >> /var/log/cert-renew.log 2>&1"
## All days at 3AM
update_cron_marker "$CONFIG_DEB_INSTALL_CRON_UPDATE" "0 3 * * * $full_command"
}
do_deb_sys_motd(){
$SUDO chmod -x /etc/update-motd.d/*
msg_success "Les fichiers dans /etc/update-motd.d/ ne sont plus executable"
@ -226,7 +269,6 @@ do_deb_sys_clone_ssh_key() {
fi
}
do_deb_sys_ntp() {
msg_info "Configuration de l'heure (Paris) et du NTP..."
@ -785,16 +827,8 @@ do_deb_sys_cert_install(){
# ------------------------------------------------------------------
# Installation du cron
# ------------------------------------------------------------------
local marker="# $CONFIG_DEB_INSTALL_DEFAULT_CA_CRON"
(
crontab -l 2>/dev/null | sed "/^${marker//\//\\/}$/,/^${marker//\//\\/}$/d"
echo "$marker"
echo "0 0 1 * * $full_command"
echo "$marker"
) | crontab -
msg_success "Tâche cron installée avec succès."
update_cron_marker "$CONFIG_DEB_INSTALL_DEFAULT_CA_CRON" "0 0 1 * * $full_command"
# ------------------------------------------------------------------
# Exécution immédiate de la génération du PFX

View File

@ -61,14 +61,16 @@ gitssl() {
}
script_update() {
local BRANCH LOCAL REMOTE
local BRANCH LOCAL REMOTE current_path
current_path=$(pwd)
cd "$WELCOME_SCRIPT_PATH" || return 2
git fetch origin >/dev/null 2>&1
if [ $? -ne 0 ]; then
msg_error "Erreur lors du Fetch"
cd ~
cd "$current_path"
return 3
fi
@ -77,7 +79,7 @@ script_update() {
REMOTE=$(git rev-parse origin/"$BRANCH")
if [ "$LOCAL" = "$REMOTE" ]; then
cd ~
cd "$current_path"
return 0
fi
@ -87,11 +89,11 @@ script_update() {
if [ $? -eq 0 ]; then
msg_success "Les script de welcome a été mis à jour !! relancer le ssh pour profiter des nouvelles fonctionnalités"
echo ""
cd ~
cd "$current_path"
return 1
else
msg_error "Erreur lors de la mise à jour du script"
cd ~
cd "$current_path"
return 4
fi
}

13
script/update.sh Normal file
View File

@ -0,0 +1,13 @@
#!/bin/bash
WELCOME_SCRIPT_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." &>/dev/null && pwd)"
#region INCLUDES
. "${WELCOME_SCRIPT_PATH}/config/config_colors.sh"
#. "${WELCOME_SCRIPT_PATH}/inc/vars.sh"
. "${WELCOME_SCRIPT_PATH}/func/common.sh"
. "${WELCOME_SCRIPT_PATH}/func/message_display.sh"
. "${WELCOME_SCRIPT_PATH}/func/git.sh"
#endregion
script_update