Skip to content

Commit 0e921d3

Browse files
authored
scripts: preparations for new deployments (#1357)
* scripts/install: allow specifying version * scripts/update: allow specifying version * scripts/services: allow 443 for smp, allow infinite startup
1 parent 7488923 commit 0e921d3

File tree

5 files changed

+52
-20
lines changed

5 files changed

+52
-20
lines changed

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,15 @@ On Linux, you can deploy smp and xftp server using Docker. This will download im
149149
You can install and setup servers automatically using our script:
150150

151151
```sh
152-
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/simplex-chat/simplexmq/stable/install.sh -o simplex-server-install.sh \
153-
&& if echo 'c90886104cd640b2ed64921dba80e90691db36788e8d6dcc13d8f33f92f0ea54 simplex-server-install.sh' | sha256sum -c; then chmod +x ./simplex-server-install.sh && ./simplex-server-install.sh; rm ./simplex-server-install.sh; else echo "SHA-256 checksum is incorrect!" && rm ./simplex-server-install.sh; fi
152+
curl --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/simplex-chat/simplexmq/stable/install.sh -o simplex-server-install.sh &&\
153+
if echo '53fcdb4ceab324316e2c4cda7e84dbbb344f32550a65975a7895425e5a1be757 simplex-server-install.sh' | sha256sum -c; then
154+
chmod +x ./simplex-server-install.sh
155+
./simplex-server-install.sh
156+
rm ./simplex-server-install.sh
157+
else
158+
echo "SHA-256 checksum is incorrect!"
159+
rm ./simplex-server-install.sh
160+
fi
154161
```
155162

156163
### Build from source

install.sh

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
set -eu
33

44
# Links to scripts/configs
5-
bin="https://github.com/simplex-chat/simplexmq/releases/latest/download"
6-
remote_version="$(curl --proto '=https' --tlsv1.2 -sSf -L https://api.github.com/repos/simplex-chat/simplexmq/releases/latest | grep -i "tag_name" | awk -F \" '{print $4}')"
7-
85
scripts="https://raw.githubusercontent.com/simplex-chat/simplexmq/stable/scripts/main"
96
scripts_systemd_smp="$scripts/smp-server.service"
107
scripts_systemd_xftp="$scripts/xftp-server.service"
@@ -57,7 +54,7 @@ ${GRN}1.${NC} Install latest binaries from GitHub releases:
5754
${GRN}2.${NC} Create server directories:
5855
- smp: ${YLW}${path_conf_smp}${NC}
5956
- xftp: ${YLW}${path_conf_xftp}${NC}
60-
${GRN}3.${NC} Setup user for each server:
57+
${GRN}3.${NC} Setup user for server:
6158
- xmp: ${YLW}${user_smp}${NC}
6259
- xftp: ${YLW}${user_xftp}${NC}
6360
${GRN}4.${NC} Create systemd services:
@@ -67,9 +64,8 @@ ${GRN}5.${NC} Install stopscript (systemd), update and uninstallation script:
6764
- all: ${YLW}${path_bin_update}${NC}, ${YLW}${path_bin_uninstall}${NC}, ${YLW}${path_bin_stopscript}${NC}
6865
6966
Press:
70-
- ${GRN}ENTER${NC} to continue installing both xftp and smp servers
71-
- ${GRN}1${NC} to install only smp server
72-
- ${GRN}2${NC} to install only xftp server
67+
- ${GRN}1${NC} to install smp server
68+
- ${GRN}2${NC} to install xftp server
7369
- ${RED}Ctrl+C${NC} to cancel installation
7470
7571
Selection: "
@@ -83,6 +79,21 @@ Please checkout our server guides:
8379
To uninstall with full clean-up, simply run: ${YLW}sudo /usr/local/bin/simplex-servers-uninstall${NC}
8480
"
8581

82+
set_version() {
83+
ver="${VER:-latest}"
84+
85+
case "$ver" in
86+
latest)
87+
bin="https://github.com/simplex-chat/simplexmq/releases/latest/download"
88+
remote_version="$(curl --proto '=https' --tlsv1.2 -sSf -L https://api.github.com/repos/simplex-chat/simplexmq/releases/latest | grep -i "tag_name" | awk -F \" '{print $4}')"
89+
;;
90+
*)
91+
bin="https://github.com/simplex-chat/simplexmq/releases/download/${ver}"
92+
remote_version="${ver}"
93+
;;
94+
esac
95+
}
96+
8697
os_test() {
8798
. /etc/os-release
8899

@@ -155,6 +166,7 @@ checks() {
155166
exit 1
156167
fi
157168

169+
set_version
158170
os_test
159171

160172
mkdir -p $path_conf_info
@@ -166,13 +178,11 @@ main() {
166178
printf "%b\n%b" "${BLU}$logo${NC}" "$welcome"
167179
read ans
168180

169-
if [ "$ans" = '1' ]; then
170-
setup='smp'
171-
elif [ "$ans" = '2' ]; then
172-
setup='xftp'
173-
else
174-
setup='smp xftp'
175-
fi
181+
case "$ans" in
182+
1) setup='smp' ;;
183+
2) setup='xftp' ;;
184+
*) printf 'Installation aborted.\n' && exit 0 ;;
185+
esac
176186

177187
printf "Installing binaries..."
178188

scripts/main/simplex-servers-update

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
set -eu
33

44
# Links to scripts/configs
5-
bin="https://github.com/simplex-chat/simplexmq/releases/latest/download"
6-
75
scripts="https://raw.githubusercontent.com/simplex-chat/simplexmq/stable/scripts/main"
86
scripts_systemd_smp="$scripts/smp-server.service"
97
scripts_systemd_xftp="$scripts/xftp-server.service"
@@ -76,6 +74,21 @@ installed_test() {
7674
set -u
7775
}
7876

77+
set_version() {
78+
ver="${VER:-latest}"
79+
80+
case "$ver" in
81+
latest)
82+
bin="https://github.com/simplex-chat/simplexmq/releases/latest/download"
83+
remote_version="$(curl --proto '=https' --tlsv1.2 -sSf -L https://api.github.com/repos/simplex-chat/simplexmq/releases/latest | grep -i "tag_name" | awk -F \" '{print $4}')"
84+
;;
85+
*)
86+
bin="https://github.com/simplex-chat/simplexmq/releases/download/${ver}"
87+
remote_version="${ver}"
88+
;;
89+
esac
90+
}
91+
7992
update_scripts() {
8093
curl --proto '=https' --tlsv1.2 -sSf -L "$scripts_update" -o "$path_tmp_bin_update" && chmod +x "$path_tmp_bin_update"
8194
curl --proto '=https' --tlsv1.2 -sSf -L "$scripts_uninstall" -o "$path_tmp_bin_uninstall" && chmod +x "$path_tmp_bin_uninstall"
@@ -137,8 +150,6 @@ update_bins() {
137150
eval "bin=\$bin_${1}"
138151
eval "path_bin=\$path_bin_${1}"
139152

140-
remote_version="$(curl --proto '=https' --tlsv1.2 -sSf -L https://api.github.com/repos/simplex-chat/simplexmq/releases/latest | grep -i "tag_name" | awk -F \" '{print $4}')"
141-
142153
set_ver() {
143154
local_version='unset'
144155
sed -i -- "s/local_version_${1}=.*/local_version_${1}='${remote_version}'/" "$path_conf_info/release"
@@ -192,6 +203,7 @@ checks() {
192203
exit 1
193204
fi
194205

206+
set_version
195207
os_test
196208
installed_test
197209

scripts/main/smp-server.service

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ ExecStart=/usr/local/bin/smp-server start +RTS -N -RTS
99
ExecStopPost=/usr/local/bin/simplex-servers-stopscript smp-server
1010
LimitNOFILE=65535
1111
KillSignal=SIGINT
12+
TimeoutStartSec=infinity
1213
TimeoutStopSec=infinity
14+
AmbientCapabilities=CAP_NET_BIND_SERVICE
1315

1416
[Install]
1517
WantedBy=multi-user.target

scripts/main/xftp-server.service

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ ExecStart=/usr/local/bin/xftp-server start +RTS -N -RTS
99
ExecStopPost=/usr/local/bin/simplex-servers-stopscript xftp-server
1010
LimitNOFILE=65535
1111
KillSignal=SIGINT
12+
TimeoutStartSec=infinity
1213
TimeoutStopSec=infinity
1314
AmbientCapabilities=CAP_NET_BIND_SERVICE
1415

0 commit comments

Comments
 (0)