Commit 2329592e authored by ale's avatar ale

Extend the replds-instance-create script to set a custom data group

The data directory will be owned by this group, and the
instance-specific user will be a member of the group.
parent e8e167bd
Pipeline #4784 passed with stages
in 1 minute and 30 seconds
#!/bin/sh
instance="$1"
instance=
data_group=
while [ $# -gt 0 ]; do
case "$1" in
-g)
data_group="$2"
shift
;;
-*)
echo "Unknown option '$1'" >&2
exit 2
;;
*)
if [ -z "${instance}" ]; then
instance="$1"
else
echo "Too many arguments" >&2
exit 2
fi
;;
esac
shift
done
if [ -z "${instance}" ]; then
echo "Usage: $0 <instance_name>" >&2
echo "Usage: $0 [-g <group>] <instance_name>" >&2
exit 2
fi
......@@ -20,12 +43,16 @@ if ! getent passwd ${instance_user} >/dev/null; then
exit 1
fi
fi
# Ensure that the user is also member of data_group.
if [ -n "${data_group}" ]; then
usermod --append --groups ${data_group} ${instance_user}
fi
# Create the repository directory.
if [ ! -e ${instance_dir} ]; then
mkdir -p ${instance_dir}
fi
chown ${instance_user}:${instance_user} ${instance_dir}
chown ${instance_user}:${data_group:-${instance_user}} ${instance_dir}
chmod 0750 ${instance_dir}
# Create an initial (mostly empty) configuration.
......
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