#!/usr/bin/env bash # planup: Update your happynetbox.com plan file via the command-line # # This script was developed based on the methods described in # "Introduction Finger" (20 Aug 2026) by bboysoul # https://www.bboy.app/2026/08/20/introduction-finger/ # # Copyright 2026 https://640kb.neocities.org # Blue Oak Model License 1.0.0 # # 02 Sep 2026: 8-bit upload testing passed. Previous comment removed, others tweaked. # 26 Aug 2026: Initial release. 7-bit support tested only. # =========================================================================== # CONFIGURATION : START # =========================================================================== USERNAME="Your Username" # Your happynetbox username PASSWORD="Your Password" # Password EDITOR="tilde" # Change this to your preferred editor HOSTNAME="happynetbox.com" # The server name. Do not modify. COOKIE_FILE="$HOME/.happynetbox.cookie" # The cookie file name # =========================================================================== # CONFIGURATION : END # =========================================================================== # --- Tries to access the edit page using the cookie; if we see "textarea", the cookie is valid --- check_cookie() { if [ -f "$COOKIE_FILE" ]; then if curl -s -b "$COOKIE_FILE" "https://$HOSTNAME/post/$USERNAME" | grep -q "textarea"; then return 0 fi fi return 1 } # --- (1) connects (2) fetches .plan (3) strips out additional generated output using sed --- # --- If happynetbox changes its additional output, this section would need tweaking --- fetch_plan() { exec 3<>"/dev/tcp/$HOSTNAME/79" printf '%s\r\n' "$USERNAME" >&3 cat <&3 | sed '/^---$/,$d' | sed '/^want another?/,$d' | sed '1{/^$/d}' exec 3<&- exec 3>&- } # --- (1) Send Credentials (2) Receive Cookie (3) Save Cookie --- login() { echo "Logging in..." curl -s -c "$COOKIE_FILE" -X POST "https://$HOSTNAME/login" \ -d "handle=$USERNAME&password=$PASSWORD" > /dev/null } # --- Supports upload of entire code page 437 (UTF-8 encoded) --- upload_plan() { local content="$1" echo "Uploading updated plan..." curl -s -b "$COOKIE_FILE" -X POST "https://$HOSTNAME/post/$USERNAME" \ --data-urlencode "content=$content" \ | grep -q "updated=true" && echo " Plan updated!" || echo " Upload failed." } main() { # --- check_cookie() result, if not valid... the login() function is called --- if ! check_cookie; then echo "Cookie expired or missing. Logging in..." login fi TEMP_FILE="/tmp/plan_edit_$$.tmp" fetch_plan > "$TEMP_FILE" 2>/dev/null $EDITOR "$TEMP_FILE" NEW_CONTENT=$(cat "$TEMP_FILE") upload_plan "$NEW_CONTENT" rm -f "$TEMP_FILE" } main