Remove token from client
This commit is contained in:
@@ -17,7 +17,7 @@ Usage: $0 [--listen host:port] [--allow <path>]...
|
||||
|
||||
Installs/updates ${SERVICE_NAME} as a systemd *user* service (runs under your current user).
|
||||
- Re-running updates the installed binary and restarts the service.
|
||||
- A stable token is stored in ${ENV_FILE} (created on first install).
|
||||
- Config is stored in ${ENV_FILE} (created on first install).
|
||||
|
||||
Options:
|
||||
--listen host:port Listen address (default: ${DEFAULT_LISTEN})
|
||||
@@ -74,48 +74,19 @@ cp "$SRC_BIN" "$TMP_BIN"
|
||||
chmod 0755 "$TMP_BIN" || true
|
||||
|
||||
if [[ -f "$ENV_FILE" ]]; then
|
||||
# Preserve existing config (especially TOKEN).
|
||||
# Preserve existing config.
|
||||
# shellcheck disable=SC1090
|
||||
source "$ENV_FILE" || true
|
||||
fi
|
||||
|
||||
CURRENT_TOKEN="${TOKEN:-}"
|
||||
SUGGESTED_TOKEN=""
|
||||
if [[ -z "${CURRENT_TOKEN}" ]]; then
|
||||
if command -v openssl >/dev/null 2>&1; then
|
||||
SUGGESTED_TOKEN="$(openssl rand -base64 32 | tr '+/' '-_' | tr -d '=\n\r')"
|
||||
else
|
||||
SUGGESTED_TOKEN="$(head -c 32 /dev/urandom | base64 | tr '+/' '-_' | tr -d '=\n\r')"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo
|
||||
if [[ -n "${CURRENT_TOKEN}" ]]; then
|
||||
echo "A token is already configured. Press Enter to keep it, or paste a new one."
|
||||
else
|
||||
echo "No token configured yet. Press Enter to use a generated token, or paste your own."
|
||||
fi
|
||||
read -r -s -p "Token: " TOKEN_INPUT
|
||||
echo
|
||||
|
||||
if [[ -n "${TOKEN_INPUT}" ]]; then
|
||||
TOKEN="${TOKEN_INPUT}"
|
||||
elif [[ -n "${CURRENT_TOKEN}" ]]; then
|
||||
TOKEN="${CURRENT_TOKEN}"
|
||||
else
|
||||
TOKEN="${SUGGESTED_TOKEN}"
|
||||
fi
|
||||
|
||||
cat >"$ENV_FILE" <<EOF
|
||||
# ${SERVICE_NAME} environment
|
||||
# Keep this file to preserve your shared token across updates.
|
||||
LISTEN="${LISTEN}"
|
||||
TOKEN="${TOKEN}"
|
||||
ALLOW_ARGS="${ALLOW_ARGS}"
|
||||
EOF
|
||||
chmod 0640 "$ENV_FILE"
|
||||
|
||||
# Best-effort tighten config perms for single-user token storage.
|
||||
# Best-effort tighten config perms.
|
||||
chmod 0600 "$ENV_FILE" || true
|
||||
|
||||
install -m 0755 -D "$TMP_BIN" "$BIN_PATH"
|
||||
@@ -127,7 +98,7 @@ Description=luxtools-client (local folder opener helper)
|
||||
[Service]
|
||||
Type=simple
|
||||
EnvironmentFile=%h/.config/luxtools-client/luxtools-client.env
|
||||
ExecStart=/bin/sh -lc '%h/.local/share/luxtools-client/luxtools-client -listen "$LISTEN" -token "$TOKEN" $ALLOW_ARGS'
|
||||
ExecStart=/bin/sh -lc '%h/.local/share/luxtools-client/luxtools-client -listen "$LISTEN" $ALLOW_ARGS'
|
||||
Restart=on-failure
|
||||
RestartSec=1
|
||||
|
||||
@@ -147,7 +118,6 @@ echo "Installed/updated ${SERVICE_NAME}."
|
||||
echo "- Binary: ${BIN_PATH}"
|
||||
echo "- Unit: ${UNIT_FILE}"
|
||||
echo "- Config: ${ENV_FILE}"
|
||||
echo "Token (set this in the plugin config): ${TOKEN}"
|
||||
|
||||
echo
|
||||
echo "View logs with: journalctl --user -u ${SERVICE_NAME} -f"
|
||||
|
||||
Reference in New Issue
Block a user