-
Notifications
You must be signed in to change notification settings - Fork 179
/
migrate-unix.sh
executable file
·70 lines (61 loc) · 2.09 KB
/
migrate-unix.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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/Ferdium"
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 successfully"
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/docs/MIGRATION.md"
echo "********************************************"
fi