From 8182dfa64dce9aa6566cba2936670d21bf3ebfa7 Mon Sep 17 00:00:00 2001 From: Ying Xie Date: Thu, 21 Mar 2019 09:19:20 -0700 Subject: [PATCH] [reboot script] add -h, -? options (#484) * [reboot script] add -h, -? and -x options Signed-off-by: Ying Xie * remove option -x * add some more help information for reboot script itself * change some wording/format --- scripts/reboot | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/reboot b/scripts/reboot index e82dd8c302..0da7e03923 100755 --- a/scripts/reboot +++ b/scripts/reboot @@ -30,6 +30,33 @@ function clear_warm_boot() /sbin/kexec -u || /bin/true } +SCRIPT=$0 + +function show_help_and_exit() +{ + echo "Usage ${SCRIPT} [options]" + echo " Request rebooting the device. Invoke platform-specific tool when available." + echo " This script will shutdown syncd before rebooting." + echo " " + echo " Available options:" + echo " -h, -? : getting this help" + + exit 0 +} + +function parse_options() +{ + while getopts "h?" opt; do + case ${opt} in + h|\? ) + show_help_and_exit + ;; + esac + done +} + +parse_options $@ + # Exit if not superuser if [[ "$EUID" -ne 0 ]]; then echo "This command must be run as root" >&2