debian/postinst: register new home dir with usermod
When a new home is created while migrating from "/var/kurento" to
"/var/lib/kurento", not only the new dir has to be created, but the
system file "/etc/passwd" must be updated accordingly. This is done via
the usermod command.
Cross-repo: kms-core, kurento-media-server
-# Shell setup
-# -----------
-
# Bash options for strict error checking
set -o errexit -o errtrace -o pipefail -o nounset
@@ -18,15 +15,11 @@ set -o xtrace
# Settings
-# --------
-
HOME_DIR="/var/lib/kurento"
# Create the kurento user
-# -----------------------
-
if ! id kurento >/dev/null 2>&1; then
adduser \
--system --group \
@@ -37,19 +30,20 @@ fi
-# Create the kurento home directory
-# ---------------------------------
-
+# Prepare the kurento home directory
mkdir -p "$HOME_DIR"
chown -R kurento "$HOME_DIR"
chmod 777 "$HOME_DIR"
# FIXME+DEPRECATED: Old home dir was "/var/kurento"
# keep it as a symlink to avoid breaking user's setups,
-# but delete this code once releasing next major version of Kurento
+# but delete this code once releasing next major version, Kurento 7.0
HOME_DIR_OLD="/var/kurento"
if [[ -d "$HOME_DIR_OLD" && ! -L "$HOME_DIR_OLD" ]]; then
mv "$HOME_DIR_OLD"/* "$HOME_DIR_OLD"/.* "$HOME_DIR"/ 2>/dev/null || true
rmdir "$HOME_DIR_OLD"
ln -s -T "$HOME_DIR" "$HOME_DIR_OLD"
+
+ # Set the new dir as user's dir in /etc/passwd
+ usermod --home "$HOME_DIR" kurento
fi
