-
-
Save elmer/506599 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
function manage_user() | |
{ | |
user=$1 | |
password=$2 | |
shift; shift; | |
out=`ralsh user $user password='$password' ensure=present` | |
echo $out | grep 'notice.*changed password' | |
return $? | |
} | |
user=$1 | |
password=$2 | |
if [ -z $user ] | |
then | |
echo "What user?" | |
exit 1 | |
fi | |
if [ -z $password ] | |
then | |
echo "What encrypted password?" | |
exit 1 | |
fi | |
id $user >& /dev/null | |
case "$?" in | |
0) | |
manage_user $user $password | |
if [ $? -eq 0 ] | |
then | |
echo "Changed password for $user" | |
exit 0 | |
else | |
echo "Didn't change password for $user" | |
exit 1 | |
fi | |
;; | |
1) echo "User doesn't exist!"; exit 1 ;; | |
*) echo "There was a problem verifying user's existence!"; exit 1 ;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment