diff --git a/build-tools/postinst b/build-tools/postinst deleted file mode 100644 index c4fda1468..000000000 --- a/build-tools/postinst +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash - -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} -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/ -fi - -# Create cheqd user -if ! /usr/bin/getent passwd ${CHEQD_USER_NAME} > /dev/null 2>&1 ; then - # Create group and user named "cheqd" - 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_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." -fi - -# Symbolic link to log directory -if [ ! -L /var/log/cheqd-node ] ; then - ln -s ${CHEQD_LOG_DIR} /var/log/cheqd-node -fi - -# Add rsyslogd configuration -if [ -d /etc/rsyslog.d/ ] ; then - if [ ! -f /etc/rsyslog.d/cheqd-node.conf ] ; then - cat < /etc/rsyslog.d/cheqd-node.conf -if \$programname == 'cheqd-noded' then ${CHEQD_LOG_DIR}/stdout.log -& stop -EOF - # Restart syslog - systemctl restart rsyslog - fi -fi - -# Add config for logrotation -if [ ! -f /etc/logrotate.d/cheqd-node ] ; then - cat < /etc/logrotate.d/cheqd-node -${CHEQD_LOG_DIR}/stdout.log { - rotate 7 - daily - maxsize 100M - notifempty - copytruncate - compress - maxage 7 -} -EOF -# Restart logrotate -systemctl restart logrotate.service -systemctl restart logrotate.timer -fi \ No newline at end of file diff --git a/build-tools/postpurge b/build-tools/postpurge deleted file mode 100644 index 360e6fee8..000000000 --- a/build-tools/postpurge +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash - -# Remove cheqd-noded systemd service -# shellcheck disable=SC1136 -if [ -f "/lib/systemd/system/cheqd-noded.service" ] -then - # 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 -fi - -# Remove rsyslog config for cheqd-noded -if [ -f "/etc/rsyslog.d/cheqd-node.conf" ] -then - # Remove syslog conf - rm /etc/rsyslog.d/cheqd-node.conf - - # Remove logs - rm -rf /var/log/cheqd-node/ - - # Restart syslog - systemctl restart rsyslog -fi - -# Remove logrotate config for cheqd-noded -if [ -f "/etc/logrotate.d/cheqd-node" ] -then - # Remove syslog conf - rm /etc/logrotate.d/cheqd-node - - # Restart logrotate - systemctl restart logrotate.service - systemctl restart logrotate.timer -fi - -# Reload systemd daemons -systemctl daemon-reload diff --git a/build-tools/rsyslog.conf b/build-tools/rsyslog.conf index a4bbde1c8..eda618b60 100644 --- a/build-tools/rsyslog.conf +++ b/build-tools/rsyslog.conf @@ -1,2 +1,2 @@ -if \$programname == '{BINARY_FOR_LOGGING}' then {CHEQD_LOG_DIR}/stdout.log +if $programname == '{BINARY_FOR_LOGGING}' then {CHEQD_LOG_DIR}/stdout.log & stop