From 5b666b896d008bb8c2890d41eddddc19aec3c55c Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 17 Oct 2019 09:47:25 +0900 Subject: [PATCH 1/3] Update service names License: MIT Signed-off-by: Jakub Sztandera --- scripts/deploy-node.sh | 4 ++-- scripts/{daemon.service => lotus-daemon.service} | 2 +- scripts/{sminer.service => lotus-miner.service} | 3 ++- scripts/setup-host.sh | 4 ++-- 4 files changed, 7 insertions(+), 6 deletions(-) rename scripts/{daemon.service => lotus-daemon.service} (78%) rename scripts/{sminer.service => lotus-miner.service} (72%) diff --git a/scripts/deploy-node.sh b/scripts/deploy-node.sh index e77b0201d..4826023cf 100755 --- a/scripts/deploy-node.sh +++ b/scripts/deploy-node.sh @@ -11,8 +11,8 @@ ssh "$HOST" 'systemctl stop lotus-daemon' ssh "$HOST" 'mkdir -p .lotus .lotusstorage' & scp "./lotus" "$HOST:/usr/local/bin" & scp "./lotus-storage-miner" "$HOST:/usr/local/bin" & -scp -C scripts/daemon.service "${HOST}:/etc/systemd/system/lotus-daemon.service" & -scp -C scripts/sminer.service "${HOST}:/etc/systemd/system/lotus-storage-miner.service" & +scp -C scripts/lotus-daemon.service "${HOST}:/etc/systemd/system/lotus-daemon.service" & +scp -C scripts/louts-miner.service "${HOST}:/etc/systemd/system/lotus-storage-miner.service" & wait ssh "$HOST" 'systemctl daemon-reload' diff --git a/scripts/daemon.service b/scripts/lotus-daemon.service similarity index 78% rename from scripts/daemon.service rename to scripts/lotus-daemon.service index 8d93518b5..44b2058b0 100644 --- a/scripts/daemon.service +++ b/scripts/lotus-daemon.service @@ -4,7 +4,7 @@ After=network.target [Service] ExecStart=/usr/local/bin/lotus daemon -Environment=GOLOG_FILE="/root/.lotus/logs" +Environment=GOLOG_FILE="/var/log/lotus-daemon" Environment=GOLOG_LOG_FMT="json" [Install] diff --git a/scripts/sminer.service b/scripts/lotus-miner.service similarity index 72% rename from scripts/sminer.service rename to scripts/lotus-miner.service index ed966a5d2..7b866e043 100644 --- a/scripts/sminer.service +++ b/scripts/lotus-miner.service @@ -1,10 +1,11 @@ [Unit] Description=Lotus Storage Miner After=network.target +After=lotus-daemon.service [Service] ExecStart=/usr/local/bin/lotus-storage-miner run -Environment=GOLOG_FILE="/root/.lotusstorage/logs" +Environment=GOLOG_FILE="/var/log/lotus-miner" Environment=GOLOG_LOG_FMT="json" [Install] diff --git a/scripts/setup-host.sh b/scripts/setup-host.sh index 9372e1678..bda0a2c98 100755 --- a/scripts/setup-host.sh +++ b/scripts/setup-host.sh @@ -2,5 +2,5 @@ HOST=$1 -scp scripts/daemon.service "${HOST}:/etc/systemd/system/lotus-daemon.service" -scp scripts/sminer.service "${HOST}:/etc/systemd/system/lotus-storage-miner.service" +scp scripts/lotus-daemon.service "${HOST}:/etc/systemd/system/lotus-daemon.service" +scp scripts/lotus-miner.service "${HOST}:/etc/systemd/system/lotus-storage-miner.service" From 0a2e33924587c9eceeab04bd92950aee2f57df10 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 17 Oct 2019 10:10:12 +0900 Subject: [PATCH 2/3] Update the deploy script License: MIT Signed-off-by: Jakub Sztandera --- scripts/deploy-node.sh | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/scripts/deploy-node.sh b/scripts/deploy-node.sh index 4826023cf..4e954773d 100755 --- a/scripts/deploy-node.sh +++ b/scripts/deploy-node.sh @@ -1,23 +1,38 @@ #!/usr/bin/env bash +set -euo pipefail +IFS=$'\n\t' + + HOST=$1 # upload binaries # TODO: destroy -ssh "$HOST" 'systemctl stop lotus-storage-miner' -ssh "$HOST" 'systemctl stop lotus-daemon' +FILES_TO_SEND=( + ./louts + ./lotus-storage-miner + scripts/lotus-daemon.service + scripts/louts-miner.service +) -ssh "$HOST" 'mkdir -p .lotus .lotusstorage' & -scp "./lotus" "$HOST:/usr/local/bin" & -scp "./lotus-storage-miner" "$HOST:/usr/local/bin" & -scp -C scripts/lotus-daemon.service "${HOST}:/etc/systemd/system/lotus-daemon.service" & -scp -C scripts/louts-miner.service "${HOST}:/etc/systemd/system/lotus-storage-miner.service" & -wait +rsync -P "${FILES_TO_SEND[@]} $HOST:~/lotus-stage/ -ssh "$HOST" 'systemctl daemon-reload' -ssh "$HOST" 'systemctl start lotus-daemon' & -wait +ssh "$HOST" 'bash -s' << EOF +set -euo pipefail + +systemctl stop lotus-storage-miner +systemctl stop lotus-daemon +mkdir -p .lotus .lotusstorage + +cd "$HOME/lotus-stage/" +cp -f louts lotus-storage-miner /usr/local/bin +cp -f lotus-daemon.service /etc/systemd/system/lotus-daemon.service +cp -f lotus-miner.service /etc/systemd/system/lotus-storage-miner.service + +systemctl daemon-reload +systemctl start lotus-daemon +EOF # setup miner actor From 21f4664294be86d8210cd21ba8ce264165d1fc97 Mon Sep 17 00:00:00 2001 From: Jakub Sztandera Date: Thu, 17 Oct 2019 13:24:32 +0900 Subject: [PATCH 3/3] Fix shellcheck License: MIT Signed-off-by: Jakub Sztandera --- scripts/deploy-node.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/deploy-node.sh b/scripts/deploy-node.sh index 4e954773d..4fc3d9aff 100755 --- a/scripts/deploy-node.sh +++ b/scripts/deploy-node.sh @@ -16,9 +16,9 @@ FILES_TO_SEND=( scripts/louts-miner.service ) -rsync -P "${FILES_TO_SEND[@]} $HOST:~/lotus-stage/ +rsync -P "${FILES_TO_SEND[@]}" "$HOST:~/lotus-stage/" -ssh "$HOST" 'bash -s' << EOF +ssh "$HOST" 'bash -s' << 'EOF' set -euo pipefail systemctl stop lotus-storage-miner