Sunday, September 26, 2010

[update]chkroot

I rearranged the code to check for root then exit 0; if that fails, it checks for a quiet switch and echos an error message accordingly, then exit 1.

#!/bin/bash

if [[ $(id -u) = 0 ]]; then
    exit 0
fi

[[ $1 = "-q" ]] || echo 'error: this script must be run with root privileges'
exit 1

No comments:

Post a Comment