From 5e77c55749f4446ece8d212bf8c5170a3c3f072f Mon Sep 17 00:00:00 2001 From: Wesley Ray Date: Thu, 5 Jun 2025 12:39:28 -0400 Subject: [PATCH] Installed SSH key on roof unit and added a host config called roof-unit to simplify the deploy script --- deploy.sh | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/deploy.sh b/deploy.sh index e1909d0..0681473 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,18 +1,24 @@ #!/bin/bash -# skyweave_deploy.sh - Deploy Lua API script to RVLink roof unit (legacy crypto) +# skyweave_deploy.sh - Deploy Lua API script to RVLink roof unit (using SSH config alias) +# SSH alias for the roof unit (defined in ~/.ssh/config) +SSH_ALIAS="roof-unit" + +# IP address for HTTP/curl access (SSH alias might not be resolvable for curl) ROOF_IP="192.168.10.254" -ROOF_USER="root" +# The user 'root' is assumed to be set in your ~/.ssh/config for the SSH_ALIAS + REMOTE_PATH="/www/cgi-bin/skyweave.lua" -SSH_PORT="22" REMOTE_HTTP_PORT="${2:-42069}" # Default to 42069 if not specified # Local script path (default to skyweave.lua in current directory) LOCAL_SCRIPT="${1:-src/skyweave.lua}" -# SSH/SCP legacy crypto options -SSH_OPTS="-oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-rsa -oMACs=+hmac-sha1 -p ${SSH_PORT}" -SCP_OPTS="-O -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-rsa -oMACs=+hmac-sha1 -P ${SSH_PORT}" +# SCP options - '-O' is for legacy SCP mode if required by the server. +# Crypto options and port are now handled by ~/.ssh/config for SSH_ALIAS. +# If your SSH_ALIAS in ~/.ssh/config specifies a non-standard port, +# scp and ssh will use it automatically. +SCP_FLAG_O="-O" # Keep this if your server requires legacy SCP mode # Colors for output GREEN='\033[0;32m' @@ -20,7 +26,8 @@ RED='\033[0;31m' YELLOW='\033[0;33m' NC='\033[0m' # No Color -echo -e "${YELLOW}Deploying ${LOCAL_SCRIPT} to ${ROOF_USER}@${ROOF_IP}:${REMOTE_PATH}...${NC}" +echo -e "${YELLOW}Deploying ${LOCAL_SCRIPT} to ${SSH_ALIAS}:${REMOTE_PATH}...${NC}" +echo -e "${YELLOW}(Ensure '${SSH_ALIAS}' is correctly configured in your ~/.ssh/config)${NC}" # Check if local script exists if [ ! -f "${LOCAL_SCRIPT}" ]; then @@ -28,24 +35,25 @@ if [ ! -f "${LOCAL_SCRIPT}" ]; then exit 1 fi -# Copy the script to the roof unit using legacy SCP -scp ${SCP_OPTS} "${LOCAL_SCRIPT}" ${ROOF_USER}@${ROOF_IP}:${REMOTE_PATH} +# Copy the script to the roof unit using SSH alias +# The SCP_FLAG_O is included; remove it if not needed. +scp ${SCP_FLAG_O} "${LOCAL_SCRIPT}" ${SSH_ALIAS}:${REMOTE_PATH} if [ $? -ne 0 ]; then - echo -e "${RED}Error: Failed to copy script to roof unit!${NC}" + echo -e "${RED}Error: Failed to copy script to ${SSH_ALIAS}!${NC}" exit 1 fi -# Make the script executable using legacy SSH -ssh ${SSH_OPTS} ${ROOF_USER}@${ROOF_IP} "chmod +x ${REMOTE_PATH}" +# Make the script executable using SSH alias +ssh ${SSH_ALIAS} "chmod +x ${REMOTE_PATH}" if [ $? -ne 0 ]; then - echo -e "${RED}Error: Failed to make script executable!${NC}" + echo -e "${RED}Error: Failed to make script executable on ${SSH_ALIAS}!${NC}" exit 1 fi -echo -e "${GREEN}Deployment successful!${NC}" +echo -e "${GREEN}Deployment to ${SSH_ALIAS} successful!${NC}" -# Test the API -echo -e "${YELLOW}Testing API by fetching network configuration...${NC}" +# Test the API (still uses ROOF_IP for HTTP) +echo -e "${YELLOW}Testing API via http://${ROOF_IP}:${REMOTE_HTTP_PORT}...${NC}" RESPONSE=$(curl -s -X GET "http://${ROOF_IP}:${REMOTE_HTTP_PORT}/cgi-bin/skyweave.lua?get_config=network_config") if [ $? -eq 0 ] && [[ "${RESPONSE}" == *'"errCode":0'* ]]; then @@ -58,4 +66,4 @@ else fi echo -e "\n${YELLOW}API endpoint: http://${ROOF_IP}:${REMOTE_HTTP_PORT}/cgi-bin/skyweave.lua${NC}" -echo -e "${YELLOW}Example usage: curl -X POST -H \"Content-Type: application/json\" -d '{\"command\":\"your_command\"}' http://${ROOF_IP}:${REMOTE_HTTP_PORT}/cgi-bin/skyweave.lua${NC}" +echo -e "${YELLOW}Example usage: curl -X POST -H \"Content-Type: application/json\" -d '{\"command\":\"your_command\"}' http://${ROOF_IP}:${REMOTE_HTTP_PORT}/cgi-bin/skyweave.lua${NC}" \ No newline at end of file