From 07c2991d756f77b64db77305d2fa790d0420778b Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Tue, 18 Feb 2014 08:07:21 -0600 Subject: [PATCH] add install/uninstall commands --- kpatch/kpatch | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/kpatch/kpatch b/kpatch/kpatch index d7f5467..d2f4d35 100755 --- a/kpatch/kpatch +++ b/kpatch/kpatch @@ -123,12 +123,23 @@ case "$1" in "remove") [[ "$#" -ne 2 ]] && usage PATCH="$2" - case "$PATCH" in - *) - find_module "$PATCH" || die "$PATCH is not installed" - unload_module "$MODULE" || die "failed to unload patch $PATCH" - ;; - esac + find_module "$PATCH" || die "$PATCH is not installed" + unload_module "$MODULE" || die "failed to unload patch $PATCH" + ;; + +"install") + [[ "$#" -ne 2 ]] && usage + PATCH="$2" + [[ -e "$PATCH" ]] || die "$PATCH doesn't exist" + [[ ${PATCH: -3} == ".ko" ]] || "$PATCH isn't a .ko file" + cp -f "$PATCH" "$USERDIR" || die "failed to install patch $PATCH" + ;; + +"uninstall") + [[ "$#" -ne 2 ]] && usage + PATCH="$2" + find_module "$PATCH" || die "$PATCH is not installed" + rm -f "$USERDIR/$(basename $MODULE)" || die "failed to uninstall patch $PATCH" ;; "list")