v0.1.10 - In the middle of working on getting admin api working
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Restart Ginxsom Development Environment
|
||||
# Combines nginx and FastCGI restart operations for debugging
|
||||
# WARNING: This script DELETES all databases in db/ for fresh testing
|
||||
|
||||
# Configuration
|
||||
|
||||
@@ -177,9 +178,22 @@ if [ $? -ne 0 ]; then
|
||||
fi
|
||||
echo -e "${GREEN}Clean rebuild complete${NC}"
|
||||
|
||||
# Step 3.5: Handle keys based on mode
|
||||
echo -e "\n${YELLOW}3.5. Configuring server keys...${NC}"
|
||||
DB_PATH="$PWD/db/ginxsom.db"
|
||||
# Step 3.5: Clean database directory for fresh testing
|
||||
echo -e "\n${YELLOW}3.5. Cleaning database directory...${NC}"
|
||||
echo "Removing all existing databases for fresh start..."
|
||||
|
||||
# Remove all .db files in db/ directory
|
||||
if ls db/*.db 1> /dev/null 2>&1; then
|
||||
echo "Found databases to remove:"
|
||||
ls -lh db/*.db
|
||||
rm -f db/*.db
|
||||
echo -e "${GREEN}Database cleanup complete${NC}"
|
||||
else
|
||||
echo "No existing databases found"
|
||||
fi
|
||||
|
||||
# Step 3.75: Handle keys based on mode
|
||||
echo -e "\n${YELLOW}3.75. Configuring server keys...${NC}"
|
||||
|
||||
if [ $TEST_MODE -eq 1 ]; then
|
||||
# Test mode: verify .test_keys file exists
|
||||
@@ -188,29 +202,20 @@ if [ $TEST_MODE -eq 1 ]; then
|
||||
echo -e "${RED}Test mode requires .test_keys file in project root${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Extract test server pubkey to determine database name
|
||||
TEST_PUBKEY=$(grep "^SERVER_PUBKEY=" .test_keys | cut -d"'" -f2)
|
||||
if [ -z "$TEST_PUBKEY" ]; then
|
||||
echo -e "${RED}ERROR: Could not extract SERVER_PUBKEY from .test_keys${NC}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "${GREEN}Test mode: Will use keys from .test_keys${NC}"
|
||||
echo -e "${GREEN}Fresh test database will be created as: db/${TEST_PUBKEY}.db${NC}"
|
||||
else
|
||||
# Production mode: check if keys exist, generate if needed
|
||||
NEED_KEYS=1
|
||||
if command -v sqlite3 >/dev/null 2>&1; then
|
||||
if sqlite3 "$DB_PATH" "SELECT seckey FROM blossom_seckey WHERE id=1" 2>/dev/null | grep -Eq '^[0-9a-f]{64}$'; then
|
||||
NEED_KEYS=0
|
||||
echo -e "${GREEN}Blossom private key found in database${NC}"
|
||||
fi
|
||||
else
|
||||
echo -e "${YELLOW}sqlite3 not found; assuming keys may be missing${NC}"
|
||||
fi
|
||||
|
||||
if [ $NEED_KEYS -eq 1 ]; then
|
||||
echo -e "${YELLOW}No blossom key found; generating server keypair...${NC}"
|
||||
./build/ginxsom-fcgi --db-path "$DB_PATH" --storage-dir blobs --generate-keys 1>>logs/app/stdout.log 2>>logs/app/stderr.log
|
||||
if [ $? -ne 0 ]; then
|
||||
echo -e "${RED}Key generation failed. Check logs/app/stderr.log${NC}"
|
||||
exit 1
|
||||
fi
|
||||
echo -e "${GREEN}Key generation completed${NC}"
|
||||
echo -e "${YELLOW}IMPORTANT: Check logs/app/stderr.log for your generated keys!${NC}"
|
||||
fi
|
||||
# Production mode: databases were cleaned, will generate new keypair
|
||||
echo -e "${YELLOW}Production mode: Fresh start with new keypair${NC}"
|
||||
echo -e "${YELLOW}New database will be created as db/<new_pubkey>.db${NC}"
|
||||
fi
|
||||
|
||||
# Step 4: Start FastCGI
|
||||
@@ -232,10 +237,13 @@ echo "Setting GINX_DEBUG environment for pubkey extraction diagnostics"
|
||||
export GINX_DEBUG=1
|
||||
|
||||
# Build command line arguments based on mode
|
||||
FCGI_ARGS="--db-path $PWD/db/ginxsom.db --storage-dir blobs"
|
||||
FCGI_ARGS="--storage-dir blobs"
|
||||
if [ $TEST_MODE -eq 1 ]; then
|
||||
FCGI_ARGS="$FCGI_ARGS --test-keys"
|
||||
echo -e "${YELLOW}Starting FastCGI in TEST MODE with test keys${NC}"
|
||||
else
|
||||
# Production mode: databases were cleaned, will generate new keys
|
||||
echo -e "${YELLOW}Starting FastCGI in production mode - will generate new keys and create database${NC}"
|
||||
fi
|
||||
|
||||
# Start FastCGI application with proper logging (daemonized but with redirected streams)
|
||||
|
||||
Reference in New Issue
Block a user