usage()
{
- echo "Usage:" >&2
- echo " $0 add <kernel-version> <kernel-image>" >&2
- echo " $0 remove <kernel-version> <kernel-image>" >&2
+ echo "Usage:"
+ echo " $0 add KERNEL-VERSION KERNEL-IMAGE"
+ echo " $0 remove KERNEL-VERSION"
}
dropindirs_sort()
export LC_COLLATE=C
-COMMAND="$1"
-KERNEL_VERSION="$2"
-KERNEL_IMAGE="$3"
+for i in "$@"; do
+ if [ "$i" == "--help" -o "$i" == "-h" ]; then
+ usage
+ exit 0
+ fi
+done
+
+if [[ "${0##*/}" == 'installkernel' ]]; then
+ COMMAND='add'
+else
+ COMMAND="$1"
+ shift
+fi
+
+KERNEL_VERSION="$1"
+KERNEL_IMAGE="$2"
if [[ -f /etc/machine-id ]]; then
read MACHINE_ID < /etc/machine-id
fi
if [[ ! $COMMAND ]] || [[ ! $KERNEL_VERSION ]]; then
- usage
+ echo "Not enough arguments" >&2
exit 1
fi
case $COMMAND in
add)
- if [[ ! $KERNEL_IMAGE ]]; then
- usage
+ if [[ ! "$KERNEL_IMAGE" ]]; then
+ echo "Command 'add' requires an argument" >&2
exit 1
fi
;;
*)
- usage
+ echo "Unknown command '$COMMAND'" >&2
exit 1
;;
esac