-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path2-install-rust.sh
executable file
·96 lines (88 loc) · 2.47 KB
/
2-install-rust.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
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
#!/bin/bash
WorkingDir="${PWD}"
#check for sudo access otherwise scripts wont work
if [ ! "$SUDO_USER" ]; then
if sudo "./$(basename "$0")"; then
exit
else
echo 'Did you run the 1st script?'
fi
fi
#################################################################################################################
function create_rust_user {
tmpfile="/tmp/create_rust_user.sh"
cat >$tmpfile << EOF
#!/bin/bash
if id rust >/dev/null 2>&1; then
exit
else
echo '>> adding rust user'
adduser rust --gecos "First Last,RoomNumber,WorkPhone,HomePhone" --disabled-password
echo rust:rust_pw | chpasswd
usermod -aG sudo rust
rm /lib/systemd/system/sudo.service
systemctl daemon-reload
systemctl unmask sudo.service
systemctl restart sudo
systemctl mask sudo.service
fi
EOF
chmod +x $tmpfile
sudo -i -u root $tmpfile
# rm $tmpfile
}
function install_steam {
tmpfile="/tmp/install_steam.sh"
cat >$tmpfile << EOF
#!/bin/bash
echo ">> Installing rust as \$USER in \$PWD"
if [ ! -f /home/rust/.steam/steam/steamcmd/steamcmd.sh ]; then
#setup steamcmd for user
steamcmd +login anonymous +quit
fi
#fix for steam bug
if [ ! -f /home/rust/.local/share/Steam/steamcmd/steamclient.so ]; then
ln -s /home/rust/.local/share/Steam/steamcmd/linux32/steamclient.so /home/rust/.local/share/Steam/steamcmd/steamclient.so
fi
if [ ! -f /home/rust/.steam/sdk64/steamclient.so ]; then
mkdir /home/rust/.steam/sdk64/
mkdir /home/rust/.steam/sdk32/
ln -s /home/rust/.steam/steamcmd/linux64/steamclient.so /home/rust/.steam/sdk64/
ln -s /home/rust/.steam/steamcmd/linux32/steamclient.so /home/rust/.steam/sdk32/
fi
#install rust now
/home/rust/.steam/steam/steamcmd/steamcmd.sh +force_install_dir ~/rust +login anonymous +app_update 258550 +quit
EOF
chmod +x $tmpfile
sudo -i -u rust $tmpfile
# rm $tmpfile
}
function copy_scripts {
tmpfile="/tmp/update_rust_scripts.sh"
cat >$tmpfile << EOF
#!/bin/bash
if [ ! -f /home/rust/tmux-help.sh ];then
echo '>> Installing server scripts'
cp ${WorkingDir}/support/* /home/rust/
chown rust:rust /home/rust/*.sh
chmod +x /home/rust/*.sh
fi
EOF
chmod +x $tmpfile
sudo -i -u root $tmpfile
# rm $tmpfile
}
#################################################################################################################
#check for rust user
if [ -d /home/rust ]; then
install_steam
copy_scripts
else
echo 'No rust dir, creating user'
if create_rust_user
then
install_steam
copy_scripts
fi
fi
echo 'Ready to run ./start-server.sh'