1#!/bin/sh 2 3CMD=${0##*/} 4 5# busybox doesn't provide shutdown command 6[ "$CMD" != shutdown ] || CMD=poweroff 7 8unset ARGS HELP 9while [ -n "$1" ];do 10 case "$1" in 11 # Original args 12 -n|-f|-w) 13 ARGS="$ARGS $1" 14 ;; 15 -d) 16 ARGS="$ARGS $1 $2" 17 shift 18 ;; 19 # Additional args 20 --halt) 21 CMD=halt 22 ;; 23 -p|--poweroff) 24 CMD=poweroff 25 ;; 26 --reboot) 27 CMD=reboot 28 ;; 29 --no-wall) 30 ARGS="$ARGS -f" 31 ;; 32 --help) 33 HELP=1 34 ARGS="$ARGS $1" 35 ;; 36 *) 37 ARGS="$ARGS $1" 38 ;; 39 esac 40 shift 41done 42 43if [ -n "$HELP" ]; then 44 busybox $CMD --help 45else 46 busybox $CMD $ARGS && exit 0 47fi 48 49# Print add-on usages 50cat << EOF 51 --help Show this help 52 --halt Halt the machine 53 -p --poweroff Switch off the machine 54 --reboot Reboot the machine 55 --no-wall Don't send wall message before halt/power-off/reboot 56EOF 57