diff --git a/scripts/coldreboot b/scripts/coldreboot new file mode 100755 index 00000000000..9f3ed71bdc4 --- /dev/null +++ b/scripts/coldreboot @@ -0,0 +1,20 @@ +#!/bin/bash +REBOOT_CAUSE_FILE="/host/reboot-cause/reboot-cause.txt" +REBOOT_SCRIPT_NAME=$(basename $0) +REBOOT_USER=$(logname) +REBOOT_TIME=$(date) + +# Exit if not superuser +if [[ "$EUID" -ne 0 ]]; then + echo "This command must be run as root" >&2 + exit 1 +fi + +echo "User issued '${REBOOT_SCRIPT_NAME}' command [User: ${REBOOT_USER}, Time: ${REBOOT_TIME}]"> ${REBOOT_CAUSE_FILE} + +# Wait until all buffers synced with disk +sync +sleep 1 +sync + +exec /sbin/coldreboot $* \ No newline at end of file diff --git a/setup.py b/setup.py index 196777d0e34..95eaf910dbc 100644 --- a/setup.py +++ b/setup.py @@ -115,6 +115,7 @@ 'scripts/asic_config_check', 'scripts/boot_part', 'scripts/buffershow', + 'scripts/coldreboot', 'scripts/coredump-compress', 'scripts/configlet', 'scripts/db_migrator.py',