Here's the check_root.sh script that I wrote:
#!/bin/bash
if [[ $(id -u) != 0 ]]; then
echo 'error: this script must be run with root privileges'
exit 1
fi
exit 0
if [[ $(id -u) != 0 ]]; then
echo 'error: this script must be run with root privileges'
exit 1
fi
exit 0
and here's how it's called within other scripts:
chkroot && [[ $? = 0 ]] || exit 1
No comments:
Post a Comment