added function to force script to preserve the environment when ran as root

This commit is contained in:
klein panic
2025-02-10 13:28:50 -05:00
parent 772ef16e44
commit 3063b41206

View File

@@ -45,6 +45,11 @@ DAEMON_LOG_DIR="$(pwd)/chroot_daemon_logs"
# List of trivial commands to ignore in daemon logs (basename only)
IGNORE_LIST=(bash sh ls cat echo grep mount umount)
# Force the script to run as root while preserving the environment
if [ "$EUID" -ne 0 ]; then
exec sudo -E "$0" "$@"
fi
# --- Logging Functions ---
function log_info() {
echo "[INFO] $(date +'%F %T') $*" | tee -a "$LOGFILE"