0

I want to know if it's possible to import some user config files (shell config for zsh or bashrc for example) from our LDAP when a user login for the first time ? It's exactly what mak /etc/skel but it's not defined per user so they can't have their own config (whithout configuring it).

Thank's for your help.

Navino16
  • 1
  • 3

1 Answers1

0

After some research I succesfuly build a kind of workflow for our user to have their own configuration:

  1. Creating a bash script that retrieve user configuration from our gitlab
  2. When we create a new server we add into /etc/skell a line in shell files (.bashrc or .zshrc for example) for executing the script when they login. This step is done automaticly by our Ansible server.
  3. When they login for the first time, skell files are copied and then shell files are loaded (and then our script is executed)
#!/bin/bash
git clone "https://username:password@gitlab_url/ldap-user-config/$USER.git" > /dev/null 2>&1
if [ -d ${HOME}/${USER} ]
then
        shopt -s dotglob
        mv ${HOME}/${USER}/* ${HOME}/
        shopt -u dotglob
        rm -rf "$HOME/.git" "$HOME/$USER"
else
        printf "Something goes wrong during cloning your config, contact an admin\n"
fi
Navino16
  • 1
  • 3