Compare commits

..
Author SHA1 Message Date
MickLesk f7f7f74985 Newt: offer the Pangolin CLI as the site connector
Pangolin 1.23 runs a site with the Pangolin CLI (pangolin up site) beside
Newt, which stays supported. The install asks for the connector (newt by
default); the same site ID and secret work for both, and the update keeps
whichever is installed.
2026-12-06 10:31:50 +01:00
4 changed files with 104 additions and 48 deletions

No files matched your search

+2 -22
View File
@@ -76,9 +76,7 @@ EOF
sleep 1
chown -R hermes:hermes /home/hermes || msg_warn "Could not take ownership of everything under /home/hermes"
fi
if [[ -f /home/hermes/.config/systemd/user/hermes-dashboard.service && ! -f /home/hermes/.hermes/backend_migration.json ]]; then
$STD runuser -l hermes -c 'systemctl --user daemon-reload && systemctl --user enable hermes-dashboard'
fi
$STD runuser -l hermes -c 'systemctl --user daemon-reload && systemctl --user enable hermes-dashboard'
NODE_VERSION="22" setup_nodejs
@@ -90,26 +88,8 @@ EOF
msg_ok "Updated Hermes Agent"
msg_info "Starting Services"
$STD runuser -l hermes -c '
systemctl --user daemon-reload
if systemctl --user is-enabled -q hermes-dashboard 2>/dev/null; then systemctl --user start hermes-dashboard; fi
if systemctl --user is-enabled -q hermes-gateway 2>/dev/null; then systemctl --user restart hermes-gateway; fi
'
$STD runuser -l hermes -c 'systemctl --user start hermes-dashboard'
msg_ok "Started Services"
# hermes dashboard is deprecated; upstream moves it onto the gateway's Webapp on the same address.
if [[ -f /home/hermes/.config/systemd/user/hermes-dashboard.service && ! -f /home/hermes/.hermes/backend_migration.json ]]; then
msg_info "Moving the Dashboard to the Gateway's Webapp"
for _ in {1..30}; do
curl -so /dev/null http://127.0.0.1:9119/ && break
sleep 1
done
if $STD runuser -l hermes -c 'set -a; source /etc/default/hermes; set +a; hermes gateway migrate --backends --apply --yes'; then
msg_ok "Moved the Dashboard to the Gateway's Webapp"
else
msg_warn "Could not move the Dashboard to the Gateway's Webapp, it keeps running"
fi
fi
msg_ok "Updated successfully!"
exit
}
+16
View File
@@ -26,6 +26,22 @@ function update_script() {
check_container_storage
check_container_resources
if [[ -f /etc/pangolin/pangolin-site.env ]]; then
if check_for_gh_release "pangolin-cli" "fosrl/cli"; then
msg_info "Stopping Service"
systemctl stop pangolin-site
msg_ok "Stopped Service"
fetch_and_deploy_gh_release "pangolin-cli" "fosrl/cli" "singlefile" "latest" "/opt/pangolin-cli" "pangolin-cli_linux_$(arch_resolve)"
ln -sf /opt/pangolin-cli/pangolin-cli /usr/local/bin/pangolin
msg_info "Starting Service"
systemctl start pangolin-site
msg_ok "Started Service"
fi
exit
fi
if [[ ! -f /etc/newt/newt.env ]]; then
msg_error "No ${APP} Installation Found!"
exit
+25 -12
View File
@@ -63,23 +63,36 @@ chown hermes:hermes /home/hermes/.hermes/.env
chmod 600 /home/hermes/.hermes/.env
msg_ok "Configured API Server"
msg_info "Setting up Gateway and Webapp"
$STD runuser -l hermes -c '
set -a; source /etc/default/hermes; set +a
hermes webapp --build-only
hermes config set webapp.enabled true
hermes config set webapp.host 127.0.0.1
hermes config set webapp.port 9119
hermes gateway install
systemctl --user enable --now hermes-gateway
'
msg_ok "Set up Gateway and Webapp"
msg_info "Creating Dashboard Service"
mkdir -p /home/hermes/.config/systemd/user
cat <<EOF >/home/hermes/.config/systemd/user/hermes-dashboard.service
[Unit]
Description=Hermes Agent Web Dashboard
After=network-online.target
[Service]
Type=simple
UMask=0077
WorkingDirectory=%h
EnvironmentFile=/etc/default/hermes
ExecStart=%h/.local/bin/hermes dashboard --host 127.0.0.1 --port 9119 --no-open
Restart=on-failure
RestartSec=5
[Install]
WantedBy=default.target
EOF
chown -R hermes:hermes /home/hermes/.config
$STD runuser -l hermes -c 'systemctl --user daemon-reload && systemctl --user enable --now hermes-dashboard'
msg_ok "Created Dashboard Service"
msg_info "Creating Setup Helper"
cat <<'SETUP' >/usr/bin/hermes-setup
#!/usr/bin/env bash
su - hermes -c 'set -a; source /etc/default/hermes; set +a; hermes setup'
su - hermes -c 'systemctl --user enable -q hermes-gateway && systemctl --user restart hermes-gateway'
if [[ -f /home/hermes/.config/systemd/user/hermes-gateway.service ]]; then
su - hermes -c 'systemctl --user enable --now hermes-gateway'
fi
echo "Hermes setup complete."
SETUP
chmod +x /usr/bin/hermes-setup
+61 -14
View File
@@ -13,36 +13,82 @@ setting_up_container
network_check
update_os
fetch_and_deploy_gh_release "newt" "fosrl/newt" "singlefile" "latest" "/opt/newt" "newt_linux_$(arch_resolve)"
ln -sf /opt/newt/newt /usr/local/bin/newt
NEWT_AGENT="${var_newt_agent:-}"
if [[ -z "$NEWT_AGENT" ]]; then
read -rp "Connector: newt or cli (Pangolin CLI) [newt]: " NEWT_AGENT || true
fi
NEWT_AGENT="${NEWT_AGENT:-newt}"
if [[ "$NEWT_AGENT" != "newt" && "$NEWT_AGENT" != "cli" ]]; then
msg_error "Unknown connector '${NEWT_AGENT}', use newt or cli. Aborting."
exit 64
fi
NEWT_ID="${NEWT_ID:-${var_newt_id:-}}"
[[ -n "$NEWT_ID" ]] || read -rp "Newt ID (from your Pangolin dashboard): " NEWT_ID || true
[[ -n "$NEWT_ID" ]] || read -rp "Site ID (from your Pangolin dashboard): " NEWT_ID || true
NEWT_SECRET="${NEWT_SECRET:-${var_newt_secret:-}}"
if [[ -z "$NEWT_SECRET" ]]; then
read -rsp "Newt Secret: " NEWT_SECRET || true
read -rsp "Site Secret: " NEWT_SECRET || true
echo
fi
PANGOLIN_ENDPOINT="${PANGOLIN_ENDPOINT:-${var_newt_endpoint:-}}"
[[ -n "$PANGOLIN_ENDPOINT" ]] || read -rp "Pangolin endpoint (e.g. https://pangolin.example.com): " PANGOLIN_ENDPOINT || true
if [[ -z "$NEWT_ID" || -z "$NEWT_SECRET" || -z "$PANGOLIN_ENDPOINT" ]]; then
msg_error "Newt ID, Secret and Endpoint are all required. Aborting."
msg_error "Site ID, Secret and Endpoint are all required. Aborting."
exit 64
fi
msg_info "Configuring Newt"
mkdir -p /etc/newt
cat <<EOF >/etc/newt/newt.env
if [[ "$NEWT_AGENT" == "cli" ]]; then
fetch_and_deploy_gh_release "pangolin-cli" "fosrl/cli" "singlefile" "latest" "/opt/pangolin-cli" "pangolin-cli_linux_$(arch_resolve)"
ln -sf /opt/pangolin-cli/pangolin-cli /usr/local/bin/pangolin
msg_info "Configuring Pangolin CLI"
mkdir -p /etc/pangolin
cat <<EOF >/etc/pangolin/pangolin-site.env
SITE_ID=${NEWT_ID}
SITE_SECRET=${NEWT_SECRET}
PANGOLIN_ENDPOINT=${PANGOLIN_ENDPOINT}
EOF
chmod 600 /etc/pangolin/pangolin-site.env
msg_ok "Configured Pangolin CLI"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/pangolin-site.service
[Unit]
Description=Pangolin Site (Pangolin CLI)
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
EnvironmentFile=/etc/pangolin/pangolin-site.env
ExecStart=/usr/local/bin/pangolin up site
Restart=always
RestartSec=2
UMask=0077
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now pangolin-site
msg_ok "Created Service"
else
fetch_and_deploy_gh_release "newt" "fosrl/newt" "singlefile" "latest" "/opt/newt" "newt_linux_$(arch_resolve)"
ln -sf /opt/newt/newt /usr/local/bin/newt
msg_info "Configuring Newt"
mkdir -p /etc/newt
cat <<EOF >/etc/newt/newt.env
NEWT_ID=${NEWT_ID}
NEWT_SECRET=${NEWT_SECRET}
PANGOLIN_ENDPOINT=${PANGOLIN_ENDPOINT}
EOF
chmod 600 /etc/newt/newt.env
msg_ok "Configured Newt"
chmod 600 /etc/newt/newt.env
msg_ok "Configured Newt"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/newt.service
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/newt.service
[Unit]
Description=Newt (Pangolin tunnel client)
Wants=network-online.target
@@ -60,8 +106,9 @@ PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now newt
msg_ok "Created Service"
systemctl enable -q --now newt
msg_ok "Created Service"
fi
motd_ssh
customize