Remove remaining direct dokku calls
This commit is contained in:
@@ -13,9 +13,9 @@ postgres-clone-cmd() {
|
||||
[[ -z "$NEW_SERVICE" ]] && dokku_log_fail "Please specify a name for the new service"
|
||||
|
||||
verify_service_name "$SERVICE"
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:create" "$NEW_SERVICE"
|
||||
service_create "$NEW_SERVICE"
|
||||
dokku_log_info1 "Copying data from $SERVICE to $NEW_SERVICE"
|
||||
dokku "$PLUGIN_COMMAND_PREFIX:export" "$SERVICE" | dokku "$PLUGIN_COMMAND_PREFIX:import" "$NEW_SERVICE" > /dev/null 2>&1 || true
|
||||
service_export "$SERVICE" | service_import "$NEW_SERVICE" > /dev/null 2>&1 || true
|
||||
dokku_log_info1 "Done"
|
||||
}
|
||||
|
||||
|
||||
@@ -9,26 +9,7 @@ postgres-create-cmd() {
|
||||
local cmd="$PLUGIN_COMMAND_PREFIX:create" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1
|
||||
declare SERVICE="$1"
|
||||
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
||||
[[ ! -d "$PLUGIN_DATA_ROOT/$SERVICE" ]] || dokku_log_fail "$PLUGIN_SERVICE service $2 already exists"
|
||||
SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"; LINKS_FILE="$SERVICE_ROOT/LINKS"
|
||||
|
||||
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
|
||||
|
||||
mkdir -p "$SERVICE_ROOT" || dokku_log_fail "Unable to create service directory"
|
||||
password=$(openssl rand -hex 16)
|
||||
echo "$password" > "$SERVICE_ROOT/PASSWORD"
|
||||
chmod 640 "$SERVICE_ROOT/PASSWORD"
|
||||
touch "$LINKS_FILE"
|
||||
|
||||
if [[ -n $POSTGRES_CUSTOM_ENV ]]; then
|
||||
echo "$POSTGRES_CUSTOM_ENV" | tr ';' "\n" > "$SERVICE_ROOT/ENV"
|
||||
else
|
||||
echo "" > "$SERVICE_ROOT/ENV"
|
||||
fi
|
||||
service_create_container "$SERVICE"
|
||||
service_create "$SERVICE"
|
||||
}
|
||||
|
||||
postgres-create-cmd "$@"
|
||||
|
||||
@@ -11,16 +11,7 @@ postgres-export-cmd() {
|
||||
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
||||
verify_service_name "$SERVICE"
|
||||
SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||
DATABASE_NAME="$(get_database_name "$SERVICE")"
|
||||
PASSWORD=$(cat "$SERVICE_ROOT/PASSWORD")
|
||||
|
||||
[[ -n $SSH_TTY ]] && stty -opost
|
||||
docker exec "$SERVICE_NAME" env PGPASSWORD="$PASSWORD" pg_dump -Fc --no-acl --no-owner -h localhost -U postgres -w "$DATABASE_NAME"
|
||||
status=$?
|
||||
[[ -n $SSH_TTY ]] && stty opost
|
||||
exit $status
|
||||
service_export "$SERVICE"
|
||||
}
|
||||
|
||||
postgres-export-cmd "$@"
|
||||
|
||||
@@ -11,15 +11,7 @@ postgres-import-cmd() {
|
||||
|
||||
[[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service"
|
||||
verify_service_name "$SERVICE"
|
||||
SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE"
|
||||
SERVICE_NAME="$(get_service_name "$SERVICE")"
|
||||
DATABASE_NAME="$(get_database_name "$SERVICE")"
|
||||
PASSWORD=$(cat "$SERVICE_ROOT/PASSWORD")
|
||||
|
||||
if [[ -t 0 ]]; then
|
||||
dokku_log_fail "No data provided on stdin."
|
||||
fi
|
||||
docker exec -i "$SERVICE_NAME" env PGPASSWORD="$PASSWORD" pg_restore -h localhost -cO -d "$DATABASE_NAME" -U postgres -w
|
||||
service_import "$SERVICE"
|
||||
}
|
||||
|
||||
postgres-import-cmd "$@"
|
||||
|
||||
Reference in New Issue
Block a user