29 lines
1.1 KiB
Bash
Executable File
29 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x
|
|
source "$PLUGIN_CORE_AVAILABLE_PATH/common/functions"
|
|
source "$PLUGIN_AVAILABLE_PATH/apps/functions"
|
|
source "$PLUGIN_AVAILABLE_PATH/ps/functions"
|
|
|
|
apps_rename_cmd() {
|
|
declare desc="renames an app"
|
|
local cmd="apps:rename"
|
|
[[ -z $2 ]] && dokku_log_fail "Please specify an app to run the command on"
|
|
[[ -d "$DOKKU_ROOT/$3" ]] && dokku_log_fail "Name is already taken"
|
|
local OLD_APP="$2"
|
|
local NEW_APP="$3"
|
|
|
|
mkdir -p "$DOKKU_ROOT/$NEW_APP"
|
|
docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$DOKKU_ROOT/$OLD_APP/cache:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
|
|
rm -rf "$DOKKU_ROOT/$OLD_APP/cache"
|
|
cp -a "$DOKKU_ROOT/$OLD_APP/." "$DOKKU_ROOT/$NEW_APP"
|
|
DOKKU_APPS_FORCE_DELETE=1 apps_destroy "$OLD_APP"
|
|
sed -i -e "s/$OLD_APP/$NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/URLS"
|
|
sed -i -e "s/$OLD_APP/$NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/VHOST"
|
|
sed -i -e "s/git-hook $OLD_APP/git-hook $NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive"
|
|
ps_rebuild "$NEW_APP"
|
|
plugn trigger post-app-rename "$OLD_APP" "$NEW_APP"
|
|
echo "Renaming $OLD_APP to $NEW_APP... done"
|
|
}
|
|
|
|
apps_rename_cmd "$@"
|