Skip to content

Commit 01d5d4b

Browse files
authored
Merge pull request #89 from richlamdev/enable-auto-reboot
add script and tasks to check for reboot
2 parents cd987d8 + dcf68c7 commit 01d5d4b

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ Additional information for the following roles:
8989
* technically there are built-in methods to run apt and snap update daily
9090
(unattended-upgrades), however, none of those methods seem to work.
9191
This primitive implementation achieves a similar effect.
92-
* This role is for any desktop/laptop that requires operating 24/7.
93-
* unfortunately there is no method to ensure reboots are triggered when
94-
required
92+
* This role is for any desktop/laptop that operates 24/7.
93+
* There is a basic script to check if a reboot is required,
94+
which is scheduled to run daily at 0400hrs.(checks for presence of
95+
/var/run/reboot-required)
9596

9697
* aws
9798
* installs [AWS CLI v2](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html)
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)