Skip to content

Commit 9c5e40e

Browse files
committed
add script and tasks to check for reboot
1 parent cd987d8 commit 9c5e40e

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
LOG_FILE="/var/log/reboot_check.log"
4+
5+
if [ -f /var/run/reboot-required ]; then
6+
echo "Reboot required on $(date)" >>"$LOG_FILE"
7+
# Uncomment the next line to automatically reboot
8+
/sbin/reboot
9+
fi

roles/auto-update/tasks/main.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,18 @@
4848
mode: '0644'
4949
modification_time: preserve
5050
access_time: preserve
51+
52+
- name: Copy the reboot check script to the server
53+
copy:
54+
src: "check_reboot.sh"
55+
dest: /usr/local/bin/check_reboot.sh
56+
owner: root
57+
group: root
58+
mode: '0755'
59+
60+
- name: Schedule cron job to run the reboot check at 0400hrs daily
61+
cron:
62+
name: "Check if reboot is required"
63+
minute: "0"
64+
hour: "4"
65+
job: "/usr/local/bin/check_reboot.sh"

0 commit comments

Comments
 (0)