diff --git a/Integration_domain/apt-update.sh b/Integration_domain/apt-update.sh new file mode 100644 index 0000000..323f419 --- /dev/null +++ b/Integration_domain/apt-update.sh @@ -0,0 +1,33 @@ +#!/bin/bash +#======================================================================= +# FILE: ~apt-update.sh +# USAGE: ./~apt-update.sh +# DESCRIPTION: script permettant la mise a jour masquée des paquets du poste +# +# OPTIONS: --- +# REQUIREMENTS: --- +# BUGS: --- +# NOTES: --- +# AUTHOR: Maxime Tertrais +# COMPANY: Operis +# CREATED: 18/10/2024 +# REVISION: --- +#======================================================================= +##Définition des variables +log_file="/var/log/apt-logs.log" +#======================================================================= +##Définition des fonctions + +#======================================================================= +##Script +main() ( + { + echo "Mise à jour système: $(date)" + apt update -y + apt upgrade -y + apt autoremove -y + echo '---------------------------------------' + } >> $log_file 2>&1 +) + +main "$@" \ No newline at end of file diff --git a/Integration_domain/integration_domain.sh b/Integration_domain/integration_domain.sh index 33d3847..974f5b1 100644 --- a/Integration_domain/integration_domain.sh +++ b/Integration_domain/integration_domain.sh @@ -26,6 +26,10 @@ domain="operis.champlan" Allowed_GG=(GRP_ADM_POSTE GRP_ADM_DOM GDL_Orvault GDL_LaRéunion GDL_Grenoble GDL_Champlan GDL_Bordeaux) local_admin="operis" GG_admin="grp_adm_poste" +cron_file="/etc/crontab" +cron_job="0 9 * * * bash /root/apt-update.sh" +script_auto_update_src="$folder/Integration_domain/apt-update.sh" +script_auto_update_dst="/root/apt-update.sh" #======================================================================= ##Définition des fonctions func_dependances(){ @@ -151,6 +155,20 @@ func_root(){ fi } +func_cron(){ + sudo crontab -l | grep -F "$cron_job" > /dev/null + if [ $? -eq 0 ]; then + echo "Le job cron existe déjà dans la crontab de root." + else + # tranfert du script d'update dans le dossier /root/ + mv $script_auto_update_src $script_auto_update_dst + chown root:root $script_auto_update_dst + chmod +x $script_auto_update_dst + # Ajouter le nouveau job cron + (sudo crontab -l; echo "$cron_job") | sudo crontab - + fi +} + #======================================================================= ###Script