Newt binary does not run in background when executed from cli #5

Closed
opened 2025-11-19 07:11:34 -06:00 by GiteaMirror · 2 comments
Owner

Originally created by @basher83 on GitHub (Feb 11, 2025).

I looked through the repo and didn't see this mentioned. Basically what the title says.

Steps to reproduce:
On host:

  1. wget -O newt "https://github.com/fosrl/newt/releases/download/1.0.0-beta.3/newt_linux_amd64" && chmod +x ./newt
  2. newt --id your_id --secret your_secret --endpoint https://pangolin.your_endpoint

Results in the cli being taken hostage. I tried & at the end with no luck, I then turned to tmux and that works but then I remembered systemd!

Did a simple:
[Unit]
Description=Newt VPN Client
After=network.target

[Service]
ExecStart=/usr/local/bin/newt --id your_id --secret your_secret --endpoint https://pangolin.your_endpoint
Restart=always
User=root

[Install]
WantedBy=multi-user.target

Best solution I could come up with. Maybe no one else has this issue or simply no one runs the binary but in either case hope this can help someone out in the future

Originally created by @basher83 on GitHub (Feb 11, 2025). I looked through the repo and didn't see this mentioned. Basically what the title says. Steps to reproduce: On host: 1. wget -O newt "https://github.com/fosrl/newt/releases/download/1.0.0-beta.3/newt_linux_amd64" && chmod +x ./newt 2. newt --id your_id --secret your_secret --endpoint https://pangolin.your_endpoint Results in the cli being taken hostage. I tried & at the end with no luck, I then turned to tmux and that works but then I remembered systemd! Did a simple: [Unit] Description=Newt VPN Client After=network.target [Service] ExecStart=/usr/local/bin/newt --id your_id --secret your_secret --endpoint https://pangolin.your_endpoint Restart=always User=root [Install] WantedBy=multi-user.target Best solution I could come up with. Maybe no one else has this issue or simply no one runs the binary but in either case hope this can help someone out in the future
Author
Owner

@oschwartz10612 commented on GitHub (Feb 11, 2025):

I added this to the readme! Thanks!

@oschwartz10612 commented on GitHub (Feb 11, 2025): I added this to the readme! Thanks!
Author
Owner

@basher83 commented on GitHub (Feb 11, 2025):

Absolutely! I actually took this one step further with a quick bash script:

#!/bin/bash
# Script to install and configure Newt VPN Client as a systemd service with user-defined parameters

# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
  case "$1" in
    --id)
      NEWT_ID="$2"
      shift 2
      ;;
    --secret)
      NEWT_SECRET="$2"
      shift 2
      ;;
    --endpoint)
      NEWT_ENDPOINT="$2"
      shift 2
      ;;
    *)
      echo "Unknown parameter: $1"
      exit 1
      ;;
  esac
done

# Check if all required parameters are provided
if [[ -z "$NEWT_ID" || -z "$NEWT_SECRET" || -z "$NEWT_ENDPOINT" ]]; then
  echo "Usage: $0 --id <ID> --secret <SECRET> --endpoint <ENDPOINT>"
  exit 1
fi

# Download and install Newt
wget -O newt "https://github.com/fosrl/newt/releases/download/1.0.0-beta.5/newt_linux_amd64" && chmod +x ./newt
mv ./newt /usr/local/bin

# Create systemd service file
cat <<EOF | sudo tee /etc/systemd/system/newt.service
[Unit]
Description=Newt VPN Client
After=network.target

[Service]
ExecStart=/usr/local/bin/newt --id $NEWT_ID --secret $NEWT_SECRET --endpoint $NEWT_ENDPOINT
Restart=always
User=root

[Install]
WantedBy=multi-user.target
EOF

# Reload systemd daemon
sudo systemctl daemon-reload

# Start and enable Newt service
sudo systemctl start newt
sudo systemctl enable newt

echo "Newt VPN Client has been installed and configured as a systemd service with the provided parameters."
@basher83 commented on GitHub (Feb 11, 2025): Absolutely! I actually took this one step further with a quick bash script: ``` #!/bin/bash # Script to install and configure Newt VPN Client as a systemd service with user-defined parameters # Parse command-line arguments while [[ "$#" -gt 0 ]]; do case "$1" in --id) NEWT_ID="$2" shift 2 ;; --secret) NEWT_SECRET="$2" shift 2 ;; --endpoint) NEWT_ENDPOINT="$2" shift 2 ;; *) echo "Unknown parameter: $1" exit 1 ;; esac done # Check if all required parameters are provided if [[ -z "$NEWT_ID" || -z "$NEWT_SECRET" || -z "$NEWT_ENDPOINT" ]]; then echo "Usage: $0 --id <ID> --secret <SECRET> --endpoint <ENDPOINT>" exit 1 fi # Download and install Newt wget -O newt "https://github.com/fosrl/newt/releases/download/1.0.0-beta.5/newt_linux_amd64" && chmod +x ./newt mv ./newt /usr/local/bin # Create systemd service file cat <<EOF | sudo tee /etc/systemd/system/newt.service [Unit] Description=Newt VPN Client After=network.target [Service] ExecStart=/usr/local/bin/newt --id $NEWT_ID --secret $NEWT_SECRET --endpoint $NEWT_ENDPOINT Restart=always User=root [Install] WantedBy=multi-user.target EOF # Reload systemd daemon sudo systemctl daemon-reload # Start and enable Newt service sudo systemctl start newt sudo systemctl enable newt echo "Newt VPN Client has been installed and configured as a systemd service with the provided parameters." ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/newt#5