#!/bin/sh
# Ship the heavy optional services installed but not started.
#
# These are all things a given unit may never use - a docker host, a samba
# share, a download manager - yet every one of them costs process startup, and
# several pull in iptables/bridge setup or their own watch loops. Leaving them
# out of the image entirely would take the choice away from the user, so
# instead they stay installed and only the boot-time autostart is removed.
#
# Re-enabling is a click in LuCI under System -> Startup, or
#
#     /etc/init.d/<name> enable && /etc/init.d/<name> start
#
# uci-defaults run once, from /etc/init.d/boot at START=10, which is before
# any of these (earliest is S25docker). So they never start even on the first
# boot after flashing, and a later "enable" is respected because this script
# has deleted itself by then.
#
# Deliberately left enabled: dropbear, uhttpd, firewall, network, dnsmasq and
# anything else the box needs to be a router or to be reachable; turboacc,
# which affects throughput; vnstat, whose whole job is to keep running so the
# traffic history has no holes; ttyd, which backs LuCI's Terminal page and is
# wanted on this product; and the pcat-* services.
#
# mwan3 already ships with no rc.d link, so listing it changes nothing today.
# It is here to pin that if the package default ever flips.

for svc in \
	docker dockerd containerd \
	samba4 \
	collectd luci_statistics \
	adbyby \
	appfilter oafd \
	nlbwmon \
	watchcat \
	aria2 \
	frpc frps \
	filebrowser \
	rclone \
	mwan3 \
	tailscale zerotier
do
	[ -x "/etc/init.d/$svc" ] || continue
	/etc/init.d/"$svc" disable 2>/dev/null
	/etc/init.d/"$svc" stop 2>/dev/null
done

exit 0
