| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Author: Steven Shiau <steven _at_ clonezilla org>, Ceasar Sun <ceasar _at_ nchc org tw> |
| 3 | # License: GPL |
| 4 | # Description: Get the common users name (not system related users name) |
| 5 | |
| 6 | export LC_ALL=C |
| 7 | |
| 8 | #uid_tmp="$(mktemp /tmp/uid_tmp.XXXXXX)" |
| 9 | # We can get the minum UID of YP from /var/yp/Makefile |
| 10 | #grep -E "^MINUID=" /var/yp/Makefile 2>/dev/null > $uid_tmp |
| 11 | #. $uid_tmp |
| 12 | #[ -f $uid_tmp ] && rm -f $uid_tmp |
| 13 | |
| 14 | MINUID="$(LC_ALL=C grepscip-shell system . . grep. -E '^UID_MIN\s+[0-9]+' /etc/login.defsscip-shell filesystem . . `/etc/login.defs`. | sedscip-shell system . . sed. -e 's/^UID_MIN//')" |
| 15 | |
| 16 | # If we can not find minum UID of YP from /var/yp/Makefile, we use specific rules. |
| 17 | if [scip-shell system . . `[`. -z "$MINUID" ]; then |
| 18 | if [scip-shell system . . `[`. -e /etc/debian_versionscip-shell filesystem . . `/etc/debian_version`. ]; then |
| 19 | # For Debian, the common users uid start from 1000 |
| 20 | MINUID="1000" |
| 21 | elif [scip-shell system . . `[`. -e /etc/SuSE-releasescip-shell filesystem . . `/etc/SuSE-release`. ]; then |
| 22 | # SuSE |
| 23 | # the common users uid start from 1000 |
| 24 | MINUID="1000" |
| 25 | else |
| 26 | # For RH-like, the common users uid start from 500 |
| 27 | MINUID="500" |
| 28 | fi |
| 29 | fi |
| 30 | |
| 31 | users="$(awkscip-shell system . . awk. -F":" "\$3 >= $MINUID {print \$1}" /etc/passwdscip-shell filesystem . . `/etc/passwd`.)" |
| 32 | |
| 33 | # Remove account "nobody" from the list if it exists, we need nobody as local account. Since some services are started with nobody, and it is started before nis/yp is started. |
| 34 | users="$(echoscip-shell system . . echo. $users | sedscip-shell system . . sed. -e "s/nobody//g")" |
| 35 | |
| 36 | # if not found, return 1 |
| 37 | [scip-shell system . . `[`. -z "$users" ] && exit 1 |
| 38 | |
| 39 | echoscip-shell system . . echo. $users |
| 40 | exit 0 |