diff options
author | erkin <e.altunbas@vyos.io> | 2021-04-17 02:20:16 +0300 |
---|---|---|
committer | erkin <e.altunbas@vyos.io> | 2021-04-17 02:20:16 +0300 |
commit | ce624d5fe8b8aac3bd067c6915f9ed87ff69781f (patch) | |
tree | ee296686d48c1019bf241f48ddf663fe930a3f30 | |
parent | 4fca5a5cd283ee7999f676a028df069db3aaae3d (diff) | |
download | vyatta-config-mgmt-ce624d5fe8b8aac3bd067c6915f9ed87ff69781f.tar.gz vyatta-config-mgmt-ce624d5fe8b8aac3bd067c6915f9ed87ff69781f.zip |
T3439: Migrate commit-confirm-notify.py to main repo
-rw-r--r-- | Makefile.am | 1 | ||||
-rwxr-xr-x | scripts/commit-confirm-notify.py | 30 | ||||
-rwxr-xr-x | scripts/vyatta-config-mgmt.pl | 2 |
3 files changed, 1 insertions, 32 deletions
diff --git a/Makefile.am b/Makefile.am index 373865b..a753c21 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,7 +9,6 @@ curver_DATA = cfg-version/config-management@1 sbin_SCRIPTS = scripts/vyatta-commit-push.pl sbin_SCRIPTS += scripts/vyatta-commit-revs.pl sbin_SCRIPTS += scripts/vyatta-config-mgmt.pl -sbin_SCRIPTS += scripts/commit-confirm-notify.py bin_sudo_users_SCRIPTS = 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) diff --git a/scripts/vyatta-config-mgmt.pl b/scripts/vyatta-config-mgmt.pl index 0a8528c..c940edb 100755 --- a/scripts/vyatta-config-mgmt.pl +++ b/scripts/vyatta-config-mgmt.pl @@ -386,7 +386,7 @@ if ($action eq 'commit-confirm') { print "Reboot scheduled for commit-confirm. " . "Confirm your changes to cancel the reboot.\n"; # Call the script to notify the users of the impending reboot. - system("sudo -b /opt/vyatta/sbin/commit-confirm-notify.py ${minutes}"); + system("sudo -b /usr/libexec/vyos/commit-confirm-notify.py ${minutes}"); exit 0; } |