My suggestions:
- decrease the use of hard coded shell script in js code;
ex.:
exec("/usr/bin/sudo /bin/systemctl restart avahi-daemon.service..."
could be refactored to:
exec("/path/to/scripts/daemon.sh restart avahi"
- use template files to create default daemon/system configurations;
ex:
[code]# file: etc_network_interfaces.tmpl
auto wlan0
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
[/code]