From 1bb89fce26d6ba022bbbd7d261c09ac2ac0c56fc Mon Sep 17 00:00:00 2001 From: Laurence Date: Thu, 2 Apr 2026 12:21:53 +0100 Subject: [PATCH] enhance: Systemd newt unit Add a systemd unit option directly from dashboard to prevent copy and paste mistakes --- messages/en-US.json | 3 ++ src/components/newt-install-commands.tsx | 52 +++++++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/messages/en-US.json b/messages/en-US.json index 51bb996af..e4a225f70 100644 --- a/messages/en-US.json +++ b/messages/en-US.json @@ -2607,6 +2607,9 @@ "machineClients": "Machine Clients", "install": "Install", "run": "Run", + "envFile": "Environment File", + "serviceFile": "Service File", + "enableAndStart": "Enable and Start", "clientNameDescription": "The display name of the client that can be changed later.", "clientAddress": "Client Address (Advanced)", "setupFailedToFetchSubnet": "Failed to fetch default subnet", diff --git a/src/components/newt-install-commands.tsx b/src/components/newt-install-commands.tsx index ba0363e3b..d7ff57c04 100644 --- a/src/components/newt-install-commands.tsx +++ b/src/components/newt-install-commands.tsx @@ -55,7 +55,7 @@ export function NewtSiteInstallCommands({ const commandList: Record> = { unix: { - All: [ + Direct: [ { title: t("install"), command: `curl -fsSL https://static.pangolin.net/get-newt.sh | bash` @@ -64,6 +64,54 @@ export function NewtSiteInstallCommands({ title: t("run"), command: `newt --id ${id} --secret ${secret} --endpoint ${endpoint}${acceptClientsFlag}` } + ], + "Systemd Service": [ + { + title: t("install"), + command: `curl -fsSL https://static.pangolin.net/get-newt.sh | bash` + }, + { + title: t("envFile"), + command: `# Create the directory and environment file +sudo install -d -m 0755 /etc/newt +sudo tee /etc/newt/newt.env > /dev/null << 'EOF' +NEWT_ID=${id} +NEWT_SECRET=${secret} +PANGOLIN_ENDPOINT=${endpoint}${!acceptClients ? ` +DISABLE_CLIENTS=true` : ""} +EOF +sudo chmod 600 /etc/newt/newt.env` + }, + { + title: t("serviceFile"), + command: `sudo tee /etc/systemd/system/newt.service > /dev/null << 'EOF' +[Unit] +Description=Newt +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple +User=root +Group=root +EnvironmentFile=/etc/newt/newt.env +ExecStart=/usr/local/bin/newt +Restart=always +RestartSec=2 +UMask=0077 + +NoNewPrivileges=true +PrivateTmp=true + +[Install] +WantedBy=multi-user.target +EOF` + }, + { + title: t("enableAndStart"), + command: `sudo systemctl daemon-reload +sudo systemctl enable --now newt` + } ] }, windows: { @@ -298,7 +346,7 @@ function getPlatformName(platformName: Platform) { function getArchitectures(platform: Platform) { switch (platform) { case "unix": - return ["All"]; + return ["Direct", "Systemd Service"]; case "windows": return ["x64"]; case "docker":