## 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:
15
WAPT/control
15
WAPT/control
@@ -1,5 +1,5 @@
|
||||
package : comi-apps-to-update-on-wapt-server
|
||||
version : 0-17
|
||||
version : 2-1
|
||||
architecture : all
|
||||
section : base
|
||||
priority : optional
|
||||
@@ -29,15 +29,16 @@ editor :
|
||||
keywords :
|
||||
licence : opensource_free,wapt_public
|
||||
homepage :
|
||||
package_uuid : 081d68fb-fd04-4bbc-a1f8-734c1ca909eb
|
||||
package_uuid : 8aa32575-7ddd-d66f-dce2-1f7363c259e3
|
||||
valid_from :
|
||||
valid_until :
|
||||
forced_install_on :
|
||||
changelog :
|
||||
min_os_version :
|
||||
max_os_version :
|
||||
icon_sha256sum :
|
||||
signer :
|
||||
signer_fingerprint:
|
||||
signature_date :
|
||||
signed_attributes :
|
||||
icon_sha256sum : d642b35ce6441158dc071677fb958ad01830271d373c332d64e48dec67f80834
|
||||
signer : pcosson_key
|
||||
signer_fingerprint: a25582410cf03bad179a60c189f459a0b03821c92c0cedf209e82448a66a9b4e
|
||||
signature_date : 2025-12-30T14:58:03.000000
|
||||
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==
|
||||
18
comi-apps-to-update-on-wapt-server.ini
Normal file
18
comi-apps-to-update-on-wapt-server.ini
Normal 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 =
|
||||
@@ -1,2 +0,0 @@
|
||||
[rocket]
|
||||
url=
|
||||
45
setup.py
45
setup.py
@@ -11,18 +11,21 @@ from waptpackage import PackageVersion
|
||||
from common import get_requests_client_cert_session
|
||||
|
||||
def install():
|
||||
plugin_inifiles = glob.glob("*.ini")
|
||||
|
||||
for file in plugin_inifiles:
|
||||
if not isfile(makepath(WAPT.private_dir,file.split("\\")[-1])) :
|
||||
print(f"copie de {file} dans {WAPT.private_dir}")
|
||||
filecopyto(file, WAPT.private_dir)
|
||||
# Copy the unified configuration file
|
||||
package_config_file = "comi-apps-to-update-on-wapt-server.ini"
|
||||
if isfile(package_config_file):
|
||||
target_path = makepath(WAPT.private_dir, package_config_file)
|
||||
if not isfile(target_path):
|
||||
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():
|
||||
"""Returns notification configuration from wapt_api.ini."""
|
||||
"""Returns notification configuration from unified package config file."""
|
||||
try:
|
||||
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):
|
||||
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."""
|
||||
try:
|
||||
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):
|
||||
raise FileNotFoundError(f"WAPT configuration file not found: {config_path}")
|
||||
@@ -299,8 +302,10 @@ def audit():
|
||||
print("Info: Starting WAPT package audit...")
|
||||
|
||||
# Initialize WAPT session
|
||||
print("Info: Step 1 - Initializing WAPT session...")
|
||||
try:
|
||||
sessionwapt, t, client_private_key_password = _get_wapt_session()
|
||||
print("Info: ✓ WAPT session initialized successfully")
|
||||
except Exception as e:
|
||||
print(f"Error: Failed to initialize WAPT session: {e}")
|
||||
import traceback
|
||||
@@ -308,8 +313,10 @@ def audit():
|
||||
return "ERROR"
|
||||
|
||||
# Get host capabilities
|
||||
print("Info: Step 2 - Getting host capabilities...")
|
||||
try:
|
||||
dict_host_capa = _get_host_capabilities(sessionwapt)
|
||||
print(f"Info: ✓ Host capabilities retrieved: {len(dict_host_capa)} configurations")
|
||||
except Exception as e:
|
||||
print(f"Error: Failed to get host capabilities: {e}")
|
||||
import traceback
|
||||
@@ -321,9 +328,11 @@ def audit():
|
||||
return "OK"
|
||||
|
||||
# Get online packages
|
||||
print("Info: Step 3 - Getting online packages...")
|
||||
try:
|
||||
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)
|
||||
print(f"Info: ✓ Online packages retrieved for {len(online_package_list)} configurations")
|
||||
except Exception as e:
|
||||
print(f"Error: Failed to fetch online packages: {e}")
|
||||
import traceback
|
||||
@@ -331,6 +340,7 @@ def audit():
|
||||
return "ERROR"
|
||||
|
||||
# Get local packages
|
||||
print("Info: Step 4 - Getting local packages...")
|
||||
try:
|
||||
localstore = WaptRemoteRepo(
|
||||
name="main",
|
||||
@@ -351,6 +361,7 @@ def audit():
|
||||
|
||||
localstore.private_key_password_callback = give_password
|
||||
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:
|
||||
print(f"Error: Failed to fetch local packages: {e}")
|
||||
@@ -386,14 +397,14 @@ def send_to_rocket(message_text, attachments=None):
|
||||
try:
|
||||
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):
|
||||
print("Warning: Rocket.Chat configuration file not found, skipping notification")
|
||||
if not isfile(config_file):
|
||||
print("Warning: Configuration file not found, skipping Rocket.Chat notification")
|
||||
return False
|
||||
|
||||
conf_wapt = ConfigParser()
|
||||
conf_wapt.read(rocket_config_file)
|
||||
conf_wapt.read(config_file)
|
||||
|
||||
try:
|
||||
webhook_url = conf_wapt.get("rocket", "url")
|
||||
@@ -440,14 +451,14 @@ def send_email(body, subject):
|
||||
try:
|
||||
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):
|
||||
print("Warning: SMTP configuration file not found, skipping email notification")
|
||||
if not isfile(config_file):
|
||||
print("Warning: Configuration file not found, skipping email notification")
|
||||
return False
|
||||
|
||||
conf_wapt = ConfigParser()
|
||||
conf_wapt.read(smtp_config_file)
|
||||
conf_wapt.read(config_file)
|
||||
|
||||
try:
|
||||
from_addr = conf_wapt.get("smtp", "from_addr")
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
[wapt]
|
||||
wapt_username = xxxxx
|
||||
wapt_password = xxxxx
|
||||
wapt_url =xxxxx
|
||||
|
||||
[notifications]
|
||||
enable_email = true
|
||||
enable_rocketchat = false
|
||||
notification_method = both
|
||||
Reference in New Issue
Block a user