Skip to content

Instantly share code, notes, and snippets.

@veysby
Last active December 10, 2015 21:07
Show Gist options
  • Save veysby/3993b2900b634b7beea6 to your computer and use it in GitHub Desktop.
Save veysby/3993b2900b634b7beea6 to your computer and use it in GitHub Desktop.
SH: wrapper for Java applications
#!/bin/sh
invoke_help() {
cat << EOF
Usage: $0 -a <ACTION> [-f] [-h]
-a : ACTION, where ACTION is one of:
start : Start the service in the background
stop : Stop the service
status : Show status
-f : FORCE, forces operation to run (no validation checks)
-h : HELP, show usage"
EOF
exit 1
}
invoke_start() {
exit 0
}
invoke_stop() {
exit 0
}
invoke_status() {
exit 0
}
commandline_args="$@"
while getopts a:fh OPT; do
case ${OPT} in
a) action=$OPTARG
;;
f) force_run=true
;;
h) invoke_help
;;
esac
done
if [ -z "$action" ]; then
invoke_help
fi
case "$action" in
status)
invoke_status
;;
start)
invoke_start
;;
stop)
invoke_stop
;;
*)
echo "ERROR: Unknown action: '$action'"
invoke_help
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment