Ansible roles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
420 B

#!/bin/bash
USER=$1
if [ -z $USER ]; then
echo "Need to get user as first argument"
exit 1
fi
getent passwd $USER >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "User $USER not found"
exit 1
fi
HOME=$(eval echo ~$USER)
if [ ! -d $HOME ]; then
echo "Creating $USER home directory ($HOME)"
umask 022
mkdir -p $HOME
GROUP=$(id -gn $USER)
chown $USER:"$GROUP" $HOME
chmod 700 $HOME
restorecon -R $HOME
fi