| 1 | # Copyright 1999-2003 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2003 Gentoo Technologies, Inc. |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.41 2003/07/14 04:47:17 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/eutils.eclass,v 1.45 2003/07/18 20:43:00 wolf31o2 Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Martin Schlemmer <azarah@gentoo.org> |
5 | # Author: Martin Schlemmer <azarah@gentoo.org> |
| 6 | # |
6 | # |
| 7 | # This eclass is for general purpose functions that most ebuilds |
7 | # This eclass is for general purpose functions that most ebuilds |
| 8 | # have to implement themselves. |
8 | # have to implement themselves. |
| … | |
… | |
| 474 | local euser="$1"; shift |
474 | local euser="$1"; shift |
| 475 | if [ -z "${euser}" ] ; then |
475 | if [ -z "${euser}" ] ; then |
| 476 | eerror "No username specified !" |
476 | eerror "No username specified !" |
| 477 | die "Cannot call enewuser without a username" |
477 | die "Cannot call enewuser without a username" |
| 478 | fi |
478 | fi |
| 479 | einfo "Adding user '${euser}' to your system ..." |
|
|
| 480 | |
479 | |
| 481 | # setup a file for testing usernames/groups |
480 | # setup a file for testing usernames/groups |
| 482 | local tmpfile="`mktemp -p ${T}`" |
481 | local tmpfile="`mktemp -p ${T}`" |
| 483 | touch ${tmpfile} |
482 | touch ${tmpfile} |
| 484 | chown ${euser} ${tmpfile} >& /dev/null |
483 | chown ${euser} ${tmpfile} >& /dev/null |
| 485 | local realuser="`ls -l ${tmpfile} | awk '{print $3}'`" |
484 | local realuser="`ls -l ${tmpfile} | awk '{print $3}'`" |
| 486 | |
485 | |
| 487 | # see if user already exists |
486 | # see if user already exists |
| 488 | if [ "${euser}" == "${realuser}" ] ; then |
487 | if [ "${euser}" == "${realuser}" ] ; then |
| 489 | einfo "${euser} already exists on your system :)" |
|
|
| 490 | return 0 |
488 | return 0 |
| 491 | fi |
489 | fi |
|
|
490 | einfo "Adding user '${euser}' to your system ..." |
| 492 | |
491 | |
| 493 | # options to pass to useradd |
492 | # options to pass to useradd |
| 494 | local opts="" |
493 | local opts="" |
| 495 | |
494 | |
| 496 | # handle uid |
495 | # handle uid |
| … | |
… | |
| 586 | local egroup="$1"; shift |
585 | local egroup="$1"; shift |
| 587 | if [ -z "${egroup}" ] ; then |
586 | if [ -z "${egroup}" ] ; then |
| 588 | eerror "No group specified !" |
587 | eerror "No group specified !" |
| 589 | die "Cannot call enewgroup without a group" |
588 | die "Cannot call enewgroup without a group" |
| 590 | fi |
589 | fi |
| 591 | einfo "Adding group '${egroup}' to your system ..." |
|
|
| 592 | |
590 | |
| 593 | # setup a file for testing groupname |
591 | # setup a file for testing groupname |
| 594 | local tmpfile="`mktemp -p ${T}`" |
592 | local tmpfile="`mktemp -p ${T}`" |
| 595 | touch ${tmpfile} |
593 | touch ${tmpfile} |
| 596 | chgrp ${egroup} ${tmpfile} >& /dev/null |
594 | chgrp ${egroup} ${tmpfile} >& /dev/null |
| 597 | local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`" |
595 | local realgroup="`ls -l ${tmpfile} | awk '{print $4}'`" |
| 598 | |
596 | |
| 599 | # see if group already exists |
597 | # see if group already exists |
| 600 | if [ "${egroup}" == "${realgroup}" ] ; then |
598 | if [ "${egroup}" == "${realgroup}" ] ; then |
| 601 | einfo "${egroup} already exists on your system :)" |
|
|
| 602 | return 0 |
599 | return 0 |
| 603 | fi |
600 | fi |
|
|
601 | einfo "Adding group '${egroup}' to your system ..." |
| 604 | |
602 | |
| 605 | # options to pass to useradd |
603 | # options to pass to useradd |
| 606 | local opts="" |
604 | local opts="" |
| 607 | |
605 | |
| 608 | # handle gid |
606 | # handle gid |