summaryrefslogtreecommitdiff
path: root/scripts/commit-confirm-notify.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-04-23 20:30:35 +0200
committerGitHub <noreply@github.com>2021-04-23 20:30:35 +0200
commita86d0a713b1707d7beb0fe359bbfc71f4a9e2eed (patch)
tree5269b329430058e52b9de6dd3d156177f4e190c1 /scripts/commit-confirm-notify.py
parentd437f023b7807a67439689ca33f96dce805497cc (diff)
parentb12811b7708ea5250590494001cda377fa6a3fbf (diff)
downloadvyatta-config-mgmt-a86d0a713b1707d7beb0fe359bbfc71f4a9e2eed.tar.gz
vyatta-config-mgmt-a86d0a713b1707d7beb0fe359bbfc71f4a9e2eed.zip
Merge pull request #5 from erkin/current
T3439: Migrate commit-confirm-notify.py to main repo
Diffstat (limited to 'scripts/commit-confirm-notify.py')
-rwxr-xr-xscripts/commit-confirm-notify.py30
1 files changed, 0 insertions, 30 deletions
diff --git a/scripts/commit-confirm-notify.py b/scripts/commit-confirm-notify.py
deleted file mode 100755
index eb7859f..0000000
--- a/scripts/commit-confirm-notify.py
+++ /dev/null
@@ -1,30 +0,0 @@
-#!/usr/bin/env python3
-import os
-import sys
-import time
-
-# Minutes before reboot to trigger notification.
-intervals = [1, 5, 15, 60]
-
-def notify(interval):
- s = "" if interval == 1 else "s"
- time.sleep((minutes - interval) * 60)
- message = ('"[commit-confirm] System is going to reboot in '
- f'{interval} minute{s} to rollback the last commit.\n'
- 'Confirm your changes to cancel the reboot."')
- os.system("wall -n " + message)
-
-if __name__ == "__main__":
- # Must be run as root to call wall(1) without a banner.
- if len(sys.argv) != 2 or os.getuid() != 0:
- exit(1)
- minutes = int(sys.argv[1])
- # Drop the argument from the list so that the notification
- # doesn't kick in immediately.
- if minutes in intervals:
- intervals.remove(minutes)
- for interval in sorted(intervals, reverse=True):
- if minutes >= interval:
- notify(interval)
- minutes -= (minutes - interval)
- exit(0)