Skip to content

Commit

Permalink
Merge pull request #217 from cheqd/debian-package-fix
Browse files Browse the repository at this point in the history
Debian package fix
  • Loading branch information
Toktar authored Nov 13, 2021
2 parents 74dc518 + a1c6551 commit 003086a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 19 deletions.
2 changes: 0 additions & 2 deletions build_tools/build_tar.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,3 @@ mkdir -p $TMP_DIR
cp $PATH_TO_BIN $TMP_DIR

tar -czf $PATH_TAR $TMP_DIR


1 change: 0 additions & 1 deletion build_tools/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ TMP_DIR=usr/bin
OUTPUT_DIR=output
TAR_ARCHIVE=${PKG_NAME}_${VERSION}.tar.gz
PATH_TAR=$OUTPUT_DIR/$TAR_ARCHIVE

7 changes: 6 additions & 1 deletion build_tools/postinst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ if [ -z ${CHEQD_HOME_DIR+x} ]; then
CHEQD_HOME_DIR=/home/${CHEQD_USER_NAME}
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/
Expand All @@ -18,20 +20,23 @@ 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
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."
Expand Down
37 changes: 32 additions & 5 deletions build_tools/postremove
Original file line number Diff line number Diff line change
@@ -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
25 changes: 15 additions & 10 deletions docs/setup-and-configure/debian/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
```
Expand All @@ -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
Expand Down Expand Up @@ -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
```

0 comments on commit 003086a

Please sign in to comment.