feat: update installation script to update the server API hostname and port

This commit is contained in:
sBubshait 2025-08-07 09:50:52 +03:00
parent f1a488d70a
commit c9188a4e31

61
install.sh → install.py Normal file → Executable file
View File

@ -2,6 +2,7 @@
"""
Wesal Social Media App - Installation Script
This script sets up all necessary configuration files and secrets for the Wesal app.
By Saleh Bubshait
"""
import os
@ -131,6 +132,58 @@ def setup_database_config():
create_env_files(hostname, port, db_name, password)
return password
def setup_server_config():
"""Setup server configuration for API base URL"""
print(f"\n{Colors.BOLD}🌐 Server Configuration{Colors.END}")
print("Setting up server hostname and port for API access...")
server_hostname = get_user_input("Server hostname", "server")
server_port = get_user_input("Server port", "8080")
# Update the API constants file
api_constants_path = Path("frontend/lib/constants/api_constants.dart")
if not api_constants_path.exists():
print_error(f"Could not find {api_constants_path}")
print_info("You'll need to manually update the API base URL in your constants file")
return
# Read the existing file
try:
with open(api_constants_path, 'r') as f:
content = f.read()
# Find and replace the baseUrl line
lines = content.split('\n')
updated_lines = []
found_base_url = False
for line in lines:
if 'static const String baseUrl' in line and '=' in line:
# Replace the line with the new hostname and port
indent = line[:len(line) - len(line.lstrip())] # Preserve indentation
new_line = f"{indent}static const String baseUrl = 'http://{server_hostname}:{server_port}';"
updated_lines.append(new_line)
found_base_url = True
print_info(f"Updated baseUrl to: http://{server_hostname}:{server_port}")
else:
updated_lines.append(line)
if not found_base_url:
print_error("Could not find 'static const String baseUrl' line in api_constants.dart")
print_info("You'll need to manually update the API base URL")
return
# Write the updated content back
with open(api_constants_path, 'w') as f:
f.write('\n'.join(updated_lines))
print_success(f"Updated {api_constants_path}")
except Exception as e:
print_error(f"Error updating API constants file: {e}")
print_info("You'll need to manually update the API base URL")
def setup_firebase_credentials():
"""Setup Firebase service account credentials"""
print(f"\n{Colors.BOLD}🔥 Firebase Configuration{Colors.END}")
@ -188,15 +241,14 @@ def setup_firebase_credentials():
return True
def print_summary():
"""Print installation summary"""
print(f"\n{Colors.BOLD}{Colors.GREEN}🎉 Installation Complete!{Colors.END}")
print(f"\n{Colors.BOLD}Files created:{Colors.END}")
print(f"\n{Colors.BOLD}Files created/updated:{Colors.END}")
print("• .env (top level)")
print("• backend/src/main/resources/env.properties")
print("• backend/src/main/resources/firebase-service-account.json")
print("• frontend/lib/constants/api_constants.dart (updated)")
print(f"\n{Colors.BOLD}Next steps:{Colors.END}")
print("1. Run: docker-compose up --build")
print("2. Access your app at: http://localhost:6060")
@ -216,6 +268,9 @@ def main():
# Setup database
db_password = setup_database_config()
# Setup server configuration
setup_server_config()
# Setup Firebase
firebase_success = setup_firebase_credentials()