diff --git a/setup.sh b/setup.sh index 4a5c429..d368010 100755 --- a/setup.sh +++ b/setup.sh @@ -6,14 +6,40 @@ read -r -p "Do you want to start the initial setup? (y/n): " INSTALL_GITEA if [ -z "$INSTALL_GITEA" ] || [[ "$INSTALL_GITEA" != "y" && "$INSTALL_GITEA" != "n" ]]; then echo "Skipping inital setup." - read -r -p "Do you want to migrate from an existing installation using scp? (y/n): " MIGRATE_GITEA - - if [ "$MIGRATE_GITEA" == "y" ]; then - read -r -p "Enter the remote user@host:/destination/of/gitea/data: " REMOTE_PATH - sudo scp -r "$REMOTE_PATH" ./data - else + + read -r -p "Do you want to migrate from an existing installation? (Y/n): " MIGRATE_EXISTING + + if [ "$MIGRATE_EXISTING" == "n" ]; then echo "Exiting setup." exit 0 + + else + read -r -p "What method do you want to use for migration? (local/scp): " MIGRATION_METHOD + if [ "$MIGRATION_METHOD" == "local" ]; then + read -r -p "Enter the local path to the existing gitea installation: " LOCAL_PATH + # check if the LOCAL_PATH is a compessed file + if [[ "$LOCAL_PATH" == *.tar.gz || "$LOCAL_PATH" == *.tgz ]]; then + echo "Extracting compressed file ..." + sudo tar -xvzf "$LOCAL_PATH" -C . + exit 0 + + elif [[ "$LOCAL_PATH" == *.zip ]]; then + echo "Extracting compressed file ..." + sudo unzip "$LOCAL_PATH" -d . + exit 0 + fi + + sudo cp -r "$LOCAL_PATH" . + exit 0 + + elif [ "$MIGRATION_METHOD" == "scp" ]; then + read -r -p "Enter the remote user@host:/destination/of/gitea/: " REMOTE_PATH + sudo scp -r "$REMOTE_PATH" . + exit 0 + else + echo "Invalid migration method. Exiting setup." + exit 0 + fi fi else