WIP add scripts
This commit is contained in:
parent
2fd6ee2186
commit
2e94aefbc0
27
files/check_crontab.sh
Executable file
27
files/check_crontab.sh
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
cron=/etc/crontab
|
||||||
|
md5old=/etc/crontab_save
|
||||||
|
|
||||||
|
log=/var/log/check_crontab.log
|
||||||
|
|
||||||
|
printf "##### %s #####\n" "$(date)" >>$log
|
||||||
|
if [ ! -f $md5old ]
|
||||||
|
then
|
||||||
|
printf "Error: %s don't exist\nCreating %s ...\n" "$md5old" "$md5old" >>$log
|
||||||
|
md5sum $cron >$md5old
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! -s $md5old ]
|
||||||
|
then
|
||||||
|
printf "Error: %s is empty\nadding md5 hash to %s ...\n" "$md5old" "$md5old" >>$log
|
||||||
|
md5sum $cron >$md5old
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if [ ! $(md5sum -c $md5old 2>/dev/null | grep $cron | cut -d' ' -f2) = "OK" ]
|
||||||
|
then
|
||||||
|
printf "Error: %s modified\nsending mail ...\n" >>$log
|
||||||
|
echo "crontab has changed T_T" | mail -s "!!! PANIC !!! PANIC !!!! PANIC !!!" root
|
||||||
|
else
|
||||||
|
printf "file OK\n" >>$log
|
||||||
|
fi
|
@ -26,6 +26,5 @@ SHELL=/bin/sh
|
|||||||
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
|
||||||
|
|
||||||
# m h dom mon dow command
|
# m h dom mon dow command
|
||||||
00 4 * * * root /usr/sbin/update_script.sh
|
00 4 * * 0 root /usr/sbin/update_script.sh
|
||||||
|
|
||||||
@reboot root /usr/sbin/update_script.sh
|
@reboot root /usr/sbin/update_script.sh
|
||||||
|
6
files/update_script.sh
Executable file
6
files/update_script.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# ajouter "0 4 * * 1 root <repertoire du script>/02" a /etc/crontab
|
||||||
|
|
||||||
|
printf "##### %s #####\n" "$(date)" >>/var/log/update_script.log
|
||||||
|
apt update >>/var/log/update_script.log 2>&1 && DEBIAN_FRONTEND=noninteractive apt upgrade -y >>/var/log/update_script.log 2>&1
|
@ -32,6 +32,30 @@
|
|||||||
service:
|
service:
|
||||||
name: "fail2ban"
|
name: "fail2ban"
|
||||||
state: "restarted"
|
state: "restarted"
|
||||||
|
- name: "Upload update_script.sh"
|
||||||
|
copy:
|
||||||
|
src: "files/update_script.sh"
|
||||||
|
dest: "/usr/sbin/update_script.sh"
|
||||||
|
owner: "root"
|
||||||
|
group: "root"
|
||||||
|
- name: "Upload update_script"
|
||||||
|
copy:
|
||||||
|
src: "files/update_script"
|
||||||
|
dest: "/etc/cron.d/update_script"
|
||||||
|
owner: "root"
|
||||||
|
group: "root"
|
||||||
|
- name: "Upload check_crontab.sh"
|
||||||
|
copy:
|
||||||
|
src: "files/check_crontab.sh"
|
||||||
|
dest: "/usr/sbin/check_crontab.sh"
|
||||||
|
owner: "root"
|
||||||
|
group: "root"
|
||||||
|
- name: "Upload check_crontab"
|
||||||
|
copy:
|
||||||
|
src: "files/check_crontab"
|
||||||
|
dest: "/etc/cron.d/check_crontab"
|
||||||
|
owner: "root"
|
||||||
|
group: "root"
|
||||||
- name: "Create .ssl directory"
|
- name: "Create .ssl directory"
|
||||||
file:
|
file:
|
||||||
path: "/home/tanguy/.ssl"
|
path: "/home/tanguy/.ssl"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user