1 |
Maybe adding a user creation funcitonality to pkg_config and pkg_postrm |
2 |
is a good solution. It isn't executed automatically and it removes the |
3 |
burned from the user to execute the exact commands, since some packages |
4 |
need to even do more things afterwards, like changing permissions and |
5 |
ownership, or even create multiple users. |
6 |
|
7 |
example from a private package: |
8 |
INSTALLDIR="/opt/${PN} |
9 |
MYGRP="mygrp" |
10 |
MYUSR="myusr" |
11 |
pkg_config() { |
12 |
einfo "Creating ${MYGRP} group if needed <==" |
13 |
if [ ! `grep -x "^${MYGRP}:.*" /etc/group` ] ; then |
14 |
groupadd ${MYGRP}; |
15 |
fi |
16 |
|
17 |
einfo "Creating ${MYUSR} user by deleting a previous existing |
18 |
entry if needed <==" |
19 |
if [ `grep -x "^${MYUSR}:.*" /etc/passwd` ] ; then |
20 |
if [ -d ${INSTALLDIR} ] ; then |
21 |
userdel -r ${MYUSR}; |
22 |
else |
23 |
userdel ${MYUSR}; |
24 |
fi |
25 |
fi |
26 |
useradd -m -d ${INSTALLDIR} -g ${MYGRP} ${MYUSR} |
27 |
|
28 |
echo "==> Updating permissions and ownerships <==" |
29 |
chgrp root `dirname ${INSTALLDIR}` |
30 |
chmod 755 `dirname ${INSTALLDIR}` |
31 |
chown -Rf ${MYUSR}.${MYGRP} ${D}${INSTALLDIR} |
32 |
chmod -Rf 775 ${D}${INSTALLDIR} |
33 |
|
34 |
} |
35 |
|
36 |
pkg_postrm() { |
37 |
|
38 |
einfo "Removing ${MYUSR} user if needed <==" |
39 |
if [ `grep -x "^${MYUSR}:.*" /etc/passwd` ] ; then |
40 |
if [ -d ${INSTALLDIR} ] ; then |
41 |
userdel -r ${MYUSR}; |
42 |
else |
43 |
userdel ${MYUSR}; |
44 |
fi |
45 |
fi |
46 |
|
47 |
} |
48 |
|
49 |
On Tue, 2002-01-29 at 22:43, Martin Schlemmer wrote: |
50 |
> On Tue, 2002-01-29 at 23:32, Sean Mitchell wrote: |
51 |
> > Ah! |
52 |
> > |
53 |
> > Okay... is this because there's no sanctioned way to do it from an ebuild? |
54 |
> > Seems to me that /etc/passwd could get huge if we did this for any package |
55 |
> > that wants its own userid(s). |
56 |
> > |
57 |
> > I'm thinking that I should just call useradd... anyone have wisdom to the |
58 |
> > contrary to offer? |
59 |
> > |
60 |
> > On a bit of a tangent, I'm wondering if a qmail or maybe a maildir USE |
61 |
> > variable wouldn't be justified as it can have a big impact on other |
62 |
> > packages. Mailmail is going to require some tweaking for sure. |
63 |
> > |
64 |
> |
65 |
> What I would have done, is create a pkg_postinst() like |
66 |
> follow: |
67 |
> |
68 |
> pkg_postinst() { |
69 |
> if [ -z "`grep "mailman" /etc/passwd`" ] ; then |
70 |
> echo |
71 |
> echo "***************************************" |
72 |
> echo "* Please create a user called mailman *" |
73 |
> echo "***************************************" |
74 |
> fi |
75 |
> } |
76 |
> |
77 |
> Or similar. I for one do not want stuff just to mess with |
78 |
> my config files without me knowing. After all, Gentoo tries |
79 |
> to be user friendly without crippeling the user ... and |
80 |
> how much effort is it to creat the user exactly how you like |
81 |
> it ? |
82 |
> |
83 |
> |
84 |
> Greetings, |
85 |
> |
86 |
> -- |
87 |
> |
88 |
> Martin Schlemmer |
89 |
> Gentoo Linux Developer, Desktop Team Developer |
90 |
> Cape Town, South Africa |
91 |
> |
92 |
-- |
93 |
Geert Bevin |
94 |
the Leaf sprl/bvba |
95 |
"Use what you need" Pierre Theunisstraat 1/47 |
96 |
http://www.theleaf.be 1030 Brussels |
97 |
gbevin@×××××××.be Tel & Fax +32 2 241 19 98 |