## Consolidate Configuration Files

### Key Changes:
- **Unified Configuration**: Consolidated all configs into single package-named file
- **Removed Separate Files**: Deleted wapt_api.ini, smtp.ini, rocket.ini
- **Updated Functions**: Modified all functions to read from unified config
- **Version Bump**: Updated to version 2-1

### New Configuration Structure:
```
comi-apps-to-update-on-wapt-server.ini
├── [wapt]           # WAPT server credentials
├── [notifications]   # Notification preferences
├── [smtp]           # Email configuration
└── [rocket]         # Rocket.Chat configuration
```

### Benefits:
- **Simpler Deployment**: Single config file instead of 4 separate files
- **Better Organization**: Related settings grouped together
- **Easier Management**: One file to backup and configure
- **Cleaner Package**: No scattered configuration files

### Technical Updates:
- Updated install() function to copy unified config only
- Modified all config reading functions to use unified file path
- Enhanced debug output with step-by-step progress tracking
This commit is contained in:
2025-12-30 16:08:26 +01:00
parent 1f4338a85d
commit 388320bbaf
6 changed files with 54 additions and 40 deletions

View File

@@ -1,5 +1,5 @@
package : comi-apps-to-update-on-wapt-server package : comi-apps-to-update-on-wapt-server
version : 0-17 version : 2-1
architecture : all architecture : all
section : base section : base
priority : optional priority : optional
@@ -29,15 +29,16 @@ editor :
keywords : keywords :
licence : opensource_free,wapt_public licence : opensource_free,wapt_public
homepage : homepage :
package_uuid : 081d68fb-fd04-4bbc-a1f8-734c1ca909eb package_uuid : 8aa32575-7ddd-d66f-dce2-1f7363c259e3
valid_from : valid_from :
valid_until : valid_until :
forced_install_on : forced_install_on :
changelog : changelog :
min_os_version : min_os_version :
max_os_version : max_os_version :
icon_sha256sum : icon_sha256sum : d642b35ce6441158dc071677fb958ad01830271d373c332d64e48dec67f80834
signer : signer : pcosson_key
signer_fingerprint: signer_fingerprint: a25582410cf03bad179a60c189f459a0b03821c92c0cedf209e82448a66a9b4e
signature_date : signature_date : 2025-12-30T14:58:03.000000
signed_attributes : signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
signature : RjghL24x4fj+OVYwHrYc9VRdp+on7V2GurFUS9E9ckLW8+c31EkINGJOtYQiqXlJRPxp7t91+P5sPHmLpX2SjUGThBvgIHDInLhYU22r+ZDGzUyMNwZGjGUyIv6tckGontcw3ysH3YtXRZbg7YID2GTk5zyoEv8BTDvj6BoYQiFMEF36F1yMOLu+S3/8/phUMe26YfbmLi48UbMN1gXvfhAhynl60p2KwYM4nH716IKQXSD3R4Sf4IjkrEjxauIjeG1p2ZQD+FavmCjRDJwrrUY8mWXW3RmNJPTmR1YeS68loWejx2SWfmTER0GdZq+FlHrC7iBg+msh6uVPqnLcag==

View File

@@ -0,0 +1,18 @@
[wapt]
wapt_username = xxxxx
wapt_password = xxxxx
wapt_url = xxxxx
[notifications]
enable_email = true
enable_rocketchat = false
notification_method = both
[smtp]
from_addr =
to_addr =
password =
smtpserver =
[rocket]
url =

View File

@@ -1,2 +0,0 @@
[rocket]
url=

View File

@@ -11,18 +11,21 @@ from waptpackage import PackageVersion
from common import get_requests_client_cert_session from common import get_requests_client_cert_session
def install(): def install():
plugin_inifiles = glob.glob("*.ini") # Copy the unified configuration file
package_config_file = "comi-apps-to-update-on-wapt-server.ini"
for file in plugin_inifiles: if isfile(package_config_file):
if not isfile(makepath(WAPT.private_dir,file.split("\\")[-1])) : target_path = makepath(WAPT.private_dir, package_config_file)
print(f"copie de {file} dans {WAPT.private_dir}") if not isfile(target_path):
filecopyto(file, WAPT.private_dir) print(f"copie de {package_config_file} dans {WAPT.private_dir}")
filecopyto(package_config_file, WAPT.private_dir)
else:
print(f"Warning: Configuration file {package_config_file} not found")
def _get_notification_config(): def _get_notification_config():
"""Returns notification configuration from wapt_api.ini.""" """Returns notification configuration from unified package config file."""
try: try:
CONFWAPT = ConfigParser() CONFWAPT = ConfigParser()
config_path = makepath(WAPT.private_dir, "wapt_api.ini") config_path = makepath(WAPT.private_dir, "comi-apps-to-update-on-wapt-server.ini")
if not isfile(config_path): if not isfile(config_path):
print(f"Warning: Configuration file not found: {config_path}, using defaults") print(f"Warning: Configuration file not found: {config_path}, using defaults")
@@ -75,7 +78,7 @@ def _get_wapt_session():
"""Initializes and returns a WAPT session.""" """Initializes and returns a WAPT session."""
try: try:
CONFWAPT = ConfigParser() CONFWAPT = ConfigParser()
config_path = makepath(WAPT.private_dir, "wapt_api.ini") config_path = makepath(WAPT.private_dir, "comi-apps-to-update-on-wapt-server.ini")
if not isfile(config_path): if not isfile(config_path):
raise FileNotFoundError(f"WAPT configuration file not found: {config_path}") raise FileNotFoundError(f"WAPT configuration file not found: {config_path}")
@@ -299,8 +302,10 @@ def audit():
print("Info: Starting WAPT package audit...") print("Info: Starting WAPT package audit...")
# Initialize WAPT session # Initialize WAPT session
print("Info: Step 1 - Initializing WAPT session...")
try: try:
sessionwapt, t, client_private_key_password = _get_wapt_session() sessionwapt, t, client_private_key_password = _get_wapt_session()
print("Info: ✓ WAPT session initialized successfully")
except Exception as e: except Exception as e:
print(f"Error: Failed to initialize WAPT session: {e}") print(f"Error: Failed to initialize WAPT session: {e}")
import traceback import traceback
@@ -308,8 +313,10 @@ def audit():
return "ERROR" return "ERROR"
# Get host capabilities # Get host capabilities
print("Info: Step 2 - Getting host capabilities...")
try: try:
dict_host_capa = _get_host_capabilities(sessionwapt) dict_host_capa = _get_host_capabilities(sessionwapt)
print(f"Info: ✓ Host capabilities retrieved: {len(dict_host_capa)} configurations")
except Exception as e: except Exception as e:
print(f"Error: Failed to get host capabilities: {e}") print(f"Error: Failed to get host capabilities: {e}")
import traceback import traceback
@@ -321,9 +328,11 @@ def audit():
return "OK" return "OK"
# Get online packages # Get online packages
print("Info: Step 3 - Getting online packages...")
try: try:
store = WaptRemoteRepo(name="main", url='https://wapt.tranquil.it/wapt', timeout=10, verify_cert=True) store = WaptRemoteRepo(name="main", url='https://wapt.tranquil.it/wapt', timeout=10, verify_cert=True)
online_package_list = _get_packages_versions(store, dict_host_capa) online_package_list = _get_packages_versions(store, dict_host_capa)
print(f"Info: ✓ Online packages retrieved for {len(online_package_list)} configurations")
except Exception as e: except Exception as e:
print(f"Error: Failed to fetch online packages: {e}") print(f"Error: Failed to fetch online packages: {e}")
import traceback import traceback
@@ -331,6 +340,7 @@ def audit():
return "ERROR" return "ERROR"
# Get local packages # Get local packages
print("Info: Step 4 - Getting local packages...")
try: try:
localstore = WaptRemoteRepo( localstore = WaptRemoteRepo(
name="main", name="main",
@@ -351,6 +361,7 @@ def audit():
localstore.private_key_password_callback = give_password localstore.private_key_password_callback = give_password
local_package_list = _get_packages_versions(localstore, dict_host_capa) local_package_list = _get_packages_versions(localstore, dict_host_capa)
print(f"Info: ✓ Local packages retrieved for {len(local_package_list)} configurations")
except Exception as e: except Exception as e:
print(f"Error: Failed to fetch local packages: {e}") print(f"Error: Failed to fetch local packages: {e}")
@@ -386,14 +397,14 @@ def send_to_rocket(message_text, attachments=None):
try: try:
print("Info: Attempting to send Rocket.Chat notification...") print("Info: Attempting to send Rocket.Chat notification...")
rocket_config_file = makepath(WAPT.private_dir, "rocket.ini") config_file = makepath(WAPT.private_dir, "comi-apps-to-update-on-wapt-server.ini")
if not isfile(rocket_config_file): if not isfile(config_file):
print("Warning: Rocket.Chat configuration file not found, skipping notification") print("Warning: Configuration file not found, skipping Rocket.Chat notification")
return False return False
conf_wapt = ConfigParser() conf_wapt = ConfigParser()
conf_wapt.read(rocket_config_file) conf_wapt.read(config_file)
try: try:
webhook_url = conf_wapt.get("rocket", "url") webhook_url = conf_wapt.get("rocket", "url")
@@ -440,14 +451,14 @@ def send_email(body, subject):
try: try:
print("Info: Attempting to send email notification...") print("Info: Attempting to send email notification...")
smtp_config_file = makepath(WAPT.private_dir, "smtp.ini") config_file = makepath(WAPT.private_dir, "comi-apps-to-update-on-wapt-server.ini")
if not isfile(smtp_config_file): if not isfile(config_file):
print("Warning: SMTP configuration file not found, skipping email notification") print("Warning: Configuration file not found, skipping email notification")
return False return False
conf_wapt = ConfigParser() conf_wapt = ConfigParser()
conf_wapt.read(smtp_config_file) conf_wapt.read(config_file)
try: try:
from_addr = conf_wapt.get("smtp", "from_addr") from_addr = conf_wapt.get("smtp", "from_addr")

View File

@@ -1,5 +0,0 @@
[wapt]
from_addr =
to_addr =
password =
smtpserver =

View File

@@ -1,9 +0,0 @@
[wapt]
wapt_username = xxxxx
wapt_password = xxxxx
wapt_url =xxxxx
[notifications]
enable_email = true
enable_rocketchat = false
notification_method = both