Skip to content

Commit 2b452d7

Browse files
committed
add generate_random_salt.sh script
allows for automatic configuration of SteamIdHashSalt on Linux (or WSL) updated the readme to reflect this
1 parent 232c7ab commit 2b452d7

File tree

2 files changed

+130
-4
lines changed

2 files changed

+130
-4
lines changed

reunion/dist/Readme.tpl

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,18 @@ INSTALLATION:
2424
or this for linux
2525
linux addons/reunion/reunion_mm_i386.so
2626
at the beginning of the file
27-
4. Copy reunion.cfg to server root or gamedir.
28-
5. Start the server. When server loads, type "meta list" in console. You'll see something like this:
27+
4. Enter a 16-64 length random alphanumerical string to "SteamIdHashSalt=" option in reunion.cfg.
28+
Or you can use generate_random_salt.sh script to do this automatically.
29+
5. Copy reunion.cfg to server root or gamedir.
30+
6. Start the server. When server loads, type "meta list" in console. You'll see something like this:
2931

3032
Currently loaded plugins:
3133
description stat pend file vers src load unlod
3234
[ 1] Reunion RUN - reunion_mm_i386. v${APP_VERSION_STRD} ini Start Never
3335
[ 2] AMX Mod X RUN - amxmodx_mm_i386. v1.8.1.3 ini Start ANY
3436
2 plugins, 2 running
35-
6. If status is not "RUN", start server with "+log on +mp_logecho 1" parameters and look through console output. In 99% cases you'll find reason there.
36-
7. Installation of AmxModX plugins from amxx directory is not necessary.
37+
7. If status is not "RUN", start server with "+log on +mp_logecho 1" parameters and look through console output. In 99% cases you'll find reason there.
38+
8. Installation of AmxModX plugins from amxx directory is not necessary.
3739

3840
HOW TO CHANGE STEAMIDS OF CLIENTS
3941
Use cid* options in AUTHID MANAGEMENT section of reunion.cfg

reunion/dist/generate_random_salt.sh

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
#!/bin/sh
2+
3+
_fail () {
4+
echo $'Could not generate salt automatically.\nPlease enter a 16-64 length random alphanumerical string to "SteamIdHashSalt=" option in reunion.cfg.'
5+
return 1
6+
}
7+
8+
_success() {
9+
if grep -e ^"SteamIdHashSalt\s*=" reunion.cfg 2>&1 >/dev/null; then
10+
sed -i "s/SteamIdHashSalt\s*=.*/SteamIdHashSalt = $SALT/g" reunion.cfg 2>&1 >/dev/null
11+
else
12+
echo "SteamIdHashSalt = $SALT" >> reunion.cfg
13+
fi
14+
if ! grep ^"SteamIdHashSalt = $SALT" reunion.cfg 2>&1 >/dev/null; then
15+
echo [fail]
16+
_fail
17+
return 1
18+
fi
19+
echo [ok]
20+
echo "Done. \"SteamIdHashSalt = $SALT\" generated successfully and written to reunion.cfg."
21+
return 0
22+
}
23+
24+
SALT=
25+
26+
if [ ! -f reunion.cfg ]; then
27+
echo Error: reunion.cfg does not exist in the current directory!
28+
exit 1
29+
fi
30+
31+
echo -n "Testing for grep ... "
32+
if ! command -v grep 2>&1 >/dev/null; then
33+
echo [fail]
34+
_fail
35+
exit 1
36+
fi
37+
echo [ok]
38+
39+
echo -n "Testing for wc ... "
40+
if ! command -v wc 2>&1 >/dev/null; then
41+
echo [fail]
42+
_fail
43+
exit 1
44+
fi
45+
echo [ok]
46+
47+
echo -n "Testing for sed ... "
48+
if ! command -v sed 2>&1 >/dev/null; then
49+
echo [fail]
50+
_fail
51+
exit 1
52+
fi
53+
echo [ok]
54+
55+
echo -n "Testing for openssl ... "
56+
if command -v openssl 2>&1 >/dev/null; then
57+
echo [ok]
58+
echo -n "Generating salt ... "
59+
SALT="$(openssl rand -hex 16)"
60+
if [ "$(echo "$SALT" | wc -c)" -gt 31 ]; then
61+
_success
62+
exit $?
63+
else
64+
echo [fail]
65+
fi
66+
else
67+
echo [not found]
68+
fi
69+
70+
echo -n "Testing for /dev/urandom ... "
71+
if [ ! -e /dev/urandom ]; then
72+
echo [fail]
73+
_fail
74+
exit 1
75+
fi
76+
echo [ok]
77+
78+
echo -n "Testing for hexdump ... "
79+
if command -v hexdump 2>&1 >/dev/null; then
80+
echo [ok]
81+
echo -n "Generating salt ... "
82+
SALT="$(hexdump -vn16 -e'4/4 "%08x"' /dev/urandom)"
83+
if [ "$(echo "$SALT" | wc -c)" -gt 31 ]; then
84+
_success
85+
exit $?
86+
else
87+
echo [fail]
88+
fi
89+
else
90+
echo [not found]
91+
fi
92+
93+
echo -n "Testing for xxd ... "
94+
if command -v xxd 2>&1 >/dev/null; then
95+
echo [ok]
96+
echo -n "Generating salt ... "
97+
SALT="$(xxd -l 16 -p /dev/urandom)"
98+
if [ "$(echo "$SALT" | wc -c)" -gt 31 ]; then
99+
_success
100+
exit $?
101+
else
102+
echo [fail]
103+
fi
104+
else
105+
echo [not found]
106+
fi
107+
108+
echo -n "Testing for tr ... "
109+
if command -v tr 2>&1 >/dev/null; then
110+
echo [ok]
111+
echo -n "Generating salt ... "
112+
SALT="$(tr -dc 'a-f0-9' < /dev/urandom | head -c32)"
113+
if [ "$(echo "$SALT" | wc -c)" -gt 31 ]; then
114+
_success
115+
exit $?
116+
else
117+
echo [fail]
118+
fi
119+
else
120+
echo [not found]
121+
fi
122+
_fail
123+
exit 1
124+

0 commit comments

Comments
 (0)