From 627c3a0ad66da96aee06b02b2af5558f679ea0ae Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 15 Sep 2021 12:28:35 +0000 Subject: [PATCH 1/2] Set default TPM CA attestation public key --- config/prod.exs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/config/prod.exs b/config/prod.exs index 1763ed3a2..1b50e5d0e 100755 --- a/config/prod.exs +++ b/config/prod.exs @@ -79,7 +79,12 @@ config :archethic, ArchEthic.BeaconChain.SummaryTimer, config :archethic, ArchEthic.Crypto, root_ca_public_keys: [ - tpm: System.get_env("ARCHETHIC_CRYPTO_ROOT_CA_TPM_PUBKEY", "") |> Base.decode16!(case: :mixed) + tpm: + System.get_env( + "ARCHETHIC_CRYPTO_ROOT_CA_TPM_PUBKEY", + "3059301306072a8648ce3d020106082a8648ce3d03010703420004f0fe701a03ce375a6e57adbe0255808812036571c1424db2779c77e8b4a9ba80a15b118e8e7465ee2e94094e59c4b3f7177e99063af1b19bfcc4d7e1ac3f89dd" + ) + |> Base.decode16!(case: :mixed) ], key_certificates_dir: System.get_env("ARCHETHIC_CRYPTO_CERT_DIR", "~/aebot/key_certificates") From 02c990d3b8b5d1f42e2da2381de778fb154dbec7 Mon Sep 17 00:00:00 2001 From: Samuel Date: Wed, 15 Sep 2021 12:29:16 +0000 Subject: [PATCH 2/2] Create systemd service when the release is installed --- scripts/release.sh | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 54dce844e..5088bf059 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -3,7 +3,8 @@ set -e trap 'echo "******* FAILED *******" 1>&2' ERR -INSTALL_DIR=~/aebot/build +USER=$(whoami) +INSTALL_DIR=/home/$USER/aebot/build UPGRADE=0 usage() { @@ -71,7 +72,7 @@ then echo "Run the upgrade" $INSTALL_DIR/bin/archethic_node upgrade ${VERSION} else - # Build the releases + # Build and install the releases echo "Generate release" MIX_ENV=prod mix distillery.release @@ -79,6 +80,46 @@ else echo "Install release" tar zxvf _build/prod/rel/archethic_node/releases/$VERSION/archethic_node.tar.gz -C $INSTALL_DIR echo "Release has been installed on ${INSTALL_DIR}" + + echo "Creating service file" + sudo bash -c 'cat > /etc/systemd/system/archethic.service' << EOF + + [Unit] + Description=ARCHEthic service + After=local-fs.target network.target + + [Service] + Type=simple + User=$USER + Group=$USER + + WorkingDirectory=$INSTALL_DIR + + ExecStart=$INSTALL_DIR/bin/archethic_node foreground + ExecStop=$INSTALL_DIR/bin/archethic_node stop + + EnvironmentFile=/etc/default/archethic.env + Environment=LANG=en_US.utf8 + Environment=MIX_ENV=prod + + Restart=on-failure + RemainAfterExit=yes + RestartSec=5 + + LimitNOFILE=65535 + UMask=0027 + SyslogIdentifier=archethic + + [Install] + WantedBy=multi-user.target +EOF + + # restart daemon, enable and start service + echo "Reloading daemon and enabling service" + sudo systemctl daemon-reload + sudo systemctl enable archethic + sudo systemctl start archethic + echo "Service Started" fi exit