Commit 2933fb02 authored by Ivan Vilata-i-Balaguer's avatar Ivan Vilata-i-Balaguer
Browse files

Parse ``--repo`` arguments in wrapper script

This allows the user to specify a different repository directory and have the
wrapper script use it instead of the hardwired default one.
parent 4c21bf4b
......@@ -5,6 +5,28 @@
set -e
# Checks for args overriding the default repository.
get_repo_from_args() {
local arg setnext=n repo
for arg in "$@"; do
if [ "$setnext" = y ]; then
repo="$arg" # previous arg was "--repo"
setnext=n
continue
fi
case "$arg" in
(--repo=*)
repo="${arg#--repo=}"
;;
(--repo)
setnext=y
;;
(*) ;;
esac
done
echo "$repo"
}
case "$1" in
(injector|client) ;;
(*) echo "Please specify whether to run the injector or the client." >&2
......@@ -18,8 +40,15 @@ PROG=$1
CONF=/var/opt/ouinet/$PROG/ouinet-$PROG.conf
REPO=$(dirname $CONF)
repo_arg=$(get_repo_from_args "$@")
REPO="${repo_arg:-$REPO}"
if [ ! -d "$REPO" ]; then
cp -r "$INST/repo-templates/$PROG" "$REPO"
fi
exec "$INST/$PROG" --repo "$REPO" "$@"
if [ "$repo_arg" ]; then
exec "$INST/$PROG" "$@"
else
exec "$INST/$PROG" --repo "$REPO" "$@"
fi
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment