diff --git a/src/install/doinst.sh b/src/install/doinst.sh index 70042c3..561b917 100644 --- a/src/install/doinst.sh +++ b/src/install/doinst.sh @@ -1,9 +1,15 @@ # Slackware post-install hook for unraid-netbird-utils. # Runs once at upgradepkg time, with the package root as $PWD. -# Make sure the rc.d script is executable and symlinked from /etc/rc.d +# Make sure the rc.d script is executable. chmod 0755 usr/local/etc/rc.d/rc.netbird -( cd etc/rc.d ; rm -f rc.netbird ; ln -sf /usr/local/etc/rc.d/rc.netbird rc.netbird ) +# Symlink it into /etc/rc.d only when that's a distinct directory. On stock +# Unraid /etc/rc.d is itself a symlink to /usr/local/etc/rc.d, so the payload +# is already reachable as /etc/rc.d/rc.netbird and adding a link would just +# point the file at itself (a symlink loop that breaks the daemon). +if [ ! -e etc/rc.d/rc.netbird ]; then + ( cd etc/rc.d && ln -sf /usr/local/etc/rc.d/rc.netbird rc.netbird ) +fi # logrotate ownership chmod 0644 etc/logrotate.d/netbird diff --git a/src/usr/local/emhttp/plugins/netbird/Netbird-1-Settings.page b/src/usr/local/emhttp/plugins/netbird/Netbird-1-Settings.page index dd92286..2534100 100644 --- a/src/usr/local/emhttp/plugins/netbird/Netbird-1-Settings.page +++ b/src/usr/local/emhttp/plugins/netbird/Netbird-1-Settings.page @@ -12,15 +12,29 @@ require_once "{$docroot}/plugins/netbird/include/common.php"; $plugin = 'netbird'; $cfg = function_exists('parse_plugin_cfg') ? parse_plugin_cfg($plugin) : []; +// Global daemon options live in netbird.cfg. $enabled = $cfg['ENABLE_NETBIRD'] ?? '1'; -$mgmtUrl = $cfg['MANAGEMENT_URL'] ?? ''; -$setupKey = $cfg['SETUP_KEY'] ?? ''; -$hostname = $cfg['HOSTNAME'] ?? ''; -$preSharedKey = $cfg['PRESHARED_KEY'] ?? ''; $logLevel = $cfg['LOG_LEVEL'] ?? 'info'; $profiles = Netbird\listProfiles(); $activeProf = Netbird\activeProfile(); + +// Which profile's credentials is the form editing? ?nbprofile= wins, then the +// active profile, then "default" (NetBird's built-in profile). +$editProf = (string) ($_GET['nbprofile'] ?? ''); +if (!Netbird\validProfileName($editProf)) { + $editProf = ''; +} +if ($editProf === '') { + $editProf = $activeProf !== '' ? $activeProf : 'default'; +} + +// Credentials are stored per profile (profiles/.cfg), not globally. +$creds = Netbird\readProfileCfg($editProf); +$mgmtUrl = $creds['MANAGEMENT_URL']; +$setupKey = $creds['SETUP_KEY']; +$hostname = $creds['HOSTNAME']; +$preSharedKey = $creds['PRESHARED_KEY']; ?>