-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeServer.sh
83 lines (64 loc) · 1.84 KB
/
makeServer.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
#!/bin/bash
# author Cardif
# path of the server folder
SERVER_PATH=$(pwd)
TXT_PATH="$SERVER_PATH/serverfiles/Insurgency/Config/Server"
INI_PATH="$SERVER_PATH/serverfiles/Insurgency/Saved/Config/LinuxServer"
LGSM_PATH="$SERVER_PATH/lgsm/config-lgsm/inssserver"
TMP_PATH=$(mktemp -d)
SERVER_NAME=$1
# check if server name is not empty
if [ "$SERVER_NAME" == "" ]
then
echo "Error: Missing server name"
exit 1
fi
##################
### LGSM files ###
##################
wget -O linuxgsm.sh https://linuxgsm.sh > /dev/null 2>&1
chmod +x linuxgsm.sh
bash linuxgsm.sh inssserver > /dev/null 2>&1
bash inssserver install
####################
### Server files ###
####################
# clone of the repo in a temp directory
git clone -q https://github.com/LorenzoCardinali/SandstormServers.git $TMP_PATH
# make needed directories
mkdir --parents $TXT_PATH
mkdir --parents $INI_PATH
# move scripts
mv -f $TMP_PATH/updateFiles.sh $SERVER_PATH
mv -f $TMP_PATH/scripts/* $SERVER_PATH
chmod +x *.sh
# move txt and ini files
mv -f $TMP_PATH/files/txtFiles/* $TXT_PATH
mv -f $TMP_PATH/files/iniFiles/* $INI_PATH
# move LGSM config file
mv -f $TMP_PATH/files/Server.cfg $LGSM_PATH/$SERVER_NAME.cfg
# make Server script
cp inssserver $SERVER_NAME
# make servers file
echo "$SERVER_NAME" > servers
################
### SSH keys ###
################
# make needed directory
mkdir --parents $HOME/.ssh
# move keys file
mv -f $TMP_PATH/files/authorized_keys $HOME/.ssh
# set permissions
chmod 700 $HOME/.ssh
chmod 600 $HOME/.ssh/authorized_keys
###############
### Crontab ###
###############
# write out current crontab
(crontab -l > $TMP_PATH/mycron) > /dev/null 2>&1
# echo new cron into cron file
echo "00 07 * * * $SERVER_PATH/restartServers.sh > /dev/null 2>&1" >> $TMP_PATH/mycron
# install new cron file
crontab $TMP_PATH/mycron
# delete temp directory
rm -rf $TMP_PATH