From 2e4f8aead55a01afdbc167471ddb6ba13a98c1da Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Sat, 13 Nov 2021 17:29:41 +0000 Subject: [PATCH 1/4] Create and recursively chown .cheqnode directory --- build_tools/build_tar.sh | 2 -- build_tools/common.sh | 1 - build_tools/postinst | 6 +++++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/build_tools/build_tar.sh b/build_tools/build_tar.sh index 2cf96cd10..b6f44991d 100755 --- a/build_tools/build_tar.sh +++ b/build_tools/build_tar.sh @@ -24,5 +24,3 @@ mkdir -p $TMP_DIR cp $PATH_TO_BIN $TMP_DIR tar -czf $PATH_TAR $TMP_DIR - - diff --git a/build_tools/common.sh b/build_tools/common.sh index cd084258d..be34571d8 100644 --- a/build_tools/common.sh +++ b/build_tools/common.sh @@ -4,4 +4,3 @@ TMP_DIR=usr/bin OUTPUT_DIR=output TAR_ARCHIVE=${PKG_NAME}_${VERSION}.tar.gz PATH_TAR=$OUTPUT_DIR/$TAR_ARCHIVE - diff --git a/build_tools/postinst b/build_tools/postinst index 49aa97c6a..a1937883e 100644 --- a/build_tools/postinst +++ b/build_tools/postinst @@ -5,6 +5,7 @@ CHEQD_USER_NAME=cheqd # Home directory location can be passed when running dpkg -i if [ -z ${CHEQD_HOME_DIR+x} ]; then CHEQD_HOME_DIR=/home/${CHEQD_USER_NAME} + CHEQD_ROOT_DIR=${CHEQD_HOME_DIR}/.cheqdnode fi # If there is an argument then assume using as binary + script instead of apt @@ -18,13 +19,15 @@ if ! /usr/bin/getent passwd ${CHEQD_USER_NAME} > /dev/null 2>&1 ; then addgroup ${CHEQD_USER_NAME} --quiet echo "Home directory for user ${CHEQD_USER_NAME} will be set up as ${CHEQD_HOME_DIR}" adduser --system ${CHEQD_USER_NAME} --home ${CHEQD_HOME_DIR} --shell /bin/bash --ingroup ${CHEQD_USER_NAME} --quiet + mkdir -p ${CHEQD_ROOT_DIR} + chown -R ${CHEQD_USER_NAME}:${CHEQD_USER_NAME} ${CHEQD_ROOT_DIR} else echo "User home directory already exists. Skipping user initialisation." fi # Log directory can be overwritten while running dpkg if [ -z ${CHEQD_LOG_DIR+x} ]; then - CHEQD_LOG_DIR=${CHEQD_HOME_DIR}/.cheqdnode/log + CHEQD_LOG_DIR=${CHEQD_ROOT_DIR}/log fi # Create node log directory @@ -32,6 +35,7 @@ if [ ! -d "${CHEQD_LOG_DIR}" ] then echo "Node log directory not found. Initializing." mkdir -p ${CHEQD_LOG_DIR} + touch ${CHEQD_LOG_DIR}/stdout.log chown -R syslog:${CHEQD_USER_NAME} ${CHEQD_LOG_DIR} else echo "Node log directory exists. Skipping." From 76e15f6f82ab8502a94559a18369ef5f40941e81 Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Sat, 13 Nov 2021 17:44:06 +0000 Subject: [PATCH 2/4] Update postremove script to mop-up system service configurations for cheqd-noded --- build_tools/postremove | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/build_tools/postremove b/build_tools/postremove index 8e61eddbb..b0969a4a9 100644 --- a/build_tools/postremove +++ b/build_tools/postremove @@ -1,11 +1,38 @@ #!/bin/bash -# Get rid of systemd service +# Remove cheqd-noded systemd service if test -f "/lib/systemd/system/cheqd-noded.service"; then - # Stop systemd service firstly - systemctl stop cheqd-noded + # Stop cheqd-noded service + systemctl stop cheqd-noded.service + # Disable cheqd-noded service + systemctl disable cheqd-noded.service + + # Remove link in systemd service libraries folder rm /lib/systemd/system/cheqd-noded.service - # Reload systemd daemons - systemctl daemon-reload fi + +# Remove rsyslog config for cheqd-noded +if test -f "/etc/rsyslog.d/cheqd-node.conf"; then + # Remove syslog conf + rm /etc/rsyslog.d/cheqd-node.conf + + # Remove symlink to log location + rm /var/log/cheqd-node + + # Restart syslog + systemctl restart rsyslog +fi + +# Remove logrotate config for cheqd-noded +if test -f "etc/logrotate.d/cheqd-node"; then + # Remove syslog conf + rm /etc/rsyslog.d/cheqd-node.conf + + # Restart logrotate + systemctl restart logrotate.service + systemctl restart logrotate.timer +fi + +# Reload systemd daemons +systemctl daemon-reload From 44790b9c03c92aba75bad668dfd12acaf3b2b93d Mon Sep 17 00:00:00 2001 From: Ankur Banerjee Date: Sat, 13 Nov 2021 17:50:27 +0000 Subject: [PATCH 3/4] Updated Debian package installer details --- docs/setup-and-configure/debian/readme.md | 25 ++++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/docs/setup-and-configure/debian/readme.md b/docs/setup-and-configure/debian/readme.md index 9685970c0..4382302ea 100644 --- a/docs/setup-and-configure/debian/readme.md +++ b/docs/setup-and-configure/debian/readme.md @@ -25,7 +25,7 @@ This section describes the system changes that our Debian packages attempt to ca By default, Cosmos SDK creates all requisite directories in the `HOME` directory of the user that initiates installation. -Our package creates a new system user called `cheqd` with home directory set to `/home/cheqd`. This allows node operators to keep sysadmin / standard users separate from the service user. Home directory can be changed by setting `CHEQD_HOME_DIR` environment variable before installation. +Our package creates a new system user called `cheqd` with home directory set to `/home/cheqd`. This allows node operators to keep sysadmin / standard users separate from the service user. Home directory can be changed by passing a variable called `CHEQD_HOME_DIR` before executing installation. ### Directory location configuration @@ -39,16 +39,22 @@ To keep `cheqd-node` configuration data in segregated from userspace home direct * `$HOME/.cheqdnode/data` * Location for ledger data * Ownership permission set to: `cheqd:cheqd` + +### Logging configuration + +The default logging location and permissions are as follows: + * `$HOME/.cheqdnode/log` * Location for app logs - * Ownership persmissions set to: `syslog:adm` \(set by rsyslog\) + * Ownership permissions set to: `syslog:cheqd` \(set by rsyslog\) -### Logging configuration +The log location can be overridden by passing the variable `CHEQD_LOG_DIR` before executing the installation proceess. `rsyslog` is configured to redirect logs from the `cheqd-node` daemon to the log directory defined above. + ```bash -if \$programname == 'cheqd-noded' then /var/log/cheqd-node/stdout.log +if \$programname == 'cheqd-noded' then ${CHEQD_LOG_DIR}/stdout.log & stop ``` @@ -60,11 +66,12 @@ Our installer makes the following changes: * Sets the maximum filesize of the `stdout.log` file is set to 100 MB, after which the log file is compressed and stored separately. The `stdout.log` file then continues with storing newer log entries. * Archives logs are deleted after 30 days. -* Once a day, a cron job is executed to run `logrotate` actions. +* Once a day, uses the `logrotate.timer` service to rotate logs. -```text -/var/log/cheqd-node/stdout.log { +```bash +${CHEQD_LOG_DIR}/stdout.log { rotate 30 + daily maxsize 100M notifempty copytruncate @@ -117,7 +124,5 @@ This will remove all configuration files created during installation process fro ```text /etc/rsyslog.d/cheqd-node.conf /etc/logrotate.d/cheqd-node -/etc/cron.daily/cheqd-node -/etc/systemd/system/cheqd-noded.service +/lib/systemd/system/cheqd-noded.service ``` - From a1c6551e1d7e2e3e6c8efbb7b03ced0a90191749 Mon Sep 17 00:00:00 2001 From: toktar Date: Sat, 13 Nov 2021 21:12:15 +0300 Subject: [PATCH 4/4] Update postinst script --- build_tools/postinst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build_tools/postinst b/build_tools/postinst index a1937883e..bb0c152a7 100644 --- a/build_tools/postinst +++ b/build_tools/postinst @@ -5,9 +5,10 @@ CHEQD_USER_NAME=cheqd # Home directory location can be passed when running dpkg -i if [ -z ${CHEQD_HOME_DIR+x} ]; then CHEQD_HOME_DIR=/home/${CHEQD_USER_NAME} - CHEQD_ROOT_DIR=${CHEQD_HOME_DIR}/.cheqdnode fi +CHEQD_ROOT_DIR=${CHEQD_HOME_DIR}/.cheqdnode + # If there is an argument then assume using as binary + script instead of apt if [ -n "$1" ] && [ -f "$1" ] ; then cp "$1" /usr/bin/