From 2a746498821ddbd7c0b42fa545dbb4428ccaaefb Mon Sep 17 00:00:00 2001 From: jo Date: Mon, 8 Aug 2022 17:17:15 +0200 Subject: [PATCH] feat(api): remove set passwords command --- Vagrantfile | 1 - .../legacy/management/__init__.py | 0 .../legacy/management/commands/__init__.py | 0 .../commands/set_icecast_passwords.py | 76 ------------------- docs/admin-manual/setup/install.md | 6 -- install | 6 -- 6 files changed, 89 deletions(-) delete mode 100644 api/libretime_api/legacy/management/__init__.py delete mode 100644 api/libretime_api/legacy/management/commands/__init__.py delete mode 100644 api/libretime_api/legacy/management/commands/set_icecast_passwords.py diff --git a/Vagrantfile b/Vagrantfile index f0eb6734d..718081686 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -84,7 +84,6 @@ Vagrant.configure('2') do |config| http://192.168.10.100:8080 libretime-api migrate - libretime-api set_icecast_passwords --from-icecast-config systemctl restart libretime.target SCRIPT diff --git a/api/libretime_api/legacy/management/__init__.py b/api/libretime_api/legacy/management/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/api/libretime_api/legacy/management/commands/__init__.py b/api/libretime_api/legacy/management/commands/__init__.py deleted file mode 100644 index e69de29bb..000000000 diff --git a/api/libretime_api/legacy/management/commands/set_icecast_passwords.py b/api/libretime_api/legacy/management/commands/set_icecast_passwords.py deleted file mode 100644 index 38b22c733..000000000 --- a/api/libretime_api/legacy/management/commands/set_icecast_passwords.py +++ /dev/null @@ -1,76 +0,0 @@ -from pathlib import Path -from typing import Optional, Tuple -from xml.etree import ElementTree - -from django.core.management.base import BaseCommand, CommandParser - -from libretime_api.core.models import StreamSetting -from libretime_api.core.models.preference import Preference - - -def get_passwords_from_config( - config_filepath: Path, -) -> Tuple[Optional[str], Optional[str]]: - root = ElementTree.fromstring(config_filepath.read_text(encoding="utf-8")) # nosec - - def _get_text(path) -> Optional[str]: - element = root.find(path) - return element.text if element is not None else None - - return ( - _get_text("./authentication/admin-password"), - _get_text("./authentication/source-password"), - ) - - -class Command(BaseCommand): - help = "Configure icecast passwords in the database." - - def add_arguments(self, parser: CommandParser): - parser.add_argument( - "--from-icecast-config", - help="Get passwords from the Icecast configuration file", - nargs="?", - const="/etc/icecast2/icecast.xml", - type=str, - ) - parser.add_argument( - "--admin-password", - help="Icecast admin password", - type=str, - ) - parser.add_argument( - "--source-password", - help="Icecast source password", - type=str, - ) - - def handle(self, *args, **options): - icecast_config = options.get("from_icecast_config") - admin_password = options.get("admin_password") - source_password = options.get("source_password") - - if icecast_config is not None: - config_passwords = get_passwords_from_config(Path(icecast_config)) - if admin_password is None and config_passwords[0] is not None: - admin_password = config_passwords[0] - if source_password is None and config_passwords[1] is not None: - source_password = config_passwords[1] - - if source_password is not None: - Preference.objects.update_or_create( - key="default_icecast_password", - defaults={"value": source_password}, - ) - - for key in ["s1", "s2", "s3", "s4"]: - if admin_password is not None: - StreamSetting.objects.update_or_create( - key=f"{key}_admin_pass", - defaults={"raw_value": admin_password}, - ) - if source_password is not None: - StreamSetting.objects.update_or_create( - key=f"{key}_pass", - defaults={"raw_value": source_password}, - ) diff --git a/docs/admin-manual/setup/install.md b/docs/admin-manual/setup/install.md index de23985f5..819572b99 100644 --- a/docs/admin-manual/setup/install.md +++ b/docs/admin-manual/setup/install.md @@ -199,12 +199,6 @@ Next, run the following commands to setup the database: sudo -u libretime libretime-api migrate ``` -Synchronize the new Icecast passwords into the database: - -```bash -sudo libretime-api set_icecast_passwords --from-icecast-config -``` - Finally, start the services, and check that they are running properly using the following commands: ```bash diff --git a/install b/install index c26829c9b..ea51ddd48 100755 --- a/install +++ b/install @@ -754,12 +754,6 @@ Once configured, run the following command to setup the database: ${cyan}\ $ sudo -u $LIBRETIME_USER libretime-api migrate -${yellow}\ -Run the following command to configure the default icecast passwords in the database: - -${cyan}\ -$ sudo libretime-api set_icecast_passwords --from-icecast-config - ${yellow}\ Finally, start LibreTime using the following command: