HEX
Server: nginx/1.29.3
System: Linux 11979.bigscoots-wpo.com 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64
User: nginx (1068)
PHP: 7.4.33
Disabled: exec,system,passthru,shell_exec,proc_open,proc_close,popen,show_source,cmd# Do not modify this line # 1684243876
Upload Files
File: //bigscoots/lxd/fix-proc-mount.sh
#!/bin/bash

# --- 1. THE GATEKEEPER: ONLY RUN ON LXD ---
# Checks if the environment is 'lxc' or if the LXD device socket exists
if [ "$container" != "lxc" ] && [ ! -d "/dev/lxd" ] && [ ! -d "/var/lib/lxd" ]; then
    # Silently exit on bare metal or other virtualization types
    exit 0
fi

# --- 2. SELF-INSTALLATION LOGIC ---
# This only runs if the gatekeeper above passes
if [ ! -f "/etc/systemd/system/proc-checker.timer" ]; then
    cat <<EOF > /etc/systemd/system/proc-checker.service
[Unit]
Description=LXD Proc Mount Watchdog
After=network.target

[Service]
Type=oneshot
ExecStart=/bin/bash /bigscoots/lxd/fix-proc-mount.sh
EOF

    cat <<EOF > /etc/systemd/system/proc-checker.timer
[Unit]
Description=Run LXD Proc Watchdog every minute

[Timer]
OnBootSec=1min
OnUnitActiveSec=1min

[Install]
WantedBy=timers.target
EOF

    systemctl daemon-reload
    systemctl enable --now proc-checker.timer
fi

# --- 3. THE ACTUAL HEALTH CHECK ---
if ! ps -p 1 > /dev/null 2>&1; then
    # We only log and fix if ps is actually broken
    echo "$(date): Broken /proc detected in LXD. Remounting..." >> /var/log/lxd-proc-fixer.log
    mount proc /proc -t proc
    
    if ps -p 1 > /dev/null 2>&1; then
        echo "$(date): /proc recovered successfully." >> /var/log/lxd-proc-fixer.log
    fi
fi

exit 0