Skip to content

Commit

Permalink
Parse arguments in service_create calls
Browse files Browse the repository at this point in the history
Refs #64
  • Loading branch information
josegonzalez committed Sep 25, 2016
1 parent 8fc2ced commit f96ca65
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions functions
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ service_create() {
[[ ! -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] || dokku_log_fail "$PLUGIN_SERVICE service $SERVICE already exists"
SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS"

service_parse_args "${@:2}"

if ! docker images | grep -e "^$PLUGIN_IMAGE " | grep -q " $PLUGIN_IMAGE_VERSION " ; then
docker pull "$PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" || dokku_log_fail "$PLUGIN_SERVICE image $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION pull failed"
fi
Expand All @@ -24,11 +26,13 @@ service_create() {
mkdir -p "$SERVICE_ROOT/config" || dokku_log_fail "Unable to create service config directory"
curl -sSL "https://raw.githubusercontent.com/antirez/redis/${PLUGIN_IMAGE_VERSION:0:3}/redis.conf" > "$SERVICE_ROOT/config/redis.conf" || dokku_log_fail "Unable to download the default redis.conf to the config directory"
PASSWORD=$(openssl rand -hex 32)
[[ -n "$SERVICE_PASSWORD" ]] && PASSWORD="$SERVICE_PASSWORD"
echo "$PASSWORD" > "$SERVICE_ROOT/PASSWORD"
chmod 640 "$SERVICE_ROOT/PASSWORD"
sed -i.bak "s/# requirepass.*/requirepass ${PASSWORD}/" "$SERVICE_ROOT/config/redis.conf" && rm "$SERVICE_ROOT/config/redis.conf.bak"
touch "$LINKS_FILE"

[[ -n "$SERVICE_CUSTOM_ENV" ]] && REDIS_CUSTOM_ENV="$SERVICE_CUSTOM_ENV"
if [[ -n $REDIS_CUSTOM_ENV ]]; then
echo "$REDIS_CUSTOM_ENV" | tr ';' "\n" > "$SERVICE_ROOT/ENV"
else
Expand Down
2 changes: 1 addition & 1 deletion subcommands/clone
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ redis-clone-cmd() {
[[ -z "$NEW_SERVICE" ]] && dokku_log_fail "Please specify a name for the new service"

verify_service_name "$SERVICE"
service_create "$NEW_SERVICE"
service_create "$NEW_SERVICE" "${@:3}"
dokku_log_info1 "Copying data from $SERVICE to $NEW_SERVICE"
service_export "$SERVICE" | service_import "$NEW_SERVICE" > /dev/null 2>&1 || true
dokku_log_info1 "Done"
Expand Down
2 changes: 1 addition & 1 deletion subcommands/create
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ redis-create-cmd() {
local cmd="$PLUGIN_COMMAND_PREFIX:create" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
declare SERVICE="$1"

service_create "$SERVICE"
service_create "$SERVICE" "${@:2}"
}

redis-create-cmd "$@"

0 comments on commit f96ca65

Please sign in to comment.