diff options
Diffstat (limited to 'scripts/migration/migrate-unix.sh')
-rwxr-xr-x | scripts/migration/migrate-unix.sh | 70 |
1 files changed, 70 insertions, 0 deletions
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 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | set -e | ||
4 | |||
5 | echo "********************************************" | ||
6 | echo " Ferdium User Data Migration Tool " | ||
7 | echo " WARNING: UNIX OS Only! " | ||
8 | echo "********************************************" | ||
9 | echo "This tool migrates your user data from Ferdi to Ferdium." | ||
10 | echo "Intended to be used on Linux or MacOS machine." | ||
11 | read -p "Do you want to proceed? (y/N) " confirm | ||
12 | |||
13 | case "$confirm" in | ||
14 | y|Y|[yY][eE][sS] ) echo "Starting...";; | ||
15 | n|N|[nN][oO] ) exit 1;; | ||
16 | * ) exit 1;; | ||
17 | esac | ||
18 | |||
19 | os_check=$(uname) | ||
20 | |||
21 | if [ $os_check == "Linux" ]; then | ||
22 | echo "Your OS is: Linux" | ||
23 | BASE_PATH="$HOME/.config" | ||
24 | elif [ $os_check == "Darwin" ]; then | ||
25 | echo "Your OS is: MacOS" | ||
26 | BASE_PATH="$HOME/Library/Application Support" | ||
27 | else | ||
28 | echo "Your OS is not supported by this script" | ||
29 | exit 1 | ||
30 | fi | ||
31 | |||
32 | FERDI_PATH="$BASE_PATH/Ferdi" | ||
33 | FERDIUM_PATH="$BASE_PATH/Ferdium2" | ||
34 | |||
35 | if [ -d "$FERDIUM_PATH" ]; then | ||
36 | echo "Path $FERDIUM_PATH exist, making a backup" | ||
37 | if ! mv -vf "$FERDIUM_PATH" "$FERDIUM_PATH.bak" 2> /dev/null ; then | ||
38 | read -p "A previous backup already exists at $FERDIUM_PATH.bak. do you want to remove it? (y/N) " confirm | ||
39 | echo | ||
40 | case "$confirm" in | ||
41 | y|Y|[yY][eE][sS] ) echo "Deleting...";; | ||
42 | n|N|[nN][oO] ) exit 1;; | ||
43 | * ) exit 1;; | ||
44 | esac | ||
45 | echo | ||
46 | rm -rf "$FERDIUM_PATH.bak" | ||
47 | mv -vf "$FERDIUM_PATH" "$FERDIUM_PATH.bak" | ||
48 | fi | ||
49 | fi | ||
50 | |||
51 | if mv -vf "$FERDI_PATH" "$FERDIUM_PATH"; then | ||
52 | echo "Files exported succesfully" | ||
53 | else | ||
54 | echo "ERROR!" | ||
55 | echo "No user data was found to be exported. Exiting..." | ||
56 | exit 1 | ||
57 | fi | ||
58 | |||
59 | if [ -f "$FERDIUM_PATH/server.sqlite" ]; then | ||
60 | echo "********************************************" | ||
61 | echo " Success! " | ||
62 | echo "********************************************" | ||
63 | else | ||
64 | echo "********************************************" | ||
65 | echo "WARNING: Your data was partially migrated!" | ||
66 | echo "It was detected that your account is using Ferdi servers to sync your data." | ||
67 | echo "Please, check this guide on how to export and import your data manually:" | ||
68 | echo "https://github.com/ferdium/ferdi/blob/main/MIGRATION.md" | ||
69 | echo "********************************************" | ||
70 | fi | ||