Description
The Help Desk Server can sometimes suppress email for end-users and admins/techs. This quick (and very basic) script will list them and allow for un-suppressing them in one go.
To use, scp or copy/paste the script into a file on the help desk server VM.
chmod +x to make the script executable
Now run ./scriptname to run the script
Follow
Source Code
#!/bin/bash
db_command () {
/opt/tron/embedded/bin/psql -U tron -p 15432 -h localhost -f $1
}
update_function () {
file=/tmp/sqlaction.sql
if test -f "$file"; then
rm "$file"
fi
echo "UPDATE $1 SET suppress_email = false WHERE suppress_email = true;" > $file
db_command /tmp/sqlaction.sql
}
echo "SELECT id,email,suppress_email,
CASE WHEN role = 0 THEN 'Admin'
WHEN role = 1 THEN 'Manager'
WHEN role = 2 THEN 'Tech'
WHEN role = 3 THEN 'Portal'
WHEN role = 4 THEN 'Email'
ELSE 'unknown' END AS role
FROM users WHERE suppress_email is true;" > /tmp/sqlsel.sql
echo "SELECT id,email,suppress_email FROM end_users WHERE suppress_email is true;" >> /tmp/sqlsel.sql
db_command /tmp/sqlsel.sql
echo "Remove email suppression from the users listed above?"
echo "if no users are listed, no one is currently suppressed and these options will have no effect"
echo
echo "Choose (X) Everyone, (A) admins and techs, (U) end users"
echo "any other key will quit"
read selection
if [ "$selection" = "A" ] || [ "$selection" = "a" ]; then
update_function users
elif [ "$selection" = "U" ] || [ "$selection" = "u" ]; then
update_function end_users
elif [ "$selection" = "X" ] || [ "$selection" = "x" ]; then
update_function users
update_function end_users
else
echo "command not understood, exiting."
exit 1
fi
echo "Completed!"
3 Spice ups
rrhodes
(RobertR at WHC)
2
Thank you! I went a step further, and removed the interactive portion of the script so it just removes the suppression on both admins and users. Then I added it to cron to run every minute. (We’re a small organization, so the overhead is nothing.) Excellent! RLR