diff --git a/README.md b/README.md index ebbfb74..4c2442a 100644 --- a/README.md +++ b/README.md @@ -1,92 +1,16 @@ # comi-apps-to-update-on-wapt-server +## You want to be notified that some new packages are available for your wapt repository + +Deploy the package on a computer + +connect to the computer and edit "C:\Program Files (x86)\wapt\private\wapt_api.ini" with your url and credentials + +if you want to send an alert by email edit "C:\Program Files (x86)\wapt\private\smtp.ini" + +by default the package send by email , but you can send using rocket chat or any other applicaiton using a webhook following the rocketchat model -## Getting started -To make it easy for you to get started with GitLab, here's a list of recommended next steps. -Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)! -## Add your files - -- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files -- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command: - -``` -cd existing_repo -git remote add origin https://gitlab.com/comitari/comi-apps-to-update-on-wapt-server.git -git branch -M main -git push -uf origin main -``` - -## Integrate with your tools - -- [ ] [Set up project integrations](https://gitlab.com/comitari/comi-apps-to-update-on-wapt-server/-/settings/integrations) - -## Collaborate with your team - -- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/) -- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html) -- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically) -- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/) -- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html) - -## Test and Deploy - -Use the built-in continuous integration in GitLab. - -- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html) -- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/) -- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html) -- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/) -- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html) - -*** - -# Editing this README - -When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template. - -## Suggestions for a good README -Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information. - -## Name -Choose a self-explaining name for your project. - -## Description -Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors. - -## Badges -On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge. - -## Visuals -Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method. - -## Installation -Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection. - -## Usage -Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README. - -## Support -Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc. - -## Roadmap -If you have ideas for releases in the future, it is a good idea to list them in the README. - -## Contributing -State if you are open to contributions and what your requirements are for accepting them. - -For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self. - -You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser. - -## Authors and acknowledgment -Show your appreciation to those who have contributed to the project. - -## License -For open source projects, say how it is licensed. - -## Project status -If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers. diff --git a/all/WAPT/control b/all/WAPT/control deleted file mode 100644 index 40c96b9..0000000 --- a/all/WAPT/control +++ /dev/null @@ -1,44 +0,0 @@ -package : comi-apps-to-update-on-wapt-server -version : 0-16 -architecture : all -section : base -priority : optional -name : json-update -categories : Utilities -maintainer : Comitari,pcosson -description : Package to audit the wapt-server and generate a json with applications that are not up to date -depends : -conflicts : -maturity : PROD -locale : all -target_os : all -min_wapt_version : 2.3 -sources : -installed_size : -impacted_process : -description_fr : Package pour auditer le serveur wapt et générer un json avec les applications qui ne sont pas à jour -description_pl : Pakiet do audytu serwera wapt i generowania pliku json z aplikacjami, które nie są aktualne -description_de : Paket zur Überprüfung des wapt-Servers und zur Erstellung eines json mit Anwendungen, die nicht auf dem neuesten Stand sind -description_es : Paquete para auditar el servidor wapt y generar un json con las aplicaciones que no están actualizadas -description_pt : Pacote para auditar o wapt-server e gerar um json com as aplicações que não estão atualizadas -description_it : Pacchetto per verificare il server wapt e generare un json con le applicazioni che non sono aggiornate -description_nl : Pakket om de wapt-server te controleren en een json te genereren met applicaties die niet up-to-date zijn -description_ru : Пакет для аудита wapt-сервера и генерации json с неактуальными приложениями -audit_schedule : -editor : -keywords : -licence : opensource_free,wapt_public -homepage : -package_uuid : 56be0e6d-4573-4d1f-ad99-1cc5d5d4c718 -valid_from : -valid_until : -forced_install_on : -changelog : -min_os_version : -max_os_version : -icon_sha256sum : d642b35ce6441158dc071677fb958ad01830271d373c332d64e48dec67f80834 -signer : pcosson_key -signer_fingerprint: a25582410cf03bad179a60c189f459a0b03821c92c0cedf209e82448a66a9b4e -signature_date : 2024-04-30T15:04:28.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 : MaKQmI6kWy/jfJDWUJ7FQlwYyIU0FyH6GHi06Tj7DcPOMJgkliC2zCrQtT+d2YGs1kC6HjkPFHMm4zOhk8j4IMUESQH+X7MgYIGizCAXTbyQfxecR9MwvRyQ7flF+d7+i5KHWBYNJmHz/4ng37a6viFyqPfK8uZ5kQC/w+BWMIV+kJFDmxtSWppSVLa27nq8N4sk6r+6R8Of/bY+o1rHpTbzr76b8WK48OFtEUNJ+2NM5l68bJB1t6lgF+4R0SDpMykL+/h4t77jpS8ZCAuoOuBVGrUuvwyIuXQx15Nk7zKgIQ60ePDY8rrTe4PsT5f+BK7ow/6Oe88rUu0Zw8WQ6g== \ No newline at end of file diff --git a/all/WAPT/icon.png b/all/WAPT/icon.png deleted file mode 100644 index 1f86e21..0000000 Binary files a/all/WAPT/icon.png and /dev/null differ diff --git a/all/setup.py b/all/setup.py deleted file mode 100644 index b642ff2..0000000 --- a/all/setup.py +++ /dev/null @@ -1,180 +0,0 @@ -# -*- coding: utf-8 -*- -from setuphelpers import * -import requests -import json -import smtplib -from configparser import ConfigParser -from waptpackage import HostCapabilities -from waptpackage import WaptRemoteRepo -from waptpackage import PackageVersion - -all_package = {} - -dict_host_capa = { - "ubuntu22frx64": HostCapabilities( - architecture="x64", - language="fr", - os="ubuntu", - packages_locales=["fr", "en", "es", "de", "it"], - tags=["debian", "debian_based", "linux", "unix", "debian11", "ubuntu-22"], - os_version="11", - ), - "ubuntu20frx64": HostCapabilities( - architecture="x64", - language="fr", - os="ubuntu", - packages_locales=["fr", "en", "es", "de", "it"], - tags=["debian", "debian_based", "linux", "unix", "debian11", "ubuntu-20"], - os_version="11", - ), - "debian11frx64": HostCapabilities( - architecture="x64", - language="fr", - os="debian", - packages_locales=["fr", "en", "es", "de", "it"], - tags=["debian-bullseye", "debian", "debian_based", "linux", "unix", "debian11", "debian-11"], - os_version="11", - ), - "debian12frx64": HostCapabilities( - architecture="x64", - language="fr", - os="debian", - packages_locales=["fr", "en", "es", "de", "it"], - tags=["debian-bookworm", "debian", "debian_based", "linux", "unix", "debian12", "debian-12"], - os_version="11", - ), - "win10x64fr": HostCapabilities( - architecture="x64", - language="fr", - os="windows", - packages_locales=["fr", "en", "es", "de", "it"], - tags=["windows-10", "win-10", "w-10", "windows10", "win10", "w10", "windows", "win", "w"], - os_version="10.0.19043", - ), -} -webhook_url="https://chat.comitari.fr/hooks/64d4d02760b38508f62a5bcb/ncKSYRiLM9oNXagK5c7G3KWX2qEzET3kbFFXKnNAhtfZQEQ9" - -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) - -def audit(): - plugin_inifile = makepath(WAPT.private_dir, "wapt_api.ini") - conf_wapt = ConfigParser() - conf_wapt.read(plugin_inifile) - wapt_url = conf_wapt.get("wapt", "wapt_url") - wapt_user = conf_wapt.get("wapt", "wapt_username") - wapt_password = conf_wapt.get("wapt", "wapt_password") - - app_to_update_json_path = makepath(WAPT.private_dir, "app_to_update.json") - if isfile(app_to_update_json_path): - print("suppression de l'ancienne version du fichier json") - remove_file(app_to_update_json_path) - - store = WaptRemoteRepo(name="main", url="https://wapt.tranquil.it/wapt", timeout=4, verify_cert=False) - localstore = WaptRemoteRepo(name="main", url="https://srvwapt.comitari.fr/wapt", timeout=4, verify_cert=False) - # Download JSON data from the URL - online_package_list = {} - local_package_list = {} - for hc in dict_host_capa: - online_package_version = {} - for packageentry in store.packages(): - if dict_host_capa[hc].is_matching_package(packageentry): - if not packageentry.package in online_package_version: - online_package_version[packageentry.package] = "0" - if PackageVersion(online_package_version[packageentry.package]) < PackageVersion(packageentry.version): - online_package_version[packageentry.package] = packageentry.version - online_package_list[hc] = online_package_version - - for hc in dict_host_capa: - local_package_version = {} - for packageentry in localstore.packages(): - if dict_host_capa[hc].is_matching_package(packageentry): - if not packageentry.package in local_package_version: - local_package_version[packageentry.package] = "0" - if PackageVersion(local_package_version[packageentry.package]) < PackageVersion(packageentry.version): - local_package_version[packageentry.package] = packageentry.version - local_package_list[hc] = local_package_version - - list_app_to_update = [] - for hc in dict_host_capa: - for app in local_package_list[hc]: - if "-" in app: - if "tis-" + app.split("-", 1)[1] in online_package_list[hc]: - if PackageVersion(local_package_list[hc][app]) < PackageVersion(online_package_list[hc]["tis-" + app.split("-", 1)[1]]) and app not in list_app_to_update: - print( - f'{app} new version detected from {local_package_list[hc][app]} to {online_package_list[hc]["tis-"+app.split("-", 1)[1]]} for {hc}' - ) - list_app_to_update.append( - { - "package": app, - "old_version": local_package_list[hc][app], - "new_version": online_package_list[hc]["tis-" + app.split("-", 1)[1]], - } - ) - WAPT.write_audit_data_if_changed("apps_to_upgrade", "list", list_app_to_update, max_count=3) - - - if not list_app_to_update: - message="your repository seems up to date" - print(message) - send_to_rocket(webhook_url,message) - return "OK" - else: - message="you need to update some packages" - print(message) - send_to_rocket(webhook_url,message) - return "WARNING" - - -def send_to_rocket(webhook_url, message_text, attachments=None): - """ - Envoie un message à Rocket.Chat via un webhook. - - :param webhook_url: URL du webhook Rocket.Chat - :param message_text: Texte du message à envoyer - :param attachments: Liste de pièces jointes (facultatif) - """ - # Construire le message - message = { - 'text': message_text - } - if attachments: - message['attachments'] = attachments - - # Envoyer la requête POST - response = requests.post(webhook_url, data=json.dumps(message), headers={'Content-Type': 'application/json'}) - - # Vérifier la réponse - if response.status_code == 200: - print('Message envoyé avec succès.') - else: - print(f'Échec de l\'envoi du message. Statut de la réponse : {response.status_code}') - print(f'Erreur : {response.text}') - - -def send_mail(body,subject): - - smtp_inifile = makepath(WAPT.private_dir, "smtp.ini") - conf_wapt = ConfigParser() - conf_wapt.read(smtp_inifile) - - from_addr = conf_wapt.get("smtp", "from_addr") - to_addr = conf_wapt.get("smtp", "to_addr") - password = conf_wapt.get("smtp", "password") - smtpserver = conf_wapt.get("smtp", "smtpserver") - - print(from_addr) - - - message = f"Subject: {subject}\n\n{body}" - server = smtplib.SMTP(smtpserver, 587) - server.starttls() - server.login(from_addr, password) - server.sendmail(from_addr, to_addr, message) - server.quit() - return "OK" \ No newline at end of file diff --git a/all/smtp.ini b/all/smtp.ini deleted file mode 100644 index ccc7d1e..0000000 --- a/all/smtp.ini +++ /dev/null @@ -1,5 +0,0 @@ -[wapt] -from_addr = -to_addr = -password = -smtpserver = \ No newline at end of file diff --git a/all/wapt_api.ini b/all/wapt_api.ini deleted file mode 100644 index 3f2be2f..0000000 --- a/all/wapt_api.ini +++ /dev/null @@ -1,4 +0,0 @@ -[wapt] -wapt_username = xxxxx -wapt_password = xxxxx -wapt_url =xxxxx \ No newline at end of file