Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reboot logging #1

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions scripts/coldreboot
Original file line number Diff line number Diff line change
@@ -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 $*
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
'scripts/asic_config_check',
'scripts/boot_part',
'scripts/buffershow',
'scripts/coldreboot',
'scripts/coredump-compress',
'scripts/configlet',
'scripts/db_migrator.py',
Expand Down