atlas-iac/scripts/node_disable_obsolete_ramlog.sh

26 lines
1.2 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
# Stop stale Armbian RAM-log copy hooks after logs have moved to external storage.
set -euo pipefail
[[ ${EUID} -eq 0 ]] || { echo "Run as root" >&2; exit 1; }
config=/etc/default/armbian-ramlog
[[ -f ${config} ]] || { echo "No Armbian RAM-log configuration" >&2; exit 1; }
[[ $(readlink -f /var/log) == /mnt/astraios/var/log ]] || {
echo "Refusing: /var/log does not use the managed external log path" >&2; exit 1;
}
[[ $(findmnt -n -o TARGET -T /var/log) == /mnt/astraios ]] || {
echo "Refusing: another filesystem is mounted over the external log directory" >&2; exit 1;
}
[[ $(findmnt -n -o FSTYPE -T /var/log) == ext4 ]] || exit 1
if systemctl is-active --quiet armbian-ramlog.service; then
echo "Refusing: migrate an active RAM-log mount before changing this setting" >&2
exit 1
fi
backup=/var/lib/atlas-maintenance/ramlog-before-20261004
install -d -m 700 "${backup}"
[[ -e ${backup}/armbian-ramlog ]] || cp -p "${config}" "${backup}/armbian-ramlog"
# The native Armbian hooks already honor this flag, including at boot.
sed -i 's/^ENABLED=.*/ENABLED=false/' "${config}"
grep -qx 'ENABLED=false' "${config}"
systemctl start logrotate.service
systemctl show logrotate.service -p Result -p ExecMainStatus