diff --git a/chroot_manager.sh b/chroot_manager.sh index 86cea0e..8e49b41 100755 --- a/chroot_manager.sh +++ b/chroot_manager.sh @@ -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"