Skip to content

Instantly share code, notes, and snippets.

@michelep
Created October 17, 2023 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michelep/d6a1480caa83ae7c2df7318fe721978c to your computer and use it in GitHub Desktop.
Save michelep/d6a1480caa83ae7c2df7318fe721978c to your computer and use it in GitHub Desktop.
RT4 password change script
#!/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