From 60b667d596a6da6ff8d867d34a41bc79be2a6761 Mon Sep 17 00:00:00 2001
From: Nikita Spivachuk
Date: Mon, 14 Mar 2022 17:20:00 +0000
Subject: [PATCH 1/5] Added `switch_to_cosmovisor` script
- Added `switch_to_cosmovisor` script.
- Added some help output to `run_dcl_node` script.
---
deployment/scripts/run_dcl_node | 3 +
deployment/scripts/switch_to_cosmovisor | 121 ++++++++++++++++++++++++
2 files changed, 124 insertions(+)
create mode 100755 deployment/scripts/switch_to_cosmovisor
diff --git a/deployment/scripts/run_dcl_node b/deployment/scripts/run_dcl_node
index fc20df5ca..b51b4b406 100755
--- a/deployment/scripts/run_dcl_node
+++ b/deployment/scripts/run_dcl_node
@@ -501,6 +501,9 @@ wait_node_up
echo -e "\nexport PATH=\$PATH:$CURRENT_APP_DIR" >> "$HOME"/.profile
source "$HOME"/.profile
+echo "Added '${CURRENT_APP_DIR}' to PATH to maintain 'dcld' command associated with the latest installed app binary."
+echo "Execute 'source ~/.profile' or restart shell to take the PATH change effective."
+
STATUS="$(dcld status)"
VAL_ID="$(_jq "$STATUS"| grep '"id"' | awk '{print $NF}' | sed -e 's/^"//' -e 's/[",]\+$//')"
VAL_ADDR="$(dcld tendermint show-address)"
diff --git a/deployment/scripts/switch_to_cosmovisor b/deployment/scripts/switch_to_cosmovisor
new file mode 100755
index 000000000..119eced27
--- /dev/null
+++ b/deployment/scripts/switch_to_cosmovisor
@@ -0,0 +1,121 @@
+#!/bin/bash
+# Copyright 2020 DSR Corporation
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -eu
+set -o pipefail
+
+GENESIS_APP_DIR="$HOME/.dcl/cosmovisor/genesis/bin"
+CURRENT_APP_DIR="$HOME/.dcl/cosmovisor/current/bin"
+
+DEF_NODE_USER="ubuntu"
+CURR_USER="${USER:-$(whoami 2>/dev/null)}"
+NODE_USER="${CURR_USER:-$DEF_NODE_USER}"
+
+function wait_node_up {
+ local _timeout="${1:-5}"
+ local _try=1
+
+ echo -e "Waiting the node becomes up"
+ until ./dcld status >/dev/null 2>&1
+ do
+ if [[ "$_try" -gt "$_timeout" ]]; then
+ echo -e "\nERROR: dcld node seems not ready after $_timeout seconds."
+ return 1
+ fi
+ echo -n "."
+ _try=$(( $_try + 1 ))
+ sleep 1
+ done
+ echo -e "\n\tNode is responding"
+}
+
+if [[ ! -d "/etc/systemd/system" ]]; then
+ echo "Error. Not a systemd system. This script supports systemd systems only."
+ exit 1
+fi
+
+if [[ ! -f "./dcld" ]]; then
+ echo "Error. './dcld' file not found"
+ exit 1
+fi
+
+if [[ ! -f "./cosmovisor" ]]; then
+ echo "Error. './cosmovisor' file not found"
+ exit 1
+fi
+
+if [[ ! -f "./cosmovisor.service" ]]; then
+ echo "Error. './cosmovisor.service' file not found"
+ exit 1
+fi
+
+if [[ ! -f "/etc/systemd/system/dcld.service" ]]; then
+ echo "Error. '/etc/systemd/system/dcld.service' file not found"
+ exit 1
+fi
+
+OLD_NODE_USER=$(cat /etc/systemd/system/dcld.service | sed -n "s~^User=\([a-z_][a-z0-9_-]*[$]\?\)$~\1~p")
+
+if [[ "$NODE_USER" != "$OLD_NODE_USER" ]]; then
+ echo "Error. Wrong current user: '${NODE_USER}'. Expected user: '${OLD_NODE_USER}', on behalf of whom 'dcld' service was previously run."
+ exit 1
+fi
+
+if ! systemctl is-active --quiet dcld; then
+ echo "Error. 'dcld' service is not running. Transition to cosmovisor will not be performed."
+ exit 1
+fi
+
+sudo systemctl stop dcld
+echo "Stopped 'dcld' service"
+
+sudo systemctl disable dcld
+
+sudo rm -f /etc/systemd/system/dcld.service
+echo "Removed 'dcld' service"
+
+sudo rm -f /usr/bin/dcld
+echo "Removed old stand-alone 'dcld' binary from '/usr/bin/'"
+
+sudo cp -f ./cosmovisor /usr/bin/
+echo "Copied 'cosmovisor' to '/usr/bin/'"
+
+mkdir -p "$GENESIS_APP_DIR"
+echo "Created '${GENESIS_APP_DIR}' directory treated by cosmovisor as path to genesis app version"
+
+sudo cp -f ./dcld "${GENESIS_APP_DIR}/"
+echo "Copied new 'dcld' binary to '${GENESIS_APP_DIR}/'"
+
+# set up systemd cosmovisor.service
+sed -i -r "s~^User=ubuntu$~User=${NODE_USER}~" ./cosmovisor.service
+sed -i -r "s~\"DAEMON_HOME=/var/lib/ubuntu/.dcl\"~\"DAEMON_HOME=${HOME}/.dcl\"~" ./cosmovisor.service
+
+sudo cp -f ./cosmovisor.service /etc/systemd/system/
+echo "Added 'cosmovisor' service"
+
+sudo systemctl enable cosmovisor
+
+sudo systemctl start cosmovisor
+echo "Started 'cosmovisor' service"
+
+echo -e "\tUse 'systemctl status cosmovisor' to get the node service status."
+echo "Use 'journalctl -u cosmovisor.service -f' to see node logs."
+
+echo -e "\nexport PATH=\$PATH:$CURRENT_APP_DIR" >> "$HOME"/.profile
+
+echo "Added '${CURRENT_APP_DIR}' to PATH to maintain 'dcld' command associated with the latest installed app binary."
+echo "Execute 'source ~/.profile' or restart shell to take the PATH change effective."
+
+wait_node_up
From 2c5a81c798a48c10f07f534b38e2cbb8e32f2d6e Mon Sep 17 00:00:00 2001
From: Nikita Spivachuk
Date: Tue, 15 Mar 2022 15:25:49 +0000
Subject: [PATCH 2/5] Corrected run_dcl_node and switch_to_cosmovisor
- Corrected granting permissions on dcld binary in run_dcl_node and switch_to_cosmovisor scripts.
- Removed redundant step on locating dcld binary in genesis app directory from running-node.md.
- Corrected steps on granting permissions on dcld binary in running--node.md files.
- Added switch-to-cosmovisor-how-to.md (not completed yet).
---
deployment/scripts/run_dcl_node | 5 +++++
deployment/scripts/switch_to_cosmovisor | 9 ++++++++-
docs/advanced/running-genesis-node.md | 8 ++++++--
docs/advanced/running-observer-node.md | 8 ++++++--
docs/advanced/running-validator-node.md | 8 ++++++--
docs/advanced/switch-to-cosmovisor-how-to.md | 16 ++++++++++++++++
docs/running-node.md | 7 ++-----
7 files changed, 49 insertions(+), 12 deletions(-)
create mode 100644 docs/advanced/switch-to-cosmovisor-how-to.md
diff --git a/deployment/scripts/run_dcl_node b/deployment/scripts/run_dcl_node
index b51b4b406..deaaa9cce 100755
--- a/deployment/scripts/run_dcl_node
+++ b/deployment/scripts/run_dcl_node
@@ -491,6 +491,11 @@ echo -e "\nOptionally, edit '$CONFIG_FILE' in order to set different setting (li
echo "Locating the genesis app version to $GENESIS_APP_DIR directory"
mkdir -p "$GENESIS_APP_DIR"
cp -f ./dcld "$GENESIS_APP_DIR"/
+sudo chown "$NODE_USER" "$GENESIS_APP_DIR"/dcld
+# Execution permissions on `dcld` are granted to all (i.e. User, Group and Others classes)
+# because cosmovisor requires execution permission on the application binary to be granted to Others class:
+# https://github.com/cosmos/cosmos-sdk/blob/cosmovisor/v1.0.0/cosmovisor/upgrade.go#L164
+sudo chmod a+x "$GENESIS_APP_DIR"/dcld
echo "Running the node"
run_node
diff --git a/deployment/scripts/switch_to_cosmovisor b/deployment/scripts/switch_to_cosmovisor
index 119eced27..10f4c1572 100755
--- a/deployment/scripts/switch_to_cosmovisor
+++ b/deployment/scripts/switch_to_cosmovisor
@@ -90,12 +90,19 @@ sudo rm -f /usr/bin/dcld
echo "Removed old stand-alone 'dcld' binary from '/usr/bin/'"
sudo cp -f ./cosmovisor /usr/bin/
+sudo chown "$NODE_USER" /usr/bin/cosmovisor
+sudo chmod u+x /usr/bin/cosmovisor
echo "Copied 'cosmovisor' to '/usr/bin/'"
mkdir -p "$GENESIS_APP_DIR"
echo "Created '${GENESIS_APP_DIR}' directory treated by cosmovisor as path to genesis app version"
-sudo cp -f ./dcld "${GENESIS_APP_DIR}/"
+sudo cp -f ./dcld "$GENESIS_APP_DIR"/
+sudo chown "$NODE_USER" "$GENESIS_APP_DIR"/dcld
+# Execution permissions on `dcld` are granted to all (i.e. User, Group and Others classes)
+# because cosmovisor requires execution permission on the application binary to be granted to Others class:
+# https://github.com/cosmos/cosmos-sdk/blob/cosmovisor/v1.0.0/cosmovisor/upgrade.go#L164
+sudo chmod a+x "$GENESIS_APP_DIR"/dcld
echo "Copied new 'dcld' binary to '${GENESIS_APP_DIR}/'"
# set up systemd cosmovisor.service
diff --git a/docs/advanced/running-genesis-node.md b/docs/advanced/running-genesis-node.md
index ad855612d..efb490a91 100644
--- a/docs/advanced/running-genesis-node.md
+++ b/docs/advanced/running-genesis-node.md
@@ -36,9 +36,13 @@ The following components will be needed:
### Deployment steps
-1. Put `cosmovisor` binary to `/usr/bin/` and configure permissions.
+1. Put `cosmovisor` binary to `/usr/bin/`, set proper owner and execution permissions.
-2. Create `$HOME/.dcl/cosmovisor/genesis/bin` directory and copy `dcld` binary to it.
+2. Locate the genesis app version to genesis application version directory:
+ * Create `$HOME/.dcl/cosmovisor/genesis/bin` directory.
+ * Copy `dcld` binary to it, set proper owner and execution permissions.
+ Please note that execution permissions on `dcld` should be granted to all (i.e. User, Group and Others classes)
+ because cosmovisor requires execution permission on the application binary to be granted to Others class.
3. Choose the chain ID. Every network (for example, test-net, main-net, etc.)
must have a unique chain ID.
diff --git a/docs/advanced/running-observer-node.md b/docs/advanced/running-observer-node.md
index f521e6a12..8b06b139e 100644
--- a/docs/advanced/running-observer-node.md
+++ b/docs/advanced/running-observer-node.md
@@ -46,9 +46,13 @@ and contains the genesis and persistent_peers files.
### Deployment steps
-1. Put `cosmovisor` binary to `/usr/bin/` and configure permissions.
+1. Put `cosmovisor` binary to `/usr/bin/`, set proper owner and execution permissions.
-2. Create `$HOME/.dcl/cosmovisor/genesis/bin` directory and copy `dcld` binary to it.
+2. Locate the genesis app version to genesis application version directory:
+ * Create `$HOME/.dcl/cosmovisor/genesis/bin` directory.
+ * Copy `dcld` binary to it, set proper owner and execution permissions.
+ Please note that execution permissions on `dcld` should be granted to all (i.e. User, Group and Others classes)
+ because cosmovisor requires execution permission on the application binary to be granted to Others class.
3. Configure CLI:
- `./dcld config chain-id testnet`
diff --git a/docs/advanced/running-validator-node.md b/docs/advanced/running-validator-node.md
index b12bc9054..ea04ecbeb 100644
--- a/docs/advanced/running-validator-node.md
+++ b/docs/advanced/running-validator-node.md
@@ -46,9 +46,13 @@ and contains the genesis and persistent_peers files.
### Deployment steps
-1. Put `cosmovisor` binary to `/usr/bin/` and configure permissions.
+1. Put `cosmovisor` binary to `/usr/bin/`, set proper owner and execution permissions.
-2. Create `$HOME/.dcl/cosmovisor/genesis/bin` directory and copy `dcld` binary to it.
+2. Locate the genesis app version to genesis application version directory:
+ * Create `$HOME/.dcl/cosmovisor/genesis/bin` directory.
+ * Copy `dcld` binary to it, set proper owner and execution permissions.
+ Please note that execution permissions on `dcld` should be granted to all (i.e. User, Group and Others classes)
+ because cosmovisor requires execution permission on the application binary to be granted to Others class.
3. Configure CLI:
- `./dcld config chain-id `
diff --git a/docs/advanced/switch-to-cosmovisor-how-to.md b/docs/advanced/switch-to-cosmovisor-how-to.md
new file mode 100644
index 000000000..fc729442b
--- /dev/null
+++ b/docs/advanced/switch-to-cosmovisor-how-to.md
@@ -0,0 +1,16 @@
+# Switch to Cosmovisor: How To
+
+This document describes the procedure how to switch a node from direct use of `dcld` binary to use of `cosmovisor` process manager which controls `dcld` process and supports DCL application upgrades that includes `dcld` binary updates and store migrations.
+
+Switching to use of `cosmovisor` is performed by `switch_to_cosmovisor` script. This procedure does not include any store migrations. So it can be applied only if the diff between the target and source versions of `dcld` does not include any breaking changes of the store.
+
+Assumptions:
+* `switch_to_cosmovisor` script assumes that old `dcld` binary is located in `/usr/bin` directory. The script is operable in this case only.
+
+Pre-requisites:
+* `dcld` is launched as `dcld` systemd service.
+* `dcld` systemd service is currently running, i.e. is in active state.
+* The following files, taken from a DCL release, have been put into the current working directory from where the script is executed:
+ * new `dcld` binary (that will be controlled by `cosmovisor` and so should include the upgrade feature)
+ * `cosmovisor` binary
+ * `cosmovisor.service`
diff --git a/docs/running-node.md b/docs/running-node.md
index 6eaad0308..f2d808d77 100644
--- a/docs/running-node.md
+++ b/docs/running-node.md
@@ -111,9 +111,8 @@ curl -L -O https://raw.githubusercontent.com/zigbee-alliance/distributed-complia
### Setup DCL binaries
* put `cosmovisor` binary in a folder listed in `$PATH` (e.g. `/usr/bin/`)
-* set a proper owner and executable permissions
-* create `$HOME/.dcl/cosmovisor/genesis/bin` directory for the genesis version of the application binary
-* copy `dcld` binary to the created directory, but do not remove it from the current working directory (to be able to perform initialization steps below)
+* set owner of `cosmovisor` binary to the user who will be used for `cosmovisor` service to run as
+* set executable permission on `cosmovisor` binary for owner
@@ -124,8 +123,6 @@ curl -L -O https://raw.githubusercontent.com/zigbee-alliance/distributed-complia
sudo cp -f ./cosmovisor -t /usr/bin
sudo chown ubuntu /usr/bin/cosmovisor
sudo chmod u+x /usr/bin/cosmovisor
-mkdir -p "$HOME/.dcl/cosmovisor/genesis/bin"
-cp -f ./dcld -t "$HOME/.dcl/cosmovisor/genesis/bin"
```
From 974cc474f12fd2d1fe323b549ff93a6678a16778 Mon Sep 17 00:00:00 2001
From: Nikita Spivachuk
Date: Wed, 16 Mar 2022 06:58:44 +0000
Subject: [PATCH 3/5] Corrected switch_to_cosmovisor script, completed how-to
document for it
---
deployment/scripts/switch_to_cosmovisor | 26 +++++++---
docs/advanced/switch-to-cosmovisor-how-to.md | 51 ++++++++++++++++----
docs/running-node.md | 1 -
3 files changed, 59 insertions(+), 19 deletions(-)
diff --git a/deployment/scripts/switch_to_cosmovisor b/deployment/scripts/switch_to_cosmovisor
index 10f4c1572..68c140929 100755
--- a/deployment/scripts/switch_to_cosmovisor
+++ b/deployment/scripts/switch_to_cosmovisor
@@ -24,7 +24,7 @@ CURR_USER="${USER:-$(whoami 2>/dev/null)}"
NODE_USER="${CURR_USER:-$DEF_NODE_USER}"
function wait_node_up {
- local _timeout="${1:-5}"
+ local _timeout="${1:-60}"
local _try=1
echo -e "Waiting the node becomes up"
@@ -47,7 +47,7 @@ if [[ ! -d "/etc/systemd/system" ]]; then
fi
if [[ ! -f "./dcld" ]]; then
- echo "Error. './dcld' file not found"
+ echo "Error. './dcld' file to install not found"
exit 1
fi
@@ -61,6 +61,15 @@ if [[ ! -f "./cosmovisor.service" ]]; then
exit 1
fi
+OLD_DCLD="$(which dcld)"
+
+if [[ -z "$OLD_DCLD" ]]; then
+ echo "Error. No installed 'dcld' found"
+ exit 1
+fi
+
+BIN_DIR="$(dirname "$OLD_DCLD")"
+
if [[ ! -f "/etc/systemd/system/dcld.service" ]]; then
echo "Error. '/etc/systemd/system/dcld.service' file not found"
exit 1
@@ -86,13 +95,13 @@ sudo systemctl disable dcld
sudo rm -f /etc/systemd/system/dcld.service
echo "Removed 'dcld' service"
-sudo rm -f /usr/bin/dcld
-echo "Removed old stand-alone 'dcld' binary from '/usr/bin/'"
+sudo rm -f "$BIN_DIR"/dcld
+echo "Removed old stand-alone 'dcld' binary from '${BIN_DIR}'"
-sudo cp -f ./cosmovisor /usr/bin/
-sudo chown "$NODE_USER" /usr/bin/cosmovisor
-sudo chmod u+x /usr/bin/cosmovisor
-echo "Copied 'cosmovisor' to '/usr/bin/'"
+sudo cp -f ./cosmovisor "$BIN_DIR"/
+sudo chown "$NODE_USER" "$BIN_DIR"/cosmovisor
+sudo chmod u+x "$BIN_DIR"/cosmovisor
+echo "Copied 'cosmovisor' to '${BIN_DIR}'"
mkdir -p "$GENESIS_APP_DIR"
echo "Created '${GENESIS_APP_DIR}' directory treated by cosmovisor as path to genesis app version"
@@ -126,3 +135,4 @@ echo "Added '${CURRENT_APP_DIR}' to PATH to maintain 'dcld' command associated w
echo "Execute 'source ~/.profile' or restart shell to take the PATH change effective."
wait_node_up
+echo "Done"
diff --git a/docs/advanced/switch-to-cosmovisor-how-to.md b/docs/advanced/switch-to-cosmovisor-how-to.md
index fc729442b..5044aee22 100644
--- a/docs/advanced/switch-to-cosmovisor-how-to.md
+++ b/docs/advanced/switch-to-cosmovisor-how-to.md
@@ -1,16 +1,47 @@
# Switch to Cosmovisor: How To
-This document describes the procedure how to switch a node from direct use of `dcld` binary to use of `cosmovisor` process manager which controls `dcld` process and supports DCL application upgrades that includes `dcld` binary updates and store migrations.
+This document describes the procedure of how to switch a node from direct use of
+`dcld` binary to use of `cosmovisor` process manager which controls `dcld`
+process and supports DCL application upgrades that include `dcld` binary updates
+and store migrations.
-Switching to use of `cosmovisor` is performed by `switch_to_cosmovisor` script. This procedure does not include any store migrations. So it can be applied only if the diff between the target and source versions of `dcld` does not include any breaking changes of the store.
+Switching to use of `cosmovisor` is performed by `switch_to_cosmovisor` script.
+This procedure does not include any store migrations. So it can be applied only
+if the difference between the previously installed stand-alone `dcld` binary and
+`dcld` binary to install with cosmovisor does not include any breaking changes
+of the store.
-Assumptions:
-* `switch_to_cosmovisor` script assumes that old `dcld` binary is located in `/usr/bin` directory. The script is operable in this case only.
+**Pre-requisites:**
-Pre-requisites:
* `dcld` is launched as `dcld` systemd service.
-* `dcld` systemd service is currently running, i.e. is in active state.
-* The following files, taken from a DCL release, have been put into the current working directory from where the script is executed:
- * new `dcld` binary (that will be controlled by `cosmovisor` and so should include the upgrade feature)
- * `cosmovisor` binary
- * `cosmovisor.service`
+* `dcld` systemd service is currently in active state (i.e. running).
+
+**Steps:**
+
+* Download new `dcld`, `cosmovisor` and `cosmovisor.service` from GitHub
+ [release page](https://github.com/zigbee-alliance/distributed-compliance-ledger/releases)
+
+ Example using curl:
+ ```bash
+ curl -L -O https://github.com/zigbee-alliance/distributed-compliance-ledger/releases/download//dcld
+ curl -L -O https://github.com/zigbee-alliance/distributed-compliance-ledger/releases/download//cosmovisor
+ curl -L -O https://github.com/zigbee-alliance/distributed-compliance-ledger/releases/download//cosmovisor.service
+ ```
+
+* Download `switch_to_cosmovisor` script from [repository](../../deployment/scripts/)
+
+ Example using curl:
+ ```bash
+ curl -L -O https://raw.githubusercontent.com/zigbee-alliance/distributed-compliance-ledger/master/deployment/scripts/switch_to_cosmovisor
+ ```
+
+* Run `switch_to_cosmovisor` script:
+
+ ```bash
+ ./switch_to_cosmovisor
+ ```
+
+ When it is done, it will print:
+ ```
+ Done
+ ```
diff --git a/docs/running-node.md b/docs/running-node.md
index f2d808d77..27bc839af 100644
--- a/docs/running-node.md
+++ b/docs/running-node.md
@@ -87,7 +87,6 @@ rm -rf "$HOME/.dcl"
```bash
# release artifacts
curl -L -O https://github.com/zigbee-alliance/distributed-compliance-ledger/releases/download//dcld
-# TODO: Add cosmovisor to release
curl -L -O https://github.com/zigbee-alliance/distributed-compliance-ledger/releases/download//cosmovisor
curl -L -O https://github.com/zigbee-alliance/distributed-compliance-ledger/releases/download//cosmovisor.service
From bf479458a394f59cba635d1a43abd5da05fafc7a Mon Sep 17 00:00:00 2001
From: Nikita Spivachuk
Date: Wed, 16 Mar 2022 07:47:49 +0000
Subject: [PATCH 4/5] Added one more prerequisite to
switch-to-cosmovisor-how-to
---
deployment/scripts/switch_to_cosmovisor | 2 +-
docs/advanced/switch-to-cosmovisor-how-to.md | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/deployment/scripts/switch_to_cosmovisor b/deployment/scripts/switch_to_cosmovisor
index 68c140929..15b7dd0b3 100755
--- a/deployment/scripts/switch_to_cosmovisor
+++ b/deployment/scripts/switch_to_cosmovisor
@@ -78,7 +78,7 @@ fi
OLD_NODE_USER=$(cat /etc/systemd/system/dcld.service | sed -n "s~^User=\([a-z_][a-z0-9_-]*[$]\?\)$~\1~p")
if [[ "$NODE_USER" != "$OLD_NODE_USER" ]]; then
- echo "Error. Wrong current user: '${NODE_USER}'. Expected user: '${OLD_NODE_USER}', on behalf of whom 'dcld' service was previously run."
+ echo "Error. Wrong current user: '${NODE_USER}'. Expected user: '${OLD_NODE_USER}', on behalf of whom 'dcld' service is launched."
exit 1
fi
diff --git a/docs/advanced/switch-to-cosmovisor-how-to.md b/docs/advanced/switch-to-cosmovisor-how-to.md
index 5044aee22..579d3c8c8 100644
--- a/docs/advanced/switch-to-cosmovisor-how-to.md
+++ b/docs/advanced/switch-to-cosmovisor-how-to.md
@@ -14,7 +14,8 @@ of the store.
**Pre-requisites:**
* `dcld` is launched as `dcld` systemd service.
-* `dcld` systemd service is currently in active state (i.e. running).
+* `dcld` service is currently in active state (i.e. running).
+* The current user is the user on behalf of whom `dcld` service is launched.
**Steps:**
From 214863bb666d3d309a192e4918417a9ef305382d Mon Sep 17 00:00:00 2001
From: Nikita Spivachuk
Date: Wed, 16 Mar 2022 08:36:30 +0000
Subject: [PATCH 5/5] Corrected granting permissions in run_dcl_node and
switch_to_cosmovisor
---
deployment/scripts/run_dcl_node | 3 +++
deployment/scripts/switch_to_cosmovisor | 9 +++++++++
2 files changed, 12 insertions(+)
diff --git a/deployment/scripts/run_dcl_node b/deployment/scripts/run_dcl_node
index deaaa9cce..318c1e30b 100755
--- a/deployment/scripts/run_dcl_node
+++ b/deployment/scripts/run_dcl_node
@@ -452,6 +452,9 @@ if [[ "$verbosity" -ge 1 ]]; then
#echo -e "Parsed arguments:\n$parsed_args"
fi
+sudo chown "$NODE_USER" ./dcld
+sudo chmod u+x ./dcld
+
echo "Configuring CLI"
# Note. we consider that cli would connect to local node (default setting)
diff --git a/deployment/scripts/switch_to_cosmovisor b/deployment/scripts/switch_to_cosmovisor
index 15b7dd0b3..c47bbc7d1 100755
--- a/deployment/scripts/switch_to_cosmovisor
+++ b/deployment/scripts/switch_to_cosmovisor
@@ -41,6 +41,8 @@ function wait_node_up {
echo -e "\n\tNode is responding"
}
+### Preliminary checks
+
if [[ ! -d "/etc/systemd/system" ]]; then
echo "Error. Not a systemd system. This script supports systemd systems only."
exit 1
@@ -87,6 +89,8 @@ if ! systemctl is-active --quiet dcld; then
exit 1
fi
+### Old stand-alone dcld removal
+
sudo systemctl stop dcld
echo "Stopped 'dcld' service"
@@ -98,6 +102,11 @@ echo "Removed 'dcld' service"
sudo rm -f "$BIN_DIR"/dcld
echo "Removed old stand-alone 'dcld' binary from '${BIN_DIR}'"
+### Cosmovisor and new dcld installation
+
+sudo chown "$NODE_USER" ./dcld
+sudo chmod u+x ./dcld
+
sudo cp -f ./cosmovisor "$BIN_DIR"/
sudo chown "$NODE_USER" "$BIN_DIR"/cosmovisor
sudo chmod u+x "$BIN_DIR"/cosmovisor