Created
August 6, 2014 01:06
-
-
Save seocam/4f25253d8951c3583cdd to your computer and use it in GitHub Desktop.
Scripts para criar/modificar usuários
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
USER=$1; GROUP=$2; HOME=$3 | |
if [ 0 -ne $(getent passwd $USER > /dev/null)$? ] | |
then useradd $USER --home $HOME --gid $GROUP -n; fi | |
OLDGID=`getent passwd $USER | awk -F: '{print $4}'` | |
OLDGROUP=`getent group $OLDGID | awk -F: '{print $1}'` | |
OLDHOME=`getent passwd $USER | awk -F: '{print $6}'` | |
if [ "$GROUP" != "$OLDGID" ] && [ "$GROUP" != "$OLDGROUP" ] | |
then usermod --gid $GROUP $USER; fi | |
if [ "$HOME" != "$OLDHOME" ] | |
then usermod --home $HOME $USER; fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment