From eb42729b5aa3da6b425a3ccfe581fa9dcc7fa46e Mon Sep 17 00:00:00 2001 From: Evan <71018479+Evan-aja@users.noreply.github.com> Date: Thu, 5 May 2022 00:26:25 +0700 Subject: Migration script from Ferdi to Ferdium for Linux & MacOS (#91) [skip ci] Co-authored-by: Vijay A --- README.md | 2 +- scripts/migration/migrate-unix.sh | 70 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100755 scripts/migration/migrate-unix.sh diff --git a/README.md b/README.md index 2b2b7cc88..323217381 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ Since we are waiting to acquire the Apple Developer License, we are publishing o ## Migrating from Ferdi -If you are a pre-existing user of Ferdi, and are thinking of switching to Ferdium, you might want to run [the following script](./scripts/migration/migrate-windows.ps1) to migrate your existing Ferdi profile such that Ferdium can pick up the configurations. +If you are a pre-existing user of Ferdi, and are thinking of switching to Ferdium, you might want to run [the following scripts](./scripts/migration) to migrate your existing Ferdi profile such that Ferdium can pick up the configurations. (.ps1 for PowerShell/Windows users and .sh for UNIX (Linux and MacOS users) ## Contributing diff --git a/scripts/migration/migrate-unix.sh b/scripts/migration/migrate-unix.sh new file mode 100755 index 000000000..529716d85 --- /dev/null +++ b/scripts/migration/migrate-unix.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +set -e + +echo "********************************************" +echo " Ferdium User Data Migration Tool " +echo " WARNING: UNIX OS Only! " +echo "********************************************" +echo "This tool migrates your user data from Ferdi to Ferdium." +echo "Intended to be used on Linux or MacOS machine." +read -p "Do you want to proceed? (y/N) " confirm + +case "$confirm" in + y|Y|[yY][eE][sS] ) echo "Starting...";; + n|N|[nN][oO] ) exit 1;; + * ) exit 1;; +esac + +os_check=$(uname) + +if [ $os_check == "Linux" ]; then + echo "Your OS is: Linux" + BASE_PATH="$HOME/.config" +elif [ $os_check == "Darwin" ]; then + echo "Your OS is: MacOS" + BASE_PATH="$HOME/Library/Application Support" +else + echo "Your OS is not supported by this script" + exit 1 +fi + +FERDI_PATH="$BASE_PATH/Ferdi" +FERDIUM_PATH="$BASE_PATH/Ferdium2" + +if [ -d "$FERDIUM_PATH" ]; then + echo "Path $FERDIUM_PATH exist, making a backup" + if ! mv -vf "$FERDIUM_PATH" "$FERDIUM_PATH.bak" 2> /dev/null ; then + read -p "A previous backup already exists at $FERDIUM_PATH.bak. do you want to remove it? (y/N) " confirm + echo + case "$confirm" in + y|Y|[yY][eE][sS] ) echo "Deleting...";; + n|N|[nN][oO] ) exit 1;; + * ) exit 1;; + esac + echo + rm -rf "$FERDIUM_PATH.bak" + mv -vf "$FERDIUM_PATH" "$FERDIUM_PATH.bak" + fi +fi + +if mv -vf "$FERDI_PATH" "$FERDIUM_PATH"; then + echo "Files exported succesfully" +else + echo "ERROR!" + echo "No user data was found to be exported. Exiting..." + exit 1 +fi + +if [ -f "$FERDIUM_PATH/server.sqlite" ]; then + echo "********************************************" + echo " Success! " + echo "********************************************" +else + echo "********************************************" + echo "WARNING: Your data was partially migrated!" + echo "It was detected that your account is using Ferdi servers to sync your data." + echo "Please, check this guide on how to export and import your data manually:" + echo "https://github.com/ferdium/ferdi/blob/main/MIGRATION.md" + echo "********************************************" +fi -- cgit v1.2.3-70-g09d2