summarylogtreecommitdiffstats
path: root/evebackup
blob: 78b17e7ba8599255d2a7e22727934f97714e1152 (plain)
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
#!/bin/sh

set -e

. ./evesetup.shlib

backup_settings() {
for SERVER in tranquility singularity duality thunderdome ;do
	CLPROFILE="$(ls -d *_$SERVER 2>/dev/null || true)"
	[ "x$CLPROFILE" = "x" ] && continue
	if [ -f "$BACKUPDIR/$SERVER-settings_current.7z" ] ;then
		mv "$BACKUPDIR/$SERVER-settings_current.7z" "$BACKUPDIR/$SERVER-settings.7z"
		SERVERLIST="$SERVERLIST $SERVER"
		MSGSTR="Settings for$SERVERLIST in $BACKUPDIR stored."
	else
		MSGSTR="Preparing backup for $SERVER, please run $CMDSTR again."
		desktop_msg "$MSGSTR"
	fi
	cd "$CLPROFILE"
	7z u -t7z -xr!Browser "$BACKUPDIR/$SERVER-settings.7z" \
		-u- -u!"$BACKUPDIR/$SERVER-settings_current.7z" "settings_*" >/dev/null
	cd ..
done
}

restore_settings() {
for SERVER in thunderdome duality singularity tranquility ;do
	if [ ! -f "$BACKUPDIR/$SERVER-settings.7z" ] ;then
		MSGSTR="No settings in $BACKUPDIR found."
		continue 2
	fi
	case $SERVER in
		tranquility)		SERVER_SHORT=tq ;;
		singularity)		SERVER_SHORT=sisi ;;
		*)			SERVER_SHORT=$SERVER ;;
	esac
	[ -d c_"$SERVER_SHORT"_"$SERVER" ] || mkdir c_"$SERVER_SHORT"_"$SERVER"
	7z x "$BACKUPDIR/$SERVER-settings.7z" -oc_"$SERVER_SHORT"_"$SERVER" -y >/dev/null
	SERVERLIST="$SERVERLIST $SERVER"
	MSGSTR="Settings for$SERVERLIST from $BACKUPDIR restored."
done
}

SHAREDIR=$(getval SharedCacheFolder)
SETTINGSDIR="${SHAREDIR}wineenv/drive_c/users/$(whoami)/Local Settings/Application Data/CCP/EVE"
BACKUPDIR=$(xdg-user-dir DOCUMENTS)/EVE
CMDSTR=$(basename $0)

[ -d "$SETTINGSDIR" ] || mkdir -p "$SETTINGSDIR"

cd "$SETTINGSDIR"

case $CMDSTR in
	evebackup)		backup_settings ;;
	everestore)		restore_settings ;;
	*)			exit 1 ;;
esac

desktop_msg "$MSGSTR"