Fix deploy.sh for existing non-git directory

Handle case where remote directory exists but is not a git repository.
Backs up config.js, removes directory, clones fresh, restores config.js.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Michael Simard
2026-01-22 09:44:36 -06:00
parent 8396fbcf6f
commit 6344171c62

View File

@@ -31,6 +31,20 @@ if [ -d "${REMOTE_PATH}/.git" ]; then
echo "Repository exists, pulling latest changes..." echo "Repository exists, pulling latest changes..."
cd ${REMOTE_PATH} cd ${REMOTE_PATH}
git pull git pull
elif [ -d "${REMOTE_PATH}" ]; then
echo "Directory exists but is not a git repo, converting..."
# Backup config.js if it exists
if [ -f "${REMOTE_PATH}/config.js" ]; then
cp "${REMOTE_PATH}/config.js" /tmp/unraid-dash-config.js.bak
fi
rm -rf ${REMOTE_PATH}
git clone ${GIT_REPO} ${REMOTE_PATH}
cd ${REMOTE_PATH}
# Restore config.js if backed up
if [ -f /tmp/unraid-dash-config.js.bak ]; then
mv /tmp/unraid-dash-config.js.bak ${REMOTE_PATH}/config.js
echo "Restored config.js"
fi
else else
echo "Cloning repository..." echo "Cloning repository..."
git clone ${GIT_REPO} ${REMOTE_PATH} git clone ${GIT_REPO} ${REMOTE_PATH}