fix_install_wsl.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import re
  2. import os
  3. file_path = "INSTALL_WSL.md"
  4. with open(file_path, "r", encoding="utf-8", errors="replace") as f:
  5. content = f.read()
  6. # Replace the encoding artifact in the first line if present
  7. content = content.replace("Franois", "Francois")
  8. content = content.replace("FranA ois", "Francois")
  9. content = content.replace("Françoise", "Francois")
  10. # 1. Update Step 3 (.env template)
  11. old_step3 = """cat <<EOF > .env
  12. MYSQL_ROOT_PASSWORD=your_db_password_here
  13. DB_READER_PASS=your_db_password_here
  14. DB_LOADER_PASS=your_db_password_here
  15. DB_APP_AUTH_PASS=your_db_password_here
  16. MYSQL_ZABBIX_PASSWORD=your_db_password_here
  17. EOF"""
  18. new_step3 = """Configure your database credentials, active network mode, and the target model name in a `.env` file at the root of the repository. A generic template is provided below:
  19. ```ini
  20. # NETWORK_MODE: local (offline) or server (online)
  21. NETWORK_MODE=local
  22. LLM_MODEL=llama3.2:3b
  23. # DATABASE CREDENTIALS (MySQL)
  24. MYSQL_ROOT_PASSWORD=your_secure_root_password
  25. DB_READER_PASS=your_secure_reader_password
  26. DB_LOADER_PASS=your_secure_loader_password
  27. DB_APP_AUTH_PASS=your_secure_auth_password
  28. MYSQL_ZABBIX_PASSWORD=your_secure_zabbix_password
  29. # ZABBIX & SNMP CREDENTIALS
  30. ZABBIX_USER=Admin
  31. ZABBIX_PASS=zabbix
  32. ZABBIX_SNMP_USER=your_snmp_user
  33. ZABBIX_SNMP_AUTHKEY=your_snmp_authkey
  34. ZABBIX_SNMP_PRIVKEY=your_snmp_privkey
  35. DISCORD_WEBHOOK=https://discord.com/api/webhooks/your_webhook_id
  36. # EMAIL ALERTS CONFIGURATION
  37. EMAIL_USER=your_email@gmail.com
  38. EMAIL_PASS=your_email_app_password
  39. # TAIGA CREDENTIALS
  40. TAIGA_URL=https://192.168.130.161/taiga
  41. TAIGA_USER=your_taiga_user
  42. TAIGA_PASS=your_taiga_password
  43. ```"""
  44. # Remove the extra code fence that would follow the old cat block
  45. content = content.replace(f"```bash\n{old_step3}\n```", new_step3)
  46. # 2. Update Step 5 (model pulling command)
  47. old_step5 = "docker exec -it $(docker ps -q -f name=ollama) ollama pull qwen2.5:7b"
  48. new_step5 = "docker exec -it $(docker ps -q -f name=ollama) ollama pull $( grep '^[ \\t]*LLM_MODEL[ \t]*=' .env | sed 's/^.*=//' )"
  49. content = content.replace(old_step5, new_step5)
  50. content = content.replace("model **`qwen2.5:7b`**", "model")
  51. with open(file_path, "w", encoding="utf-8") as f:
  52. f.write(content)
  53. print("INSTALL_WSL.md successfully updated and encoding sanitized.")