Handle cases where directories and files are not-existent
New applications will be missing a few different files and directories, which isn't strictly an error case.
This commit is contained in:
1 parent
be3574136b
commit
b2fac23d58
2 files changed
+8
-7
No files matched your search
@@ -11,17 +11,18 @@ apps_rename_cmd() {
|
|||||||
[[ -d "$DOKKU_ROOT/$3" ]] && dokku_log_fail "Name is already taken"
|
[[ -d "$DOKKU_ROOT/$3" ]] && dokku_log_fail "Name is already taken"
|
||||||
local OLD_APP="$2"
|
local OLD_APP="$2"
|
||||||
local NEW_APP="$3"
|
local NEW_APP="$3"
|
||||||
|
local OLD_CACHE_DIR="$DOKKU_ROOT/$OLD_APP/cache"
|
||||||
|
|
||||||
mkdir -p "$DOKKU_ROOT/$NEW_APP"
|
mkdir -p "$DOKKU_ROOT/$NEW_APP"
|
||||||
if ! rmdir "$DOKKU_ROOT/$OLD_APP/cache" > /dev/null 2>&1; then
|
if [[ -d "$OLD_CACHE_DIR" ]] && ! rmdir "$OLD_CACHE_DIR"; then
|
||||||
docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$DOKKU_ROOT/$OLD_APP/cache:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
|
docker run "$DOKKU_GLOBAL_RUN_ARGS" --rm -v "$OLD_CACHE_DIR:/cache" "dokku/$OLD_APP" chmod 777 -R /cache
|
||||||
fi
|
fi
|
||||||
rm -rf "$DOKKU_ROOT/$OLD_APP/cache"
|
rm -rf "$OLD_CACHE_DIR"
|
||||||
cp -a "$DOKKU_ROOT/$OLD_APP/." "$DOKKU_ROOT/$NEW_APP"
|
cp -a "$DOKKU_ROOT/$OLD_APP/." "$DOKKU_ROOT/$NEW_APP"
|
||||||
DOKKU_APPS_FORCE_DELETE=1 apps_destroy "$OLD_APP"
|
DOKKU_APPS_FORCE_DELETE=1 apps_destroy "$OLD_APP"
|
||||||
sed -i -e "s/$OLD_APP/$NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/URLS"
|
[[ -f "$DOKKU_ROOT/$NEW_APP/URLS" ]] && 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"
|
[[ -f "$DOKKU_ROOT/$NEW_APP/VHOST" ]] && 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"
|
[[ -f "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive" ]] && sed -i -e "s/git-hook $OLD_APP/git-hook $NEW_APP/g" "$DOKKU_ROOT/$NEW_APP/hooks/pre-receive"
|
||||||
ps_rebuild "$NEW_APP"
|
ps_rebuild "$NEW_APP"
|
||||||
plugn trigger post-app-rename "$OLD_APP" "$NEW_APP"
|
plugn trigger post-app-rename "$OLD_APP" "$NEW_APP"
|
||||||
echo "Renaming $OLD_APP to $NEW_APP... done"
|
echo "Renaming $OLD_APP to $NEW_APP... done"
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ load test_helper
|
|||||||
run bash -c "dokku apps:rename $TEST_APP great-test-name"
|
run bash -c "dokku apps:rename $TEST_APP great-test-name"
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
assert_output $TEST_APP
|
assert_success
|
||||||
run bash -c "dokku --force apps:destroy great-test-name"
|
run bash -c "dokku --force apps:destroy great-test-name"
|
||||||
echo "output: "$output
|
echo "output: "$output
|
||||||
echo "status: "$status
|
echo "status: "$status
|
||||||
|
|||||||
Reference in new issue
Block a user