Fix script issues with root detection and node configuration

- Fix root confirmation prompt to use echo -n and read instead of read -rp
- Fix non-interactive mode to use NODE_TYPE='node' instead of 'bootstrap'
- Simplify firewall configuration to always use bootstrap ports for node
- Fix final installation summary to show correct ports for node type
- Ensure consistent behavior across all node type checks
This commit is contained in:
johnysigma 2025-08-04 16:26:59 +03:00
parent 6b0951c601
commit e165dfd689

View File

@ -50,7 +50,8 @@ warning() {
if [[ $EUID -eq 0 ]]; then if [[ $EUID -eq 0 ]]; then
warning "Running as root is not recommended for security reasons." warning "Running as root is not recommended for security reasons."
if [ "$NON_INTERACTIVE" != true ]; then if [ "$NON_INTERACTIVE" != true ]; then
read -rp "Are you sure you want to continue? (yes/no): " ROOT_CONFIRM echo -n "Are you sure you want to continue? (yes/no): "
read ROOT_CONFIRM
if [[ "$ROOT_CONFIRM" != "yes" ]]; then if [[ "$ROOT_CONFIRM" != "yes" ]]; then
error "Installation cancelled for security reasons." error "Installation cancelled for security reasons."
exit 1 exit 1
@ -394,7 +395,7 @@ configuration_wizard() {
if [ "$NON_INTERACTIVE" = true ]; then if [ "$NON_INTERACTIVE" = true ]; then
log "Non-interactive mode: using default configuration" log "Non-interactive mode: using default configuration"
NODE_TYPE="bootstrap" NODE_TYPE="node"
SOLANA_WALLET="11111111111111111111111111111111" # Placeholder wallet SOLANA_WALLET="11111111111111111111111111111111" # Placeholder wallet
CONFIGURE_FIREWALL="yes" CONFIGURE_FIREWALL="yes"
log "Node Type: $NODE_TYPE" log "Node Type: $NODE_TYPE"
@ -619,8 +620,7 @@ configure_firewall() {
# This allows the rules to be ready when UFW is enabled # This allows the rules to be ready when UFW is enabled
log "Adding UFW rules for DeBros Network ports..." log "Adding UFW rules for DeBros Network ports..."
# Add ports based on node type with error handling # Add ports for node (using bootstrap ports)
if [ "$NODE_TYPE" = "bootstrap" ]; then
for port in $BOOTSTRAP_PORT $RQLITE_BOOTSTRAP_PORT $RAFT_BOOTSTRAP_PORT; do for port in $BOOTSTRAP_PORT $RQLITE_BOOTSTRAP_PORT $RAFT_BOOTSTRAP_PORT; do
if ! sudo ufw allow $port; then if ! sudo ufw allow $port; then
error "Failed to allow port $port" error "Failed to allow port $port"
@ -628,15 +628,6 @@ configure_firewall() {
fi fi
log "Added UFW rule: allow port $port" log "Added UFW rule: allow port $port"
done done
else
for port in $NODE_PORT $RQLITE_NODE_PORT $RAFT_NODE_PORT; do
if ! sudo ufw allow $port; then
error "Failed to allow port $port"
exit 1
fi
log "Added UFW rule: allow port $port"
done
fi
# Check UFW status and inform user # Check UFW status and inform user
UFW_STATUS=$(sudo ufw status | grep -o "Status: [a-z]\+" | awk '{print $2}' || echo "inactive") UFW_STATUS=$(sudo ufw status | grep -o "Status: [a-z]\+" | awk '{print $2}' || echo "inactive")
@ -650,15 +641,9 @@ configure_firewall() {
else else
warning "UFW not found. Please configure firewall manually." warning "UFW not found. Please configure firewall manually."
log "Required ports to allow:" log "Required ports to allow:"
if [ "$NODE_TYPE" = "bootstrap" ]; then log " - Port $BOOTSTRAP_PORT (Node)"
log " - Port $BOOTSTRAP_PORT (Bootstrap)"
log " - Port $RQLITE_BOOTSTRAP_PORT (RQLite)" log " - Port $RQLITE_BOOTSTRAP_PORT (RQLite)"
log " - Port $RAFT_BOOTSTRAP_PORT (Raft)" log " - Port $RAFT_BOOTSTRAP_PORT (Raft)"
else
log " - Port $NODE_PORT (Node)"
log " - Port $RQLITE_NODE_PORT (RQLite)"
log " - Port $RAFT_NODE_PORT (Raft)"
fi
fi fi
fi fi
} }
@ -816,15 +801,9 @@ main() {
log "${GREEN}Configuration:${NOCOLOR} ${CYAN}$INSTALL_DIR/configs/$NODE_TYPE.yaml${NOCOLOR}" log "${GREEN}Configuration:${NOCOLOR} ${CYAN}$INSTALL_DIR/configs/$NODE_TYPE.yaml${NOCOLOR}"
log "${GREEN}Logs:${NOCOLOR} ${CYAN}$INSTALL_DIR/logs/$NODE_TYPE.log${NOCOLOR}" log "${GREEN}Logs:${NOCOLOR} ${CYAN}$INSTALL_DIR/logs/$NODE_TYPE.log${NOCOLOR}"
if [ "$NODE_TYPE" = "bootstrap" ]; then log "${GREEN}Node Port:${NOCOLOR} ${CYAN}$BOOTSTRAP_PORT${NOCOLOR}"
log "${GREEN}Bootstrap Port:${NOCOLOR} ${CYAN}$BOOTSTRAP_PORT${NOCOLOR}"
log "${GREEN}RQLite Port:${NOCOLOR} ${CYAN}$RQLITE_BOOTSTRAP_PORT${NOCOLOR}" log "${GREEN}RQLite Port:${NOCOLOR} ${CYAN}$RQLITE_BOOTSTRAP_PORT${NOCOLOR}"
log "${GREEN}Raft Port:${NOCOLOR} ${CYAN}$RAFT_BOOTSTRAP_PORT${NOCOLOR}" log "${GREEN}Raft Port:${NOCOLOR} ${CYAN}$RAFT_BOOTSTRAP_PORT${NOCOLOR}"
else
log "${GREEN}Node Port:${NOCOLOR} ${CYAN}$NODE_PORT${NOCOLOR}"
log "${GREEN}RQLite Port:${NOCOLOR} ${CYAN}$RQLITE_NODE_PORT${NOCOLOR}"
log "${GREEN}Raft Port:${NOCOLOR} ${CYAN}$RAFT_NODE_PORT${NOCOLOR}"
fi
log "${BLUE}==================================================${NOCOLOR}" log "${BLUE}==================================================${NOCOLOR}"
log "${GREEN}Management Commands:${NOCOLOR}" log "${GREEN}Management Commands:${NOCOLOR}"