feat(api): remove set passwords command
This commit is contained in:
parent
5624fd5cd0
commit
2a74649882
|
@ -84,7 +84,6 @@ Vagrant.configure('2') do |config|
|
||||||
http://192.168.10.100:8080
|
http://192.168.10.100:8080
|
||||||
|
|
||||||
libretime-api migrate
|
libretime-api migrate
|
||||||
libretime-api set_icecast_passwords --from-icecast-config
|
|
||||||
|
|
||||||
systemctl restart libretime.target
|
systemctl restart libretime.target
|
||||||
SCRIPT
|
SCRIPT
|
||||||
|
|
|
@ -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},
|
|
||||||
)
|
|
|
@ -199,12 +199,6 @@ Next, run the following commands to setup the database:
|
||||||
sudo -u libretime libretime-api migrate
|
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:
|
Finally, start the services, and check that they are running properly using the following commands:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
6
install
6
install
|
@ -754,12 +754,6 @@ Once configured, run the following command to setup the database:
|
||||||
${cyan}\
|
${cyan}\
|
||||||
$ sudo -u $LIBRETIME_USER libretime-api migrate
|
$ 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}\
|
${yellow}\
|
||||||
Finally, start LibreTime using the following command:
|
Finally, start LibreTime using the following command:
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue