Last active
August 17, 2021 13:48
-
-
Save refs/f57de24cf6db638beee5482e4c077496 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
RED='\033[0;31m' | |
GREEN='\033[0;32m' | |
YELLOW='\033[0;33m' | |
NC='\033[0m' # No Color | |
ENV="" | |
BUILD="false" | |
RESTART="false" | |
TRACE="false" | |
LOG_COLOR="true" | |
OCIS_SOURCE="/Users/aunger/code/owncloud/ocis/ocis" | |
usage() | |
{ | |
echo "ocis runner helper" | |
echo "" | |
echo "\t[-h | --help] - display this menu." | |
echo "\t[-b | --build]=true | false - rebuild the ocis binary." | |
echo "\t[-r | --restart]=true | false - restart jaeger docker container." | |
echo "\t[-s | --source]=a/path - location of ocis source files." | |
echo "\t[-e | --edit] - edit this script with your default editor" | |
echo "" | |
} | |
while [ "$1" != "" ]; do | |
PARAM=`echo $1 | awk -F= '{print $1}'` | |
VALUE=`echo $1 | awk -F= '{print $2}'` | |
case $PARAM in | |
-h | --help) | |
usage | |
exit | |
;; | |
-b | --build) | |
if [ "$VALUE" = "" ] ; then | |
BUILD="true" | |
else | |
BUILD=$VALUE | |
fi | |
;; | |
-r | --restart) | |
if [ "$VALUE" = "" ] ; then | |
RESTART="true" | |
else | |
RESTART=$VALUE | |
fi | |
;; | |
-br | -rb) | |
if [ "$VALUE" = "" ] ; then | |
BUILD="true" | |
RESTART="true" | |
else | |
usage | |
exit 1 | |
fi | |
;; | |
-s | --source) | |
if [ "$VALUE" != "" ] ; then | |
OCIS_SOURCE=$VALUE | |
else | |
echo "${RED}ERROR: \"${PARAM}\" needs a value${NC}" | |
fi | |
;; | |
-t | --trace) | |
if [ "$VALUE" = "" ] ; then | |
TRACE="true" | |
else | |
TRACE=$VALUE | |
fi | |
;; | |
-e | --edit) | |
# https://stackoverflow.com/questions/59895/how-can-i-get-the-source-directory-of-a-bash-script-from-within-the-script-itsel | |
$EDITOR ${BASH_SOURCE[0]} | |
exit | |
;; | |
*) | |
echo "${RED}ERROR: unknown parameter \"$PARAM\"${NC}" | |
usage | |
exit 1 | |
;; | |
esac | |
shift | |
done | |
if [ "$BUILD" = "true" ] ; then | |
echo "${YELLOW}rebuilding ocis binary...${NC}" | |
cd $OCIS_SOURCE && make clean build | |
echo "${GREEN}ok${NC}" | |
fi | |
if [ "$RESTART" = "true" ] ; then | |
echo "${YELLOW}restarting jaeger container${NC}" | |
docker restart jaeger | |
echo "${GREEN}ok${NC}" | |
fi | |
if [ "$TRACE" = "true" ] ; then | |
ENV="$ENV OCIS_TRACING_ENABLED=true OCIS_TRACING_COLLECTOR=http://localhost:14268/api/traces " | |
fi | |
if [ "$LOG_COLOR" = "true" ] ; then | |
ENV="$ENV OCIS_LOG_COLOR=true OCIS_LOG_PRETTY=true " | |
fi | |
(export $ENV; $OCIS_SOURCE/bin/ocis server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment