From 388e4d2bcc41f8688e643301daadb109b1e486a2 Mon Sep 17 00:00:00 2001 From: Efim Poberezkin <8711996+efim-poberezkin@users.noreply.github.com> Date: Fri, 24 Dec 2021 15:34:09 +0400 Subject: [PATCH] update server recipes - Linode & DigitalOcean (#239) --- README.md | 14 +++++++++----- scripts/smp-server-digitalocean-droplet/README.md | 6 +++--- .../files/opt/simplex/on_login.sh | 2 +- .../scripts/03-init-start.sh | 6 ++++-- scripts/smp-server-linode.sh | 12 +++++++----- 5 files changed, 24 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index f865e2dd8..9a6953f87 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,9 @@ It's the easiest to try SMP agent via a prototype [simplex-chat](https://github. ## Deploy SMP server on Linode -You can get Linode [free credits](https://www.linode.com/lp/affiliate-referral/?irclickid=02-QkdTEpxyLW0W0EOSREQreUkB2DtzGE2lGTE0&irgwc=1&utm_source=impact) to deploy SMP server. + + +\* You can get [Linode free credits](https://www.linode.com/lp/affiliate-referral/?irclickid=02-QkdTEpxyLW0W0EOSREQreUkB2DtzGE2lGTE0&irgwc=1&utm_source=impact) to deploy SMP server. Deployment on Linode is performed via StackScripts, which serve as recipes for Linode instances, also called Linodes. To deploy SMP server on Linode: @@ -108,13 +110,15 @@ Please submit an [issue](https://github.com/simplex-chat/simplexmq/issues) if an ## Deploy SMP server on DigitalOcean -You can deploy SMP server using [SimpleX Server 1-click app](https://marketplace.digitalocean.com/apps/simplex-server) from DigitalOcean marketplace: +\* When creating a DigitalOcean account you can use [this link](https://try.digitalocean.com/freetrialoffer/) to get free credits. (You would still be required either to provide your credit card details or make a confirmation pre-payment with PayPal) + +To deploy SMP server use [SimpleX Server 1-click app](https://marketplace.digitalocean.com/apps/simplex-server) from DigitalOcean marketplace: - Create a DigitalOcean account or login with an already existing one. - Click 'Create SimpleX server Droplet' button. -- Choose the region and plan according to your requirements (cheapest Regular plan should be sufficient). -- Provide ssh key and confirm Droplet creation. -- SSH to created Droplet (`ssh root@`) to get SMP server public key hash - either from the welcome message or from `/etc/opt/simplex/pub_key_hash`. DigitalOcean has a good guide on [how to login to Droplet via ssh](https://docs.digitalocean.com/products/droplets/how-to/connect-with-ssh/). +- Choose the region and plan according to your requirements (Basic plan should be sufficient). +- Finalize Droplet creation. +- Open "Console" on your Droplet management page to get SMP server fingerprint - either from the welcome message or from `/etc/opt/simplex/fingerprint`. Alternatively you can manually SSH to created Droplet, see [instruction](https://docs.digitalocean.com/products/droplets/how-to/connect-with-ssh/). - Great, your own SMP server is ready! Use `ip_address#hash` as SMP server address in the client. Please submit an [issue](https://github.com/simplex-chat/simplexmq/issues) if any problems occur. diff --git a/scripts/smp-server-digitalocean-droplet/README.md b/scripts/smp-server-digitalocean-droplet/README.md index f38216775..7d58ad0f7 100644 --- a/scripts/smp-server-digitalocean-droplet/README.md +++ b/scripts/smp-server-digitalocean-droplet/README.md @@ -1,10 +1,10 @@ # Server image for DigitalOcean + ## How to build an image diff --git a/scripts/smp-server-digitalocean-droplet/files/opt/simplex/on_login.sh b/scripts/smp-server-digitalocean-droplet/files/opt/simplex/on_login.sh index ad7003218..73cc2a8d9 100644 --- a/scripts/smp-server-digitalocean-droplet/files/opt/simplex/on_login.sh +++ b/scripts/smp-server-digitalocean-droplet/files/opt/simplex/on_login.sh @@ -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) diff --git a/scripts/smp-server-digitalocean-droplet/scripts/03-init-start.sh b/scripts/smp-server-digitalocean-droplet/scripts/03-init-start.sh index b7be37ae2..6b1e39e98 100644 --- a/scripts/smp-server-digitalocean-droplet/scripts/03-init-start.sh +++ b/scripts/smp-server-digitalocean-droplet/scripts/03-init-start.sh @@ -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 diff --git a/scripts/smp-server-linode.sh b/scripts/smp-server-linode.sh index 60dfdcc70..81fd7e72c 100644 --- a/scripts/smp-server-linode.sh +++ b/scripts/smp-server-linode.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# -# +# +# # 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 <> $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)