add user
Geert Stappers
Geert.Stappers at xs4all.nl
Tue Oct 9 17:33:31 CEST 2001
Hello,
FAI is a beautyfull concept.
Especial for clusters or other computerpools in a NIS it is a nice tool.
For stand alone computers it misses an "add user" function.
After install you still have to create an user,
because there is no NIS where the user management is done.
So had to build a "adduser"-function.
It is a shell script, which is self documented.
See the attached patch.
The great magic in the script is
chroot $target adduser
and the
chroot $target expect << HERE
The main benefit is that you don't have to allow remote root login.
This is more secure. It is also more like the "standard" Debian installation
where the installer asks for a non-root user account to install.
To activate the script you have to add a line "ADDUSER" in a class file.
The "expect dot deb" has to be installed. Beware: on Potato there
is a "expect5.24" and "expect5.31", on Woody "expect", what can't go wrong.
I hope that the add user script is also usefull for other people.
For me it is. ;-)
Kind Regards
Geert Stappers
-------------------------
diff -urN fai-vanilla/templates/scripts/ADDUSER fai/templates/scripts/ADDUSER
--- fai-vanilla/templates/scripts/ADDUSER Thu Jan 1 01:00:00 1970
+++ fai/templates/scripts/ADDUSER Tue Oct 9 15:38:25 2001
@@ -0,0 +1,33 @@
+#! /bin/sh
+#
+# (c) Geert Stappers, 2001, Geert.Stappers at xs4all.nl
+# to be used for FAI, Full Automatic Installation
+#
+# ADDUSER, Adds an user
+# $adduser_name and $adduser_passwd got their value in ADDUSER.var
+#
+
+[ ${debug} ] && set -vx
+
+# create the user and his/her home dir
+chroot ${target} adduser --disabled-password \
+ --gecos ${adduser_name}\ ${HOSTNAME} ${adduser_name}
+# having a hostname in "the real name" is usefull
+# when recieving mail from the user which is on so many computers
+
+# set password with the "talk to program" program `expect`
+# the slash before the dollar-sign is
+# to protect the `expect` variables
+chroot ${target} expect << HERE
+ spawn passwd \$env(adduser_name)
+ expect "word*:"
+ send "\$env(adduser_passwd)\r"
+ expect "word*:"
+ send "\$env(adduser_passwd)\r"
+ expect eof
+HERE
+
+[ ${debug} ] && set +vx
+
+## note: 'adduser' and 'expect' didn't work together...
+# end of shell script
diff -urN fai-vanilla/templates/class/ADDUSER.var
fai/templates/class/ADDUSER.var
--- fai-vanilla/templates/class/ADDUSER.var Thu Jan 1 01:00:00 1970
+++ fai/templates/class/ADDUSER.var Tue Oct 9 15:47:51 2001
@@ -0,0 +1,4 @@
+# variables for ADDUSER
+adduser_name=stappers
+adduser_passwd=fai
+#
Kind Regards, Geert Stappers
---------------------
The Future is now, be part of it.
More information about the linux-fai
mailing list