fix(install): detect rc.conf.d override that blocks FreeBSD service start and restart (#2219)

* fix(install): detect rc.conf.d override that blocks FreeBSD service start

* fix log file removal
This commit is contained in:
mhlas7
2026-08-15 13:16:33 -07:00
committed by GitHub
parent eebcd56462
commit b4e1f3fafe

View File

@@ -5,7 +5,7 @@ is_alpine() {
}
is_openwrt() {
grep -qi "OpenWrt" /etc/os-release
[ -f /etc/os-release ] && grep -qi "OpenWrt" /etc/os-release
}
is_freebsd() {
@@ -465,9 +465,10 @@ if [ "$UNINSTALL" = true ]; then
echo "Removing the daily update cron job..."
rm -f /etc/cron.d/beszel-agent
# Remove log files
# Remove log files. The rc script derives its logfile from $name
# (beszel_agent), not from the script filename (beszel-agent).
echo "Removing log files..."
rm -f /var/log/beszel-agent.log
rm -f /var/log/beszel_agent.log
# Remove env file and directories
echo "Removing environment configuration file..."
@@ -739,7 +740,7 @@ if [ -f "$BIN_PATH" ]; then
fi
mv beszel-agent "$BIN_PATH"
chown beszel:beszel "$BIN_PATH"
chown "${AGENT_USER}:${AGENT_USER}" "$BIN_PATH"
chmod 755 "$BIN_PATH"
# Set SELinux context if needed
@@ -802,7 +803,7 @@ EOF
# Create log files with proper permissions
touch /var/log/beszel-agent.log /var/log/beszel-agent.err
chown beszel:beszel /var/log/beszel-agent.log /var/log/beszel-agent.err
chown "${AGENT_USER}:${AGENT_USER}" /var/log/beszel-agent.log /var/log/beszel-agent.err
# Start the service
rc-service beszel-agent restart
@@ -964,6 +965,26 @@ EOF
echo "Enabling and starting the agent service..."
sysrc beszel_agent_enable="YES"
sysrc beszel_agent_user="${AGENT_USER}"
# sysrc writes to /etc/rc.conf, but rc.subr sources /etc/rc.conf.d/beszel_agent
# afterwards, so a stale or third-party file there silently overrides the value
# we just set. The service then refuses to start, and rc.subr's own error points
# at /etc/rc.conf, which looks correct. Verify the flag actually took effect.
# An empty value means this rc.subr does not support "rcvar"; skip the check.
rcvar_value=$(service beszel-agent rcvar 2>/dev/null | sed -n 's/^beszel_agent_enable="\(.*\)"$/\1/p')
if [ -n "$rcvar_value" ]; then
case "$rcvar_value" in
[Yy][Ee][Ss] | [Tt][Rr][Uu][Ee] | [Oo][Nn] | 1) ;;
*)
echo "Error: beszel_agent_enable resolves to \"${rcvar_value}\" even though it was just set to YES in /etc/rc.conf."
echo "Another rc configuration file is overriding it. The most likely cause is a leftover:"
echo " /etc/rc.conf.d/beszel_agent"
echo "Remove or correct that file, then re-run this installer."
exit 1
;;
esac
fi
service beszel-agent restart
# Check if service started successfully