Created
October 17, 2023 12:57
-
-
Save michelep/d6a1480caa83ae7c2df7318fe721978c to your computer and use it in GitHub Desktop.
RT4 password change script
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
#!/bin/bash | |
echo "==========================" | |
echo "RT4 password change script" | |
echo "==========================" | |
read -p "Username: " username | |
if [ ${#username} -lt 2 ]; then | |
echo "No valid username entered." | |
exit | |
fi | |
read -p "New password for $username: " -s password | |
if [ ${#password} -lt 3 ]; then | |
echo "Password should be at least 3 chars" | |
exit | |
fi | |
echo ""; | |
read -p "Type it again: " -s password2 | |
if [ "$password" = "$password2" ]; then | |
perl -I/opt/rt4/local/lib -I/opt/rt4/lib -MRT -MRT::User -e 'RT::LoadConfig(); RT::Init(); my $u = RT::User->new($RT::SystemUser); $u->Load("$username"); $u->SetPassword("$password")' | |
echo "New password set for user $username" | |
else | |
echo "Password mismatch. Try again!" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment