users: Try-restart service after service is added to the sharing group

Try-restart the service (instead of restart) after adding service to the
freedombox-share group to avoid starting the service if app is disabled.

Tests performed:
- Remove syncthing user from the freedombox-share group, disable
  syncthing app, increase app version. After the app is upgraded,
  verify that syncthing user is in the freedombox-share group and
  syncthing@syncthing.service remains disabled.
- Remove syncthing user from the freedombox-share group, enable
  syncthing app, increase app version. After the app is upgraded,
  verify that syncthing user is in the freedombox-share group and
  logs show that syncthing@syncthing.service was restarted.

Signed-off-by: Veiko Aasa <veiko17@disroot.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Veiko Aasa 2020-04-03 13:17:48 +03:00 committed by Sunil Mohan Adapa
parent 4187a19c34
commit 2d963ec461
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -155,4 +155,4 @@ def add_user_to_share_group(username, service=None):
actions.superuser_run(
'users', ['add-user-to-group', username, 'freedombox-share'])
if service:
actions.superuser_run('service', ['restart', service])
actions.superuser_run('service', ['try-restart', service])