-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript-no-os
More file actions
103 lines (88 loc) · 3.3 KB
/
script-no-os
File metadata and controls
103 lines (88 loc) · 3.3 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# Prompt user for configuration
read -p "Enter Root Username: " ROOT_USER
read -s -p "Enter Root Password: " ROOT_PASS
echo
read -p "Enter Server Name: " SERVER_NAME
read -p "Enter Max Players: " MAX_PLAYERS
read -p "Enter Server Description (optional): " SERVER_DESC
read -s -p "Enter Server Password (optional): " SERVER_PASS
echo
read -p "Enter Server Visibility (0: Manual, 2: Public) [Default: 2]: " SERVER_VISIBILITY
SERVER_VISIBILITY=${SERVER_VISIBILITY:-2}
read -p "Enter Game World (Default: Navezgane): " GAME_WORLD
GAME_WORLD=${GAME_WORLD:-Navezgane}
read -p "Enter World Gen Seed (Default: asdf): " WORLD_GEN_SEED
WORLD_GEN_SEED=${WORLD_GEN_SEED:-asdf}
read -p "Enter World Gen Size (6144 - 10240, multiple of 1024) [Default: 6144]: " WORLD_GEN_SIZE
WORLD_GEN_SIZE=${WORLD_GEN_SIZE:-6144}
read -p "Enter Game Name (Default: My Game): " GAME_NAME
GAME_NAME=${GAME_NAME:-"My Game"}
# Update system
echo "Updating system..."
apt update && apt upgrade -y
# Install dependencies
echo "Installing dependencies..."
apt install -y software-properties-common curl wget file tar bzip2 gzip unzip bsdmainutils python3 util-linux ca-certificates jq net-tools iproute2 screen tmux htop nano steamcmd
# Create 7D2D user
echo "Creating game server user..."
useradd -m -s /bin/bash 7d2d
# Set password for root (if applicable)
echo "root:$ROOT_PASS" | chpasswd
# Install SteamCMD
echo "Installing SteamCMD..."
mkdir -p /home/7d2d/steamcmd
cd /home/7d2d/steamcmd
wget https://steamcdn-a.akamaihd.net/client/installer/steamcmd_linux.tar.gz
tar -xvzf steamcmd_linux.tar.gz
# Install 7 Days to Die Server
echo "Downloading 7 Days to Die server..."
mkdir -p /home/7d2d/7daysded
/home/7d2d/steamcmd/steamcmd.sh +login anonymous +force_install_dir /home/7d2d/7daysded +app_update 294420 validate +quit
# Generate serverconfig.xml
echo "Configuring 7 Days to Die server..."
cat <<EOL > /home/7d2d/7daysded/serverconfig.xml
<?xml version="1.0" encoding="UTF-8"?>
<ServerSettings>
<property name="ServerName" value="$SERVER_NAME"/>
<property name="ServerDescription" value="$SERVER_DESC"/>
<property name="ServerPassword" value="$SERVER_PASS"/>
<property name="ServerPort" value="26900"/>
<property name="ServerVisibility" value="$SERVER_VISIBILITY"/>
<property name="GameWorld" value="$GAME_WORLD"/>
<property name="GameName" value="$GAME_NAME"/>
<property name="WorldGenSeed" value="$WORLD_GEN_SEED"/>
<property name="WorldGenSize" value="$WORLD_GEN_SIZE"/>
<property name="MaxPlayers" value="$MAX_PLAYERS"/>
</ServerSettings>
EOL
# Set permissions
chown -R 7d2d:7d2d /home/7d2d/
# Open required ports
echo "Configuring firewall..."
ufw allow 26900/tcp
ufw allow 26900/udp
ufw allow 26901/udp
ufw allow 26902/udp
ufw reload
# Create systemd service
echo "Creating systemd service..."
cat <<EOL > /etc/systemd/system/7d2d.service
[Unit]
Description=7 Days to Die Server
After=network.target
[Service]
User=7d2d
WorkingDirectory=/home/7d2d/7daysded
ExecStart=/home/7d2d/7daysded/startserver.sh -configfile=serverconfig.xml
Restart=always
LimitNOFILE=100000
[Install]
WantedBy=multi-user.target
EOL
# Enable and start the server
systemctl daemon-reload
systemctl enable 7d2d
systemctl start 7d2d
echo "7 Days to Die Server installation is complete!"
echo "You can manage the server with: systemctl start|stop|restart 7d2d"