mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-02-18 08:33:41 +00:00
- This changes sets the default dpkg vendor as FreedomBox. 'Debian' is still the parent of the vendor. - This results in popcon setting the Vendor as FreedomBox. This allows measuring the popular of FreedomBox distribution itself as against other Debian derivatives in the section 'Statistics per distributions reporting to Debian' of https://popcon.debian.org Tests: - Run `sudo ./setup.py install` and freedombox service. Privacy app will be setup for the first time. In /etc/dpkg/origins/ the file default is a symlink pointing to /etc/dpkg/origins/fredombox. Running 'sudo sh +x /etc/cron.daily/popularity' runs successfully. Remove files /var/lib/popularity-contest/lastsub /var/log/popularity-contest* if necessary. The file /etc/log/popularity-contest shows VENDOR:FreedomBox in the first line. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
59 lines
1.5 KiB
Python
59 lines
1.5 KiB
Python
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""Configure Privacy App."""
|
|
|
|
import pathlib
|
|
from typing import Optional
|
|
|
|
import augeas
|
|
|
|
from plinth.actions import privileged
|
|
|
|
CONFIG_FILE = pathlib.Path('/etc/popularity-contest.d/freedombox.conf')
|
|
|
|
|
|
@privileged
|
|
def setup():
|
|
"""Create initial popcon configuration."""
|
|
CONFIG_FILE.parent.mkdir(exist_ok=True)
|
|
CONFIG_FILE.touch()
|
|
|
|
aug = _load_augeas()
|
|
aug.set('ENCRYPT', 'yes')
|
|
aug.save()
|
|
|
|
# Set the vendor to 'FreedomBox' with 'Debian' as parent
|
|
default_link = pathlib.Path('/etc/dpkg/origins/default')
|
|
debian_link = pathlib.Path('/etc/dpkg/origins/debian')
|
|
if default_link.is_symlink() and default_link.resolve() == debian_link:
|
|
default_link.unlink()
|
|
default_link.symlink_to('freedombox')
|
|
|
|
|
|
@privileged
|
|
def set_configuration(enable_popcon: Optional[bool] = None):
|
|
"""Update popcon configuration."""
|
|
aug = _load_augeas()
|
|
if enable_popcon:
|
|
aug.set('PARTICIPATE', 'yes')
|
|
else:
|
|
aug.set('PARTICIPATE', 'no')
|
|
|
|
aug.save()
|
|
|
|
|
|
def get_configuration() -> dict[str, bool]:
|
|
"""Return if popcon participation is enabled."""
|
|
aug = _load_augeas()
|
|
value = aug.get('PARTICIPATE')
|
|
return {'enable_popcon': (value == 'yes')}
|
|
|
|
|
|
def _load_augeas():
|
|
"""Initialize Augeas."""
|
|
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
|
augeas.Augeas.NO_MODL_AUTOLOAD)
|
|
aug.transform('Shellvars', str(CONFIG_FILE))
|
|
aug.set('/augeas/context', '/files' + str(CONFIG_FILE))
|
|
aug.load()
|
|
return aug
|