forked from lloesche/valheim-server-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
valheim-bootstrap
executable file
·71 lines (55 loc) · 2.29 KB
/
valheim-bootstrap
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
#!/bin/bash
# valheim-bootstrap is the first of the valheim-* scripts
# that runs and prepares the system based on
# environment variables.
# Include defaults
. /usr/local/etc/valheim/defaults
. /usr/local/etc/valheim/common
mkdir -p "$valheim_download_path"
mkdir -p "$valheim_install_path"
if [ "$VALHEIM_PLUS" = true ]; then
mkdir -p "$vp_download_path"
mkdir -p "$vp_install_path"
write_valheim_plus_config
fi
if [ -f "/usr/share/zoneinfo/$TZ" ]; then
info "Setting timezone $TZ"
ln -snf "/usr/share/zoneinfo/$TZ" /etc/localtime
echo "$TZ" > /etc/timezone
else
error "Error: unknown timezone $TZ"
fi
crontab=$(mktemp)
if [ "$BACKUPS" = true ] && [ -n "$BACKUPS_CRON" ] && [ "$BACKUPS_INTERVAL" = "315360000" ]; then
debug "Creating cron to do world backups using schedule $BACKUPS_CRON"
echo "$BACKUPS_CRON [ -f \"$valheim_backup_pidfile\" ] && kill -HUP \$(cat $valheim_backup_pidfile)" >> "$crontab"
fi
if [ -n "$UPDATE_CRON" ] && [ "$UPDATE_INTERVAL" = "315360000" ]; then
debug "Creating cron to check for updates using schedule $UPDATE_CRON"
echo "$UPDATE_CRON [ -f \"$valheim_updater_pidfile\" ] && kill -HUP \$(cat $valheim_updater_pidfile)" >> "$crontab"
fi
if [ -n "$RESTART_CRON" ]; then
debug "Creating cron to restart valheim-server using schedule $RESTART_CRON"
echo "$RESTART_CRON /usr/bin/supervisorctl restart valheim-server" >> "$crontab"
else
debug "Environment variable RESTART_CRON is empty - no automatic valheim-server restart scheduled"
fi
crontab "$crontab"
rm -f "$crontab"
# Notify users of new data paths
if [ -d "/opt/valheim_dl" ] || [ -f "/opt/valheim/valheim_server.x86_64" ]; then
cat <<EOF
!!! ATTENTION !!!
You have /opt/valheim_dl mounted or old server files in /opt/valheim.
The /opt/valheim_dl volume is no longer required and has been unified under
/opt/valheim
Directories have been moved in the following way:
/opt/valheim/ -> /opt/valheim/server/
/opt/valheim_dl/ -> /opt/valheim/dl/server/
You might want to (re)move existing files or create a fresh volume mount under /opt/valheim to clean things up.
Nothing is going to break though if you don't. It will just consume some extra disk space.
If required we'll download a fresh copy of the server in the new directory structure.
!!! ATTENTION !!!
EOF
fi
exit 0