update server recipes - Linode & DigitalOcean (#239)

This commit is contained in:
Efim Poberezkin
2021-12-24 15:34:09 +04:00
committed by GitHub
parent 0c866105d2
commit 388e4d2bcc
5 changed files with 24 additions and 16 deletions
@@ -1,10 +1,10 @@
# Server image for DigitalOcean
<!-- TODO tested on a fresh DO droplet and this seems to be wrong - we have to update the image to behave as described.
The current image used for 1-click deployment on DigitalOcean does not contain the source or binary of SMP Server - it downloads the compiled binary of the latest release (rather than a particular release) from GitHub.
The upside is that the new image does not have to be created and approved by DigitalOcean every time when the new release is created.
The downside is that while the release is being prepared in CI, when the release object is already created in GitHub but the server binary is not attached yet, the attempt to install the server would fail - it can last anything from several to 20 minutes, depending on whether the cached dependencies were used or everything was recompiled. Currently, when there is a small number of users, it is not a big problem, but we should consider some possible solutions in the future. Linode StackScript has the same issue.
The upside is that the new image does not have to be created and approved by DigitalOcean every time when the new release is created. -->
## How to build an image
@@ -1,5 +1,5 @@
#!/bin/bash
# receives pubkey_hash file location as the first parameter
# receives fingerprint file location as the first parameter
ip_address=$(hostname -I | awk '{print$1}')
hash=$(cat $1)
@@ -45,10 +45,12 @@ EOT
chmod 644 /etc/systemd/system/smp-server.service
echo "initializing SMP server"
hash_file="$conf_dir/pubkey_hash"
smp-server init -l | grep "transport key hash:" | cut -f2 -d":" | xargs > $hash_file
smp-server init -l
# CA certificate (identity/offline) fingerprint
hash_file="$conf_dir/fingerprint"
# turn off websockets support
sed -e '/websockets/s/^/# /g' -i $conf_dir/smp-server.ini
# add welcome script to .bashrc
echo "bash /opt/simplex/on_login.sh $hash_file" >> /root/.bashrc
+7 -5
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# <UDF name="enable_store_log" label="Store log - persists SMP queues to append only log and restores them upon server restart." default="on" oneof="on, off" />
# <UDF name="api_token" label="Linode API token - enables StackScript to create tags containing SMP server domain/ip address, transport key hash and server version. Use `domain#hash` or `ip#hash` as SMP server address in the client. Note: minimal permissions token should have are - read/write access to `linodes` (to update linode tags - you need them) and `domains` (to add A record for the chosen 3rd level domain)" default="" />
# <UDF name="fqdn" label="FQDN (Fully qualified domain name) - provide third level domain name (ex: smp.example.com). If provided can be used instead of ip address." default="" />
# <UDF name="api_token" label="Linode API token - enables StackScript to create tags containing SMP server FQDN / IP address, CA certificate fingerprint and server version. Use `fqdn#fingerprint` or `ip#fingerprint` as SMP server address in the client. Note: minimal permissions token should have are - read/write access to `linodes` (to update linode tags) and `domains` (to add A record for the chosen 3rd level domain)" default="" />
# <UDF name="fqdn" label="FQDN (Fully qualified domain name) - provide third level domain name (ex: smp.example.com). If provided can be used instead of IP address." default="" />
# log all stdout output to stackscript.log
exec &> >(tee -i /var/log/stackscript.log)
@@ -48,15 +48,17 @@ source /etc/profile.d/simplex.sh
# initialize SMP server
init_opts=()
[[ $ENABLE_STORE_LOG == "on" ]] && init_opts+=(-l)
hash_file="$conf_dir/pubkey_hash"
smp-server init "${init_opts[@]}" | grep "transport key hash:" | cut -f2 -d":" | xargs > $hash_file
smp-server init "${init_opts[@]}"
# CA certificate (identity/offline) fingerprint
hash_file="$conf_dir/fingerprint"
# turn off websockets support
sed -e '/websockets/s/^/# /g' -i $conf_dir/smp-server.ini
# create script that will run on login
on_login_script="/opt/simplex/on_login.sh"
cat <<EOT >> $on_login_script
#!/bin/bash
# receives pubkey_hash file location as the first parameter
# receives fingerprint file location as the first parameter
ip_address=\$(hostname -I | awk '{print\$1}')
hash=\$(cat \$1)