If you're only installing that one small script, I'd just do it manually. You could use a shar
file, but that seems like overkill.
The biggest issues I see are first, that bash
is going to be located in different locations on different systems, but there's nothing in your script that's Bash-specific, so you could change your shebang to:
#!/bin/sh
or
#!/usr/bin/env bash
for portability.
Second, you will need to choose a location for your script. It strikes me that /usr/local/bin
would be as good as any.
Third, you will need to chown
to set the ownership and chmod
to set the permissions.
Fourth, you should choose better locations for your output files. If they are only for temporary use, then they should be created in /tmp
rather than the root directory where you have suid.old
and suid.new
going, or the current directory where you have newchanges
going. Otherwise, somewhere in var
might be where you'd want to put more persistent data. Perhaps /var/local/suid
.
Fifth, the exit
prevents the second if
from ever being evaluated so no mail will ever be sent.
Sixth, you might want to mv suid.new suid.old
at some point so the next time you do your check it's comparing the most recent saved data.
Seventh, your last mail command should have the file piped or redirected in. It won't work as an argument. And the two mail commands should be swapped so you're not mailing a file when it's empty and are mailing it when it's not.
if [ -s "/newchanges" ]
then
mail -s "No changes have occurred" [email protected] < /path/to/newchanges
else
mail -s "changes have occurred" [email protected]
fi