mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-20 10:34:30 +00:00
syncthing: Use systemd-sysusers for creating a system user account
- Drop dependency on 'adduser' package. Tests: - Functional tests for syncthing work. - Installing syncthing app works. The system user and group are created with proper UID/GID, shell, gecos, and home directory. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
parent
0f98ed67e7
commit
f4be9039d2
@ -0,0 +1,6 @@
|
||||
# Create system user and group to run syncthing as system daemon (as opposed to
|
||||
# running in particular user's account). The user is created at boot or when
|
||||
# 'systemd-sysusers freedombox-syncthing.conf' is run. To override this file as
|
||||
# system administrator, create a file /etc/sysusers.d/freedombox-syncthing.conf
|
||||
# or link it to /dev/null.
|
||||
u! syncthing - "Syncthing file synchronization server" /var/lib/syncthing
|
||||
@ -1,9 +1,7 @@
|
||||
# SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
"""Configure Syncthing."""
|
||||
|
||||
import grp
|
||||
import os
|
||||
import pwd
|
||||
import shutil
|
||||
import time
|
||||
|
||||
@ -32,21 +30,8 @@ def augeas_load(conf_file):
|
||||
@privileged
|
||||
def setup():
|
||||
"""Perform post-install actions for Syncthing."""
|
||||
# Create syncthing group if needed.
|
||||
try:
|
||||
grp.getgrnam('syncthing')
|
||||
except KeyError:
|
||||
action_utils.run(['addgroup', '--system', 'syncthing'], check=True)
|
||||
|
||||
# Create syncthing user if needed.
|
||||
try:
|
||||
pwd.getpwnam('syncthing')
|
||||
except KeyError:
|
||||
action_utils.run([
|
||||
'adduser', '--system', '--ingroup', 'syncthing', '--home',
|
||||
DATA_DIR, '--gecos', 'Syncthing file synchronization server',
|
||||
'syncthing'
|
||||
], check=True)
|
||||
# Create a 'syncthing' system user and group, if needed.
|
||||
action_utils.run(['systemd-sysusers', 'freedombox-syncthing.conf'])
|
||||
|
||||
if not os.path.exists(DATA_DIR):
|
||||
os.makedirs(DATA_DIR, mode=0o750)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user