-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvalheim-copy.sh
More file actions
77 lines (61 loc) · 2.64 KB
/
valheim-copy.sh
File metadata and controls
77 lines (61 loc) · 2.64 KB
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
71
72
73
74
75
76
#!/usr/bin/env bash
# Copies your Valheim world save files over to the $targetPath.
# Notice: Much like reincarnation, does NOT actually help
# anyone or save any world. It merely copies you over to
# another hellish nightmare of existence to start all over
# again from wherever you left off; presuming you even rememver
# whatever it was you were trying to do in the first place,
# assuming things are not too expensive from communism to do so.
containerWaitTime=75
containerName="valheim-server"
localPath="./"
localWorldsPath="$HOME/.config/unity3d/IronGate/Valheim"
targetPath="/home/hyperuser/hyperstor"
containerWorldsPath="/container-entrypoint-valheim/valheim-server/.config/unity3d/IronGate/Valheim"
sshRemoteHost="secure.us.hyperspire.net"
cd "${localWorldsPath}" || exit 1
if ssh ${sshRemoteHost} -t "rm ${targetPath}/worlds_local.tar.xz"; then
echo "Old worlds_local.tar.xz was removed."
fi
if rm "${localWorldsPath}"/worlds_local/*.old; then
echo "Old worlds_local files were removed."
fi
if [[ -f "worlds_local.tar.xz" ]]; then
rm -vf worlds_local.tar.xz
fi
if tar -cvJ "worlds_local" -f "worlds_local.tar.xz"; then
echo "New worlds_local.tar.xz was created."
else
echo "New worlds_local.tar.xz was not created."
exit 1
fi
if scp ${localPath}/worlds_local.tar.xz ${sshRemoteHost}:${targetPath}; then
echo "New worlds_local.tar.xz was copied to ${sshRemoteHost}:${targetPath}."
else
echo "New worlds_local.tar.xz was not copied to ${sshRemoteHost}:${targetPath}."
exit 1
fi
if ssh ${sshRemoteHost} -t "sudo podman cp ${targetPath}/worlds_local.tar.xz ${containerName}:${containerWorldsPath}"; then
echo "New worlds_local.tar.xz was copied to ${containerName}."
else
echo "New worlds_local.tar.xz was not copied to ${containerName}."
exit 1
fi
if ssh ${sshRemoteHost} -t sudo podman exec ${containerName} "tar -xvJf ${containerWorldsPath}/worlds_local.tar.xz -C ${containerWorldsPath}"; then
echo "worlds_local files were updated."
else
echo "worlds_local files were not updated."
exit 1
fi
if ssh ${sshRemoteHost} -t sudo podman exec ${containerName} "rm ${containerWorldsPath}/worlds_local.tar.xz"; then
echo "worlds_local.tar.xz was removed from ${containerName}."
fi
if ssh ${sshRemoteHost} -t "sudo podman stop ${containerName}"; then
echo "${containerName} was stopped."
fi
if ssh ${sshRemoteHost} -t "sudo podman start ${containerName}"; then
echo "${containerName} was started."
fi
echo "Waiting ${containerWaitTime} seconds for ${containerName} to start..."
sleep "${containerWaitTime}"
echo "${containerName} is $(ssh ${sshRemoteHost} -t sudo podman inspect --format '{{.State.Health.Status}}' ${containerName} 2> /dev/null)"