Initial commit of code. All endpoints tested except for set_connect_wifi()

This commit is contained in:
wes
2025-05-28 08:06:31 -04:00
parent 8dfefac310
commit 189afaeb45
3 changed files with 1060 additions and 0 deletions
Executable
+61
View File
@@ -0,0 +1,61 @@
#!/bin/bash
# skyweave_deploy.sh - Deploy Lua API script to RVLink roof unit (legacy crypto)
ROOF_IP="192.168.10.254"
ROOF_USER="root"
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}"
# Colors for output
GREEN='\033[0;32m'
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}"
# Check if local script exists
if [ ! -f "${LOCAL_SCRIPT}" ]; then
echo -e "${RED}Error: Local script ${LOCAL_SCRIPT} not found!${NC}"
exit 1
fi
# Copy the script to the roof unit using legacy SCP
scp ${SCP_OPTS} "${LOCAL_SCRIPT}" ${ROOF_USER}@${ROOF_IP}:${REMOTE_PATH}
if [ $? -ne 0 ]; then
echo -e "${RED}Error: Failed to copy script to roof unit!${NC}"
exit 1
fi
# Make the script executable using legacy SSH
ssh ${SSH_OPTS} ${ROOF_USER}@${ROOF_IP} "chmod +x ${REMOTE_PATH}"
if [ $? -ne 0 ]; then
echo -e "${RED}Error: Failed to make script executable!${NC}"
exit 1
fi
echo -e "${GREEN}Deployment successful!${NC}"
# Test the API
echo -e "${YELLOW}Testing API by fetching network configuration...${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
echo -e "${GREEN}API test successful!${NC}"
echo -e "Response: ${RESPONSE}"
else
echo -e "${RED}API test failed!${NC}"
echo -e "Curl exit status: $?"
echo -e "Response: ${RESPONSE}"
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}"