#!/usr/bin/env bash source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/config" set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x source "$PLUGIN_BASE_PATH/common/functions" source "$(dirname "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")/functions" source "$PLUGIN_AVAILABLE_PATH/ps/functions" service-upgrade-cmd() { #E you can upgrade an existing service to a new image or image-version #E dokku $PLUGIN_COMMAND_PREFIX:upgrade lolipop #A service, service to run command against #F -C|--custom-env "USER=alpha;HOST=beta", semi-colon delimited environment variables to start the service with #F -i|--image IMAGE, the image name to start the service with #F -I|--image-version IMAGE_VERSION, the image version to start the service with #F -R|--restart-apps "true", whether to force an app restart declare desc="upgrade service to the specified versions" local cmd="$PLUGIN_COMMAND_PREFIX:upgrade" argv=("$@"); [[ ${argv[0]} == "$cmd" ]] && shift 1 declare SERVICE="$1" UPGRADE_FLAG_LIST="${@:2}" [[ -z "$SERVICE" ]] && dokku_log_fail "Please specify a name for the service" verify_service_name "$SERVICE" local SERVICE_ROOT="$PLUGIN_DATA_ROOT/$SERVICE" local ID="$(cat "$SERVICE_ROOT/ID")" is_container_status "$ID" "Running" || dokku_log_fail "Service ${SERVICE} container is not running" service_parse_args "${@:2}" if ! service_image_exists "$SERVICE"; then dokku_log_fail "Unable to proceed with upgrade, image ${PLUGIN_IMAGE}:${PLUGIN_IMAGE_VERSION} does not exist" fi dokku_log_info2 "Upgrading $SERVICE to $PLUGIN_IMAGE:$PLUGIN_IMAGE_VERSION" if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then dokku_log_info2 "Stopping all linked services" for app in $(service_linked_apps "$SERVICE"); do ps_stop "$app" done fi dokku_log_info2 "Stopping $SERVICE" service_container_rm "$SERVICE" service_start "$SERVICE" "${@:2}" if [[ "$SERVICE_RESTART_APPS" == "true" ]]; then dokku_log_info2 "Starting all linked services" for app in $(service_linked_apps "$SERVICE"); do ps_start "$app" done fi dokku_log_info2 "Done" } service-upgrade-cmd "$@"