Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: createHomeDirectory #238

Closed
paddymahoney opened this issue Apr 29, 2014 · 4 comments
Closed

Feature request: createHomeDirectory #238

paddymahoney opened this issue Apr 29, 2014 · 4 comments
Labels
debian documentation Documentation should be extended or updated rpm

Comments

@paddymahoney
Copy link

I was looking to create a home directory for the daemonUser.

I tried to modify some of the debian templates in the following way:

b/module/src/templates/postinst-useradd

@@ -0,0 +1,5 @@
\# Adding ${{user}}
if ! id -u ${{user}} > /dev/null 2>&1; then
    echo "Creating user ${{user}} in group ${{group}}"
    useradd --system --create-home --gid ${{group}} --shell /bin/false ${{user}}
fi

b/module/src/DEBIAN/postrm-purge

\# Deleting user: ${{user}} and group: ${{group}}
case "$1" in
   remove|failed-upgrade|abort-upgrade|abort-install|disappear)
   ;;
   purge)        
        deluser --quiet --remove-home --system ${{user}} > /dev/null || true
        delgroup --quiet --system ${{group}} > /dev/null || true
   ;;
   upgrade)
   ;;
   *)
      echo "postinst called with unknown argument \`\$1'" >&2
   ;;
esac

Alternately, I would use a 'createHomeDirectory in Debian' settingKey.

@muuki88
Copy link
Contributor

muuki88 commented Sep 25, 2014

This should be done after #348
A simple setting createHomeDirectory and corresponding linuxScriptReplacement entry should do the trick.

@francisdb
Copy link
Contributor

@muuki88 most of this stuff is outdated, I was wondering what today would be the best way to have this home directory created

this is my current solution

maintainerScripts in Debian := maintainerScriptsAppend((maintainerScripts in Debian).value)(
  DebianConstants.Postinst -> s"mkdir /home/${(daemonUser in Linux).value}; chown ${(daemonUser in Linux).value}:${(daemonUser in Linux).value} /home/${(daemonUser in Linux).value}"
)

@muuki88 muuki88 added documentation Documentation should be extended or updated and removed feature request labels Mar 19, 2016
@muuki88
Copy link
Contributor

muuki88 commented Mar 19, 2016

@francisdb thanks for sharing. I like the idea of creating a home directory explicitly. I wonder if this would be a nice idea for a small archetype, e.g. CreateHomeDirectoryPlugin, which adds this piece of code to rpm and debian. Or if we just put it in the docs.

@francisdb
Copy link
Contributor

@muuki88 I'm more fan of having an option for --create-home on the useradd command as that probably uses an os-specific template for the home directory instead of an empty folder

@muuki88 muuki88 closed this as completed Jul 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debian documentation Documentation should be extended or updated rpm
Projects
None yet
Development

No branches or pull requests

3 participants