diff options
| author | Louis Burda <quent.burda@gmail.com> | 2021-05-19 13:48:31 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2021-05-19 13:48:31 +0200 |
| commit | 16b3dff93e5d1096174749e1b809728f585d95fb (patch) | |
| tree | bf0882e08c1834774ff1297f81752305ac7aaec3 /service/do.sh | |
| parent | 64e9b2ad130c0cf28797c3530683fc1cc6b0e9d3 (diff) | |
| download | enowars5-service-stldoctor-16b3dff93e5d1096174749e1b809728f585d95fb.tar.gz enowars5-service-stldoctor-16b3dff93e5d1096174749e1b809728f585d95fb.zip | |
refactored service structure and added do.sh for automation
Diffstat (limited to 'service/do.sh')
| -rw-r--r-- | service/do.sh | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/service/do.sh b/service/do.sh new file mode 100644 index 0000000..2dfd82c --- /dev/null +++ b/service/do.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +SCRIPTPATH="$(dirname $(readlink -f "$0"))" +cd "$SCRIPTPATH" + +makefile=" +all: .cleansrc + +.cleansrc: src/* + bash do.sh cleansrc src container/src + touch .cleansrc +" + +shopt -s expand_aliases +alias pushd="pushd &>/dev/null" +alias popd="popd &>/dev/null" + +if [ "$1" == "compose" ]; then + # ensure container files are up to date + make --file <(echo "$makefile") + + # forward commands to compose + pushd container + docker-compose ${@:2} + popd +elif [ "$1" == "cleansrc" ]; then + # copy files + src="$2" + dst="$3" + [ -e "$dst" ] && rm -rf "$dst" + cp -r "$src" "$dst" + + # strip comments + find "$dst" | while read path; do + if [ -f "$path" ]; then + sed -i -e 's/^\s*\/\*.*\*\/\s*$//g' "$path" # remove /* */ style comments + sed -i -e 's/\s*\/\*.*\*\/\s*/ /g' "$path" # remove /* */ style comments + sed -i -e 's/\/\/.*//g' "$path" # remove // style comments + sed -i -e ':a;N;$!ba;s/\n{2,}/\n/g' "$path" # collapse multiple newlines + fi + done +else + echo "USAGE: do.sh (compose) [args..]" + echo "EXAMPLES:" + echo " do.sh compose up --build # starts the docker container" +fi |
