v0.2.2 - Working on config setup
This commit is contained in:
@@ -5,6 +5,53 @@
|
||||
|
||||
echo "=== C Nostr Relay Build and Restart Script ==="
|
||||
|
||||
# Parse command line arguments
|
||||
PRESERVE_CONFIG=false
|
||||
HELP=false
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--preserve-config|-p)
|
||||
PRESERVE_CONFIG=true
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
HELP=true
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1"
|
||||
HELP=true
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Show help
|
||||
if [ "$HELP" = true ]; then
|
||||
echo "Usage: $0 [OPTIONS]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --preserve-config Keep existing configuration file (don't regenerate)"
|
||||
echo " --help, -h Show this help message"
|
||||
echo ""
|
||||
echo "Default behavior: Automatically regenerates configuration file on each build"
|
||||
echo " for development purposes"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Handle configuration file regeneration
|
||||
CONFIG_FILE="$HOME/.config/c-relay/c_relay_config_event.json"
|
||||
if [ "$PRESERVE_CONFIG" = false ] && [ -f "$CONFIG_FILE" ]; then
|
||||
echo "Removing old configuration file to trigger regeneration..."
|
||||
rm -f "$CONFIG_FILE"
|
||||
echo "✓ Configuration file removed - will be regenerated with latest database values"
|
||||
elif [ "$PRESERVE_CONFIG" = true ] && [ -f "$CONFIG_FILE" ]; then
|
||||
echo "Preserving existing configuration file as requested"
|
||||
elif [ ! -f "$CONFIG_FILE" ]; then
|
||||
echo "No existing configuration file found - will generate new one"
|
||||
fi
|
||||
|
||||
# Build the project first
|
||||
echo "Building project..."
|
||||
make clean all
|
||||
@@ -90,6 +137,19 @@ if ps -p "$RELAY_PID" >/dev/null 2>&1; then
|
||||
# Save PID for debugging
|
||||
echo $RELAY_PID > relay.pid
|
||||
|
||||
# Check if a new private key was generated and display it
|
||||
sleep 1 # Give relay time to write initial logs
|
||||
if grep -q "GENERATED RELAY ADMIN PRIVATE KEY" relay.log 2>/dev/null; then
|
||||
echo "=== IMPORTANT: NEW ADMIN PRIVATE KEY GENERATED ==="
|
||||
echo ""
|
||||
# Extract and display the private key section from the log
|
||||
grep -A 8 -B 2 "GENERATED RELAY ADMIN PRIVATE KEY" relay.log | head -n 12
|
||||
echo ""
|
||||
echo "⚠️ SAVE THIS PRIVATE KEY SECURELY - IT CONTROLS YOUR RELAY!"
|
||||
echo "⚠️ This key is also logged in relay.log for reference"
|
||||
echo ""
|
||||
fi
|
||||
|
||||
echo "=== Relay server running in background ==="
|
||||
echo "To kill relay: pkill -f 'c_relay_'"
|
||||
echo "To check status: ps aux | grep c_relay_"
|
||||
|
||||
Reference in New Issue
Block a user