Compare commits

..

2 Commits

Author SHA1 Message Date
Muhammad Ibrahim
e57ff7612e removed emoji 2025-11-01 03:25:31 +00:00
Muhammad Ibrahim
7a3d98862f Fix emoji parsing error in print functions
- Changed from echo -e to printf for safer special character handling
- Store emoji characters in variables using bash octal escape sequences
- Prevents 'command not found' error when bash interprets emoji as commands
- Fixes issue where line 41 error occurred during setup.sh --update
2025-11-01 02:58:34 +00:00

View File

@@ -66,27 +66,27 @@ SELECTED_SERVICE_NAME=""
# Functions # Functions
print_status() { print_status() {
echo -e "${GREEN}$1${NC}" printf "${GREEN}%s${NC}\n" "$1"
} }
print_info() { print_info() {
echo -e "${BLUE} $1${NC}" printf "${BLUE}%s${NC}\n" "$1"
} }
print_error() { print_error() {
echo -e "${RED}$1${NC}" printf "${RED}%s${NC}\n" "$1"
} }
print_warning() { print_warning() {
echo -e "${YELLOW}⚠️ $1${NC}" printf "${YELLOW}%s${NC}\n" "$1"
} }
print_question() { print_question() {
echo -e "${BLUE}$1${NC}" printf "${BLUE}%s${NC}\n" "$1"
} }
print_success() { print_success() {
echo -e "${GREEN}🎉 $1${NC}" printf "${GREEN}%s${NC}\n" "$1"
} }
# Interactive input functions # Interactive input functions
@@ -1657,7 +1657,7 @@ start_services() {
local logs=$(journalctl -u "$SERVICE_NAME" -n 50 --no-pager 2>/dev/null || echo "") local logs=$(journalctl -u "$SERVICE_NAME" -n 50 --no-pager 2>/dev/null || echo "")
if echo "$logs" | grep -q "WRONGPASS\|NOAUTH"; then if echo "$logs" | grep -q "WRONGPASS\|NOAUTH"; then
print_error "Detected Redis authentication error!" print_error "Detected Redis authentication error!"
print_info "The service cannot authenticate with Redis." print_info "The service cannot authenticate with Redis."
echo "" echo ""
print_info "Current Redis configuration in .env:" print_info "Current Redis configuration in .env:"
@@ -1681,18 +1681,18 @@ start_services() {
print_info " cat /etc/redis/users.acl" print_info " cat /etc/redis/users.acl"
echo "" echo ""
elif echo "$logs" | grep -q "ECONNREFUSED.*postgresql\|Connection refused.*5432"; then elif echo "$logs" | grep -q "ECONNREFUSED.*postgresql\|Connection refused.*5432"; then
print_error "Detected PostgreSQL connection error!" print_error "Detected PostgreSQL connection error!"
print_info "Check if PostgreSQL is running:" print_info "Check if PostgreSQL is running:"
print_info " systemctl status postgresql" print_info " systemctl status postgresql"
elif echo "$logs" | grep -q "ECONNREFUSED.*redis\|Connection refused.*6379"; then elif echo "$logs" | grep -q "ECONNREFUSED.*redis\|Connection refused.*6379"; then
print_error "Detected Redis connection error!" print_error "Detected Redis connection error!"
print_info "Check if Redis is running:" print_info "Check if Redis is running:"
print_info " systemctl status redis-server" print_info " systemctl status redis-server"
elif echo "$logs" | grep -q "database.*does not exist"; then elif echo "$logs" | grep -q "database.*does not exist"; then
print_error "Database does not exist!" print_error "Database does not exist!"
print_info "Database: $DB_NAME" print_info "Database: $DB_NAME"
elif echo "$logs" | grep -q "Error:"; then elif echo "$logs" | grep -q "Error:"; then
print_error "Application error detected in logs" print_error "Application error detected in logs"
fi fi
echo "" echo ""
@@ -1741,9 +1741,9 @@ async function updateSettings() {
}); });
} }
console.log('Database settings updated successfully'); console.log('Database settings updated successfully');
} catch (error) { } catch (error) {
console.error('Error updating settings:', error.message); console.error('Error updating settings:', error.message);
process.exit(1); process.exit(1);
} finally { } finally {
await prisma.\$disconnect(); await prisma.\$disconnect();
@@ -1867,7 +1867,7 @@ EOF
if [ -f "$SUMMARY_FILE" ]; then if [ -f "$SUMMARY_FILE" ]; then
print_status "Deployment summary appended to: $SUMMARY_FILE" print_status "Deployment summary appended to: $SUMMARY_FILE"
else else
print_error "⚠️ Failed to append to deployment-info.txt file" print_error "Failed to append to deployment-info.txt file"
return 1 return 1
fi fi
} }
@@ -1949,7 +1949,7 @@ EOF
print_status "Deployment information saved to: $INFO_FILE" print_status "Deployment information saved to: $INFO_FILE"
print_info "File details: $(ls -lh "$INFO_FILE" | awk '{print $5, $9}')" print_info "File details: $(ls -lh "$INFO_FILE" | awk '{print $5, $9}')"
else else
print_error "⚠️ Failed to create deployment-info.txt file" print_error "Failed to create deployment-info.txt file"
return 1 return 1
fi fi
} }
@@ -2142,7 +2142,7 @@ deploy_instance() {
log_message "Backend port: $BACKEND_PORT" log_message "Backend port: $BACKEND_PORT"
log_message "SSL enabled: $USE_LETSENCRYPT" log_message "SSL enabled: $USE_LETSENCRYPT"
print_status "🎉 PatchMon instance deployed successfully!" print_status "PatchMon instance deployed successfully!"
echo "" echo ""
print_info "Next steps:" print_info "Next steps:"
echo " • Visit your URL: $SERVER_PROTOCOL_SEL://$FQDN (ensure DNS is configured)" echo " • Visit your URL: $SERVER_PROTOCOL_SEL://$FQDN (ensure DNS is configured)"
@@ -3236,7 +3236,7 @@ update_installation() {
sleep 5 sleep 5
if systemctl is-active --quiet "$service_name"; then if systemctl is-active --quiet "$service_name"; then
print_success "Update completed successfully!" print_success "Update completed successfully!"
print_status "Service $service_name is running" print_status "Service $service_name is running"
# Get new version # Get new version
@@ -3264,7 +3264,7 @@ update_installation() {
local logs=$(journalctl -u "$service_name" -n 50 --no-pager 2>/dev/null || echo "") local logs=$(journalctl -u "$service_name" -n 50 --no-pager 2>/dev/null || echo "")
if echo "$logs" | grep -q "WRONGPASS\|NOAUTH"; then if echo "$logs" | grep -q "WRONGPASS\|NOAUTH"; then
print_error "Detected Redis authentication error!" print_error "Detected Redis authentication error!"
print_info "The service cannot authenticate with Redis." print_info "The service cannot authenticate with Redis."
echo "" echo ""
print_info "Current Redis configuration in .env:" print_info "Current Redis configuration in .env:"
@@ -3281,12 +3281,12 @@ update_installation() {
print_info " redis-cli --user $test_user --pass $test_pass -n ${test_db:-0} ping" print_info " redis-cli --user $test_user --pass $test_pass -n ${test_db:-0} ping"
echo "" echo ""
elif echo "$logs" | grep -q "ECONNREFUSED"; then elif echo "$logs" | grep -q "ECONNREFUSED"; then
print_error "Detected connection refused error!" print_error "Detected connection refused error!"
print_info "Check if required services are running:" print_info "Check if required services are running:"
print_info " systemctl status postgresql" print_info " systemctl status postgresql"
print_info " systemctl status redis-server" print_info " systemctl status redis-server"
elif echo "$logs" | grep -q "Error:"; then elif echo "$logs" | grep -q "Error:"; then
print_error "Application error detected in logs" print_error "Application error detected in logs"
fi fi
echo "" echo ""
@@ -3319,7 +3319,7 @@ main() {
# Handle update mode # Handle update mode
if [ "$UPDATE_MODE" = "true" ]; then if [ "$UPDATE_MODE" = "true" ]; then
print_banner print_banner
print_info "🔄 PatchMon Update Mode" print_info "PatchMon Update Mode"
echo "" echo ""
# Select installation to update # Select installation to update
@@ -3335,7 +3335,7 @@ main() {
# Check if existing installations are present # Check if existing installations are present
local existing_installs=($(detect_installations)) local existing_installs=($(detect_installations))
if [ ${#existing_installs[@]} -gt 0 ]; then if [ ${#existing_installs[@]} -gt 0 ]; then
print_warning "⚠️ Found ${#existing_installs[@]} existing PatchMon installation(s):" print_warning "Found ${#existing_installs[@]} existing PatchMon installation(s):"
for install in "${existing_installs[@]}"; do for install in "${existing_installs[@]}"; do
print_info " - $install" print_info " - $install"
done done