Action Utils

Several utilities to help with the implementation of actions and diagnostic tests are implemented in this module.

Python action utility functions.

class plinth.action_utils.WebserverChange[source]

Context to restart/reload Apache after configuration changes.

__init__()[source]

Initialize the context object state.

disable(name, kind='config')[source]

Disable a config/module/site in Apache.

Don’t apply the changes until the context is exited.

enable(name, kind='config')[source]

Enable a config/module/site in Apache.

Don’t apply the changes until the context is exited.

plinth.action_utils.debconf_set_selections(presets)[source]

Answer debconf questions before installing a package.

plinth.action_utils.dpkg_reconfigure(package, config)[source]

Reconfigure package using debconf database override.

plinth.action_utils.get_addresses()[source]

Return a list of IP addresses and hostnames.

plinth.action_utils.get_hostname()[source]

Return the current hostname.

plinth.action_utils.get_ip_addresses()[source]

Return a list of IP addresses assigned to the system.

plinth.action_utils.is_disk_image()[source]

Return whether the current machine is from a disk image.

Two primary ways to install FreedomBox are: - Using FreedomBox image for various hardware platforms. - Installing packages on a Debian machine using apt.

plinth.action_utils.is_systemd_running()[source]

Return if we are running under systemd.

plinth.action_utils.service_action(service_name, action)[source]

Perform the given action on the service_name.

plinth.action_utils.service_disable(service_name)[source]

Disable and stop service in systemd and sysvinit using update-rc.d.

plinth.action_utils.service_enable(service_name)[source]

Enable and start a service in systemd and sysvinit using update-rc.d.

plinth.action_utils.service_is_enabled(service_name, strict_check=False)[source]

Check if service is enabled in systemd.

In some cases, after disabling a service, systemd puts it into a state called ‘enabled-runtime’ and returns a positive response to ‘is-enabled’ query. Until we understand better, a conservative work around is to pass strict=True to services effected by this behavior.

plinth.action_utils.service_is_running(servicename)[source]

Return whether a service is currently running.

Does not need to run as root.

plinth.action_utils.service_reload(service_name)[source]

Reload a service with systemd or sysvinit.

plinth.action_utils.service_restart(service_name)[source]

Restart a service with systemd or sysvinit.

plinth.action_utils.service_start(service_name)[source]

Start a service with systemd or sysvinit.

plinth.action_utils.service_stop(service_name)[source]

Stop a service with systemd or sysvinit.

plinth.action_utils.service_try_restart(service_name)[source]

Try to restart a service with systemd or sysvinit.

plinth.action_utils.service_unmask(service_name)[source]

Unmask a service

plinth.action_utils.uwsgi_disable(config_name)[source]

Disable a uwsgi configuration that runs under uwsgi.

plinth.action_utils.uwsgi_enable(config_name)[source]

Enable a uwsgi configuration that runs under uwsgi.

plinth.action_utils.uwsgi_is_enabled(config_name)[source]

Return whether a uwsgi config is enabled.

plinth.action_utils.webserver_disable(name, kind='config', apply_changes=True)[source]

Disable config/module/site in Apache.

Restart/reload the webserver if apply_changes is True. Return whether restart(‘restart’), reload(‘reload’) or no action (None) is required. If changes have been applied, then performed action is returned.

plinth.action_utils.webserver_enable(name, kind='config', apply_changes=True)[source]

Enable a config/module/site in Apache.

Restart/reload the webserver if apply_changes is True. Return whether restart(‘restart’), reload(‘reload’) or no action (None) is required. If changes have been applied, then performed action is returned.

plinth.action_utils.webserver_is_enabled(name, kind='config')[source]

Return whether a config/module/site is enabled in Apache.