Commit 588f7c97 authored by ale's avatar ale

Create systemd snippet to set process group if necessary

parent 2329592e
Pipeline #4785 passed with stages
in 1 minute and 24 seconds
#!/bin/sh
#
# Create a new replds instance.
#
# The new instance will have its own configuration in
# /etc/replds/<name>.yml, its data directory in
# /var/lib/replds/<name>, and its own system user and group.
#
# If the '-g <group>' option is passed, the new instance will use the
# specified UNIX group. Permissions of the data directory will be set
# accordingly, and the systemd configuration will be modified.
#
# You are expected to invoke 'systemctl enable replds@<name>.service'
# yourself.
instance=
data_group=
......@@ -48,6 +61,17 @@ if [ -n "${data_group}" ]; then
usermod --append --groups ${data_group} ${instance_user}
fi
# If data_group is specified, create a customized snippet for systemd
# to set the data_group for the running process.
if [ -n "${data_group}" ]; then
systemd_dir="/etc/systemd/system/replds@${instance}.service.d"
mkdir -p ${systemd_dir}
cat >${systemd_dir}/group.conf <<EOF
[Service]
Group=${data_group}
EOF
fi
# Create the repository directory.
if [ ! -e ${instance_dir} ]; then
mkdir -p ${instance_dir}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment