| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # am-i-root.sh: Am I root or not? |
| 3 | |
| 4 | ROOT_UID=0 # Root has $UID 0. |
| 5 | |
| 6 | if [scip-shell system . . `[`. "$UID" -eq "$ROOT_UID" ] # Will the real "root" please stand up? |
| 7 | then |
| 8 | echoscip-shell system . . echo. "You are root." |
| 9 | else |
| 10 | echoscip-shell system . . echo. "You are just an ordinary user (but mom loves you just the same)." |
| 11 | fi |
| 12 | |
| 13 | exit 0 |
| 14 | |
| 15 | |
| 16 | # ============================================================= # |
| 17 | # Code below will not execute, because the script already exited. |
| 18 | |
| 19 | # An alternate method of getting to the root of matters: |
| 20 | |
| 21 | ROOTUSER_NAME=root |
| 22 | |
| 23 | username=`idscip-shell system . . id. -nu` # Or... username=`whoami` |
| 24 | if [scip-shell system . . `[`. "$username" = "$ROOTUSER_NAME" ] |
| 25 | then |
| 26 | echoscip-shell system . . echo. "Rooty, toot, toot. You are root." |
| 27 | else |
| 28 | echoscip-shell system . . echo. "You are just a regular fella." |
| 29 | fi |