56 Commits

Author SHA1 Message Date
Sunil Mohan Adapa
bfa11beb73
*: pylint: Don't inherit from 'object'
- This was required in Python 2 but useless in Python 3.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2022-07-04 19:46:15 -04:00
James Valleroy
892deefdca
upgrades: Hold packages one at a time
`apt-mark hold PACKAGES` accepts a list of packages. But if one of the
package is missing from the apt repository, then it will fail to hold
any of the listed packages. So it is necessary to try to hold each
package by itself.

Test:
- Run dist-upgrade from bullseye to bookworm. mumble-server package is
currently missing from bookworm, but it should not cause an error in
dist-upgrade.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2022-07-01 10:22:42 -04:00
Sunil Mohan Adapa
9bd1f80d5c
*: Always pass check= argument to subprocess.run()
- Avoid flake8 warnings.

- Makes the call more explicitly readable in case an exception is expected but
check=True is not passed by mistake.

Tests:

- Many tests are skipped since the changes are considered trivial.
check=False is already the default for subprocess.run() method.

- actions/package: Install an app when it is not installed.

- actions/upgrade: Run manual upgrades.

- actions/users: Change a user password. Login. Create/remove a user.

- actions/zoph: Restore a database.

- container: On a fresh repository, run ./container up,ssh,stop,destroy for a
testing container.

- plinth/action_utils.py: Enable/disable an app that has a running service.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2021-10-11 14:34:40 -04:00
James Valleroy
e5c94db620
action_utils: Don't print when unholding freedombox package
Some actions that use this function are expected to output
JSON. Any output from apt-mark can interfere with this.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2021-07-15 20:15:56 -04:00
James Valleroy
39d411be5b
upgrades: Check for held freedombox package daily
Guard against removing a hold while the package manager is busy.

Test:
1. Place hold on freedombox package.
2. Wait 3 minutes in development mode.
   - Package is held.
3. Touch /var/lib/freedombox/package-held.
4. Wait 3 minutes in development mode.
   - Package is not held.
   - Flag is removed.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2021-07-15 20:15:47 -04:00
James Valleroy
912d9ec9e0
upgrades: Check for held freedombox package in manual update
This is to recover from a situation where the package is held, and
then plinth process is interrupted so it cannot release the hold.

We check for and recover from this situation when installing new apps,
and when running dist upgrade. This provides another way to recover
from the problem, by running manual update.

Tests:

- (normal) No hold on freedombox package, and flag is not set. Run
  manual update. Afterwards, there is no hold, and flag is not set.

- (admin preference) Place hold on freedombox package, but flag is not
set. Run manual update. Afterwards, there is still a hold, but flag is
not set.

- (recovery) Place hold on freedombox package, but flag is
set. Run manual update. Afterwards, there is no hold, and flag is not
set.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2021-07-15 20:15:38 -04:00
James Valleroy
856a83c890
action_utils: Use flag to indicate freedombox package has been held
In case the plinth process is interrupted, the "finally" block that is
meant to unhold the package may not be executed, and the package will
stay held. The flag is used to indicate this situation, so it can be
resolved the next time apt_hold_freedombox is used.

Tests:

- (normal) No hold on freedombox package, and flag is not set. Install
  any app. Afterwards, there is no hold, and flag is not set.

- (admin preference) Place hold on freedombox package, but flag is not
  set. Install any app. Afterwards, there is still a hold, but flag is
  not set.

- (recovery) Place hold on freedombox package, but flag is
  set. Install any app. Afterwards, there is no hold, and flag is not
  set.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2021-07-15 20:15:27 -04:00
James Valleroy
5412bd75d7
action_utils: Separate function to hold freedombox package
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2021-07-15 20:15:15 -04:00
Sunil Mohan Adapa
ee991dbab8
action_utils: Introduce utility for masking services
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2021-03-05 18:06:25 -08:00
James Valleroy
566a1bd243
upgrades: Hold tt-rss during dist upgrade, if available
Performs this hold separately from the others, and ignore errors only
for tt-rss.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2021-01-10 20:44:03 -08:00
James Valleroy
6c801f117f
upgrades: Use apt_hold contextmanager
Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-11-25 21:32:23 -08:00
James Valleroy
5424e1e23f
apt: Run apt-get -f install before other commands
Run `apt-get --fix-broken install` before installing package or manual
update. This will attempt to correct broken dependencies.

Tests:
- Install a package without its dependencies using `dpkg -i`.
- Both app install and manual update successfully recover from this
  situation.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2020-06-25 11:54:45 -07:00
Sunil Mohan Adapa
f2c451720d
action_utils: Add utility to call systemd daemon-reload
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Nektarios Katakis <iam@nektarioskatakis.xyz>
2020-03-22 20:08:13 +00:00
Sunil Mohan Adapa
9368504da5
*.py: Use SPDX license identifier
Reviewed-by: Veiko Aasa <veiko17@disroot.org>
2020-02-19 14:38:55 +02:00
Veiko Aasa
a75c1da683
service: Stop service not before but after disabling it
Services that have socket activation enabled (e.g avahi) could automatically
start again after they are stopped manually. This change disables service
before stopping it, preventing it from auto-starting again.

Closes #1772

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2020-02-08 14:45:14 -05:00
Sunil Mohan Adapa
e0dba2cc17
apache: Move diagnostics for checking URLs into apache module
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-30 11:37:57 -05:00
Sunil Mohan Adapa
c617cecc02
daemon: Move diagnosing using netcat to daemon module
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-30 11:37:54 -05:00
Sunil Mohan Adapa
97d8166f31
daemon: Move diagnosing port listening into daemon module
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-30 11:37:52 -05:00
Alice Kile
eb83e00011
fix formatting issues
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-12-07 13:08:35 -05:00
Veiko Aasa
ee03357f65
diagnostics: fix IPv6 failures
- Curl: if an IPv6 zone index is specified, use --interface parameter.
  This fixes two issues:
  - Curl in Debian Buster doesn't support an IPv6 zone index in URL
  - Curl in Debian Bullseye doesn't redirect properly if a zone index is in URL.
- Disable IPv6 diagnostics on daemons that don't listen on an IPv6 address:
  plinth, deluge, transmission

Closes #1519

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Joseph Nuthalapati <njoseph@riseup.net>
2019-11-25 20:10:48 +05:30
Matthias Dellweg
cb3e050722
diagnose: Move negating diagnose result inside try bock
A caught Exception should always be considered a failed test.

Signed-off-by: Matthias Dellweg <2500@gmx.de>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-09-23 18:48:49 -07:00
Sunil Mohan Adapa
1de2b96bc4
action_utils: Workaround problem with setting debconf answers
Closes: #1303.

Test:

Reproduce the problem with debconf-set-selections. Install tt-rss. run
debconf-set

apt install tt-rss
echo 'tt-rss tt-rss/database-type string pgsql' | debconf-set-selections
apt purge tt-rss
echo 'tt-rss tt-rss/database-type string pgsql' | debconf-set-selections
error: Cannot find a question for tt-rss/database-type

Then run try to install ttrss without patch and observe that it fails. Apply
the patch and see that ttrss is installed properly. Observe that database
configured in /etc/ttrss/database.php is 'pgsql'.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-08-31 08:25:07 -04:00
Sunil Mohan Adapa
ca8ea9427c
action_utils: Introduce utility for setting debconf answers
Tests:

mldonkey
 - Installs
 - /etc/default/mldonkey-server has LAUNCH_AT_STARTUP=true
 - systemctl status mldonkey-server shows daemon running

ejabberd
 - Installs
 - /etc/ejabberd/ejabberd.yml has domainname properly configured

privoxy
 - Installs
 - /etc/privoxy/config has listen-address set to '[::]:8118'

roundcube
 - Installs and works
 - /etc/roundcube/debian-db.php contains dbtype sqlite3

ttrss
 - Installs and works
 - /etc/ttrss/database.php has dbtype 'pgsql'.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-08-31 08:24:59 -04:00
Nikolas Nyby
d2e987ef3c
Fix a handful of typos in docs and comments
Found with [codespell](https://github.com/codespell-project/codespell/)

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-07-24 12:39:11 -07:00
Sunil Mohan Adapa
9d44b09fd4
action_utils: Fix checking for URL availability
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-02-09 19:35:57 -05:00
Sunil Mohan Adapa
c0de223ae4
action_utils: Expose URL checking utility for generic use
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2019-02-05 14:58:52 -08:00
James Valleroy
75d6b667ba
radicale: Create collections folder before starting uwsgi
Workaround for https://bugs.debian.org/919339

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
2019-01-14 20:32:44 -05:00
Sunil Mohan Adapa
2c59bbe0f3
action_utils: Implement utilities for managing uwsgi configurations
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2019-01-14 19:51:25 -05:00
Sunil Mohan Adapa
7b326870da
apache: Only regenerate snake oil cert when needed
Closes #1230.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-03-24 20:12:51 -04:00
Sunil Mohan Adapa
dea4af17fb
Rename Plinth to FreedomBox in license headers
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-16 20:10:09 -05:00
Joseph Nuthalapati
ff9d061e98
Add file-sharing application Coquelicot to FreedomBox
- Add settings in Service View
- Fixes for maximum file setting
- Don't allow negative values for max. file size in UI
- Minor text changes to django messages
- Minor correction to maximum file size calculation
- Rename apache conf file to coquelicot-freedombox.conf
- Remove all hacks to adjust file size.
- Fix permissions issues for settings file
- Show status block in UI
- try-restart on settings change instead of restart

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-02-14 07:11:25 -05:00
Sunil Mohan Adapa
527aa66494
tor: Ensure that is-enabled status is show properly
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2018-01-30 17:00:47 +05:30
Joseph Nuthalpati
37138ee83b
mediawiki: Add wiki application
Installs and configures MediaWiki. SSO integration is not included yet.

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2018-01-01 13:20:37 -05:00
Joseph Nuthalapati
890da32aa1
transmission: fix sso not being enabled
- Transmission version wasn't updated, so the new configuration didn't take
  effect.
- The new configuration disabled Transmission's own auth and an apache reload is
  required for SSO auth to be enabled for Transmission. This was not happening
  because webserver_enable command finds that webserver is already enabled for
  Transmission. It cannot detect upgrades. Hence disabled that check for
  reloads. We're still avoiding restarts if there's no config change, just like
  before.

Fixes #1139

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
2017-12-02 19:35:35 -05:00
Rahul De
a22a01a76f Generic framework for user group per application
- Closes #928
- Adds shell and python APIs adding/removing LDAP groups

Signed-off-by: Rahul De <rahul080327@gmail.com>
Reviewed-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
2017-10-05 10:43:50 +05:30
nsaikiran
a8a5da996e
[#759] Add fail2ban to Plinth UI
Run sudo-required action via actions.superuser_run

Actions related to services those require `sudo` permissions need to
be executed via actions.superuser_run.

NOTE:
If plinth service is started via `sudo ./run --debug` (in dev mode)
all actions will be executed silently. But plinth in user machines
won't be executed with sudo permissions.
2017-07-29 09:42:31 -04:00
Joseph Nuthalpati
d269a0a645
diaspora: Completed debconf configuration for Diaspora. 2017-05-06 07:25:34 -04:00
Sunil Mohan Adapa
8059e6d12c
Allow '405 method not allowed' in URL diagnostics
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
2017-04-05 12:58:29 +05:30
Sunil Mohan Adapa
65aadef546
actions: Hush some unneeded output of systemd 2016-09-04 14:47:28 -04:00
Sunil Mohan Adapa
ddc7e07ea1
Use shutil instead of distuils for which()
It is unusual to use distuils outside of setup scripts.
2016-08-26 21:51:55 -04:00
Sunil Mohan Adapa
9ba327f0dd
users: Fix issue with removing temp file 2016-07-31 15:06:20 +05:30
Sunil Mohan Adapa
8e28afe160
users: Move dpkg reconfigure to action utils
In the hope that it will be useful to other actions.  Also delete the
named temporary file after configuration.
2016-07-31 10:58:07 +05:30
nikhilrayaprolu
eca8b8d42e
checking for apache2 installation
- checking whether apache2 is configured or not before checking
  whether it is enabled

- changed python2 syntax to python3

- returning False
2016-07-24 10:41:02 -04:00
Sunil Mohan Adapa
3d5661dc60
action_utils: PEP8 fixes and minor changes 2016-06-03 16:22:06 -04:00
Sunil Mohan Adapa
d3f386733f
diagnostics: Use curl instead of wget for URLs
wget does not seem to support interface scoping for IPv6 addresses.  For
example, http_proxy=http://[fe80::babe:ff:ffff:babe%eth0]:8118/ . Curl
supports this.

This fixes most of the failures for IPv6 related addresses.  Hide the
last failure as there does not seem to be a proper fix from OS level:
when using link local addresses, if a hostname is resolved to IPv6 link
local address, it is not scoped to that interface.  It can't properly be
used by any tool then.
2016-06-03 16:22:02 -04:00
Sunil Mohan Adapa
97b77e3719
diagnostics: Implement scoping for IPv6 addresses 2016-06-03 16:21:59 -04:00
Sunil Mohan Adapa
8d9480901b
action_utils: Limited fallback to sysvinit
In case of start/stop/restart/reload and to check whether service is
running, fallback to sysvinit scripts when systemd is not running.  This
happens inside a chroot environment when setup of essential components
is happening.
2016-05-21 16:06:29 -04:00
Sunil Mohan Adapa
5234bffb3b Don't restart webserver unnecessary
Some of the important modules such as php5, cgi and authnz_ldap are
enabled by default in freedombox-setup.  However, when installing
ikiwiki we still restart the apache2 web server.  This patch fixes that
by restart or reloading only when the corresponding module/config/site
is not already in the state required.
2015-12-03 17:55:22 -05:00
Sunil Mohan Adapa
3df1a88824 Switch to Django i18n for code strings
Django i18n layer is on top of gettext and provide may crucial features
such as per-request locales, lazy translations etc.
2015-11-13 22:08:43 +05:30
James Valleroy
e7b68f7e28 diagnostics: Remove extra 'error' displayed results.
Just show 'error' for missing command.
2015-08-29 09:37:35 -04:00