o Add Michael Reifenberger's mini-adduser script.

o	Optionally invoke tzsetup or adduser from the last stage.
o	Add tzsetup and friends to cpio floppy.
This commit is contained in:
Jordan K. Hubbard 1994-11-20 14:49:48 +00:00
parent 0a50d08da1
commit 8151a277cf
5 changed files with 240 additions and 25 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.51 1994/11/20 01:19:33 phk Exp $
# $Id: Makefile,v 1.52 1994/11/20 01:54:13 phk Exp $
#
# Evil floppies are, of course, 1.2MB floppies.
@ -19,17 +19,17 @@ MNT= /mnt
CPIO1= basename cat chmod cksum cp date dd df dmesg echo ed expr hostname kill
CPIO1+= ln ls mkdir mt mv rcp rm rmdir sh sleep stty sync tar test tip [ -sh
CPIO1+= badsect chown clri disklabel dump dmesg fdisk fsck ifconfig init
CPIO1+= badsect chown clri disklabel dump dmesg fdisk fsck getopt ifconfig init
CPIO1+= mknod mount mount_cd9660 mount_msdos mount_nfs ncftp newfs ping pwd
CPIO1+= reboot restore slattach swapon umount route
CPIO1+= rdump rrestore halt ft
CPIO1+= ftp rsh sed telnet rlogin grep
CPIO1+= ftp rsh sed telnet tzsetup rlogin grep
CPIO2= etc/services etc/protocols
# bininst MUST be the last file on the cpio floppy. It's used to detect
# a successful extraction.
CPIO3= miscfuncs.sh instdist.sh netinst.sh bininst
CPIO3= miscfuncs.sh instdist.sh netinst.sh adduser.sh bininst
# Somewhat on the rough side...
CLEANFILES+= *.o *.c *.cache *.mk *.lo ${CPIO1} *.flp *.gz

183
release/adduser.sh Executable file
View File

@ -0,0 +1,183 @@
#!/stand/sh
#
# Written: November 6th, 1994
# Copyright (C) 1994 by Michael Reifenberger
#
# Permission to copy or use this software for any purpose is granted
# provided that this message stay intact, and at this location (e.g. no
# putting your name on top after doing something trivial like reindenting
# it, just to make it look like you wrote it!).
########################
# First set some globals
startuid=1000;
startgid=1000;
gname=guest
uname=guest
shell="/bin/csh"
needgentry="NO"
. /stand/miscfuncs.sh
#########################
# Some Functions we need.
#
###########################
# Show the User all options
usage() {
message "
adduser -h Prints help
adduser -i For interactively adding users
Command line options:
adduser [-u UserName][-g GroupName][-s Shell]"
exit 1
}
##########################
# Get the next free UserID
getuid() {
local xx=$startuid;
uid=$startuid;
for i in `cut -f 3 -d : /etc/master.passwd | cut -c 2- | sort -n`; do
if [ $i -lt $xx ]; then
elif [ $i -eq $xx ]; then xx=`expr $xx + 1`
else uid=$xx; return 0
fi
done
}
#######################################################
# Get the next free GroupID or the GroupID of GroupName
getgid() {
local xx=$startgid;
gid=$startgid;
needgentry="YES"
if grep -q \^$gname: /etc/group; then
gid=`grep \^$gname: /etc/group | cut -f 3 -d:`
needgentry="NO"
else
for i in `cut -f 3 -d : /etc/group | cut -c 2- | sort -n`; do
if [ $i -lt $xx ]; then
elif [ $i -eq $xx ]; then xx=`expr $xx + 1`
else gid=$xx; return 0
fi
done
fi
}
##########################################
# Ask the User interactively what he wants
interact() {
dialog --title "Add New User Name" --clear \
--inputbox "Please specify a login name for the user:\n\
Hit [return] for a default of <$uname>" -1 -1 2> /tmp/i.$$
ret=$?
case $ret in
0)
if [ x`cat /tmp/i.$$` != x ]; then
uname=`cat /tmp/i.$$`; fi;;
1|255)
exit 1;;
esac
if grep -q \^$uname: /etc/master.passwd; then
error "Username $uname already exists."
exit 1
fi
dialog --title "Group Name" --clear \
--inputbox "Which group should $uname belong to?\n\
Hit [return] for default of <$gname>" -1 -1 2> /tmp/i.$$
ret=$?
case $ret in
0)
if [ x`cat /tmp/i.$$` != x ]; then
gname=`cat /tmp/i.$$`; fi;;
1|255)
exit 1;;
esac
dialog --title "Login Shell" --clear \
--inputbox "Please specify which login shell\n<$uname> should use\n\
Hit [return] for default of <$shell>" -1 -1 2> /tmp/i.$$
ret=$?
case $ret in
0)
if [ x`cat /tmp/i.$$` != x ]; then
shell=`cat /tmp/i.$$`; fi;;
1|255)
exit 1;;
esac
##############
# Remove junk
rm -f /tmp/i.$$
}
#########
# START #
#########
###################################
# Parse the commandline for options
set -- `getopt hiu:g:s: $*`
if [ $? != 0 ]; then
usage
fi
for i; do
case "$i"
in
-h)
usage; shift;;
-i)
interact; shift; iflag=yes; break;;
-u)
uname=$2; shift; shift;;
-g)
gname=$2; shift; shift;;
-s)
shell=$2; shift; shift;;
--)
shift; break;;
# *)
# usage; shift;;
esac
done
#####################
# This is no Edituser
if grep -q \^$uname: /etc/master.passwd; then
error "This user already exists in the master password file.\n
Use 'chpass' to edit an existing user rather than adduser.."
exit 1;
fi
###############
# Get Free ID's
getuid;
getgid;
###################
# Only if necessary
if [ $needgentry = "YES" ]; then
echo "$gname:*:$gid:$uname" >> /etc/group
fi
################
# Make /home BTW
mkdir -p -m755 /home/$uname
if [ ! -d /home/$uname ]; then
error "Could not create /home/$uname"
exit 1
else
for xx in /usr/share/skel/*; do
cp $xx /home/$uname/.`basename $xx | cut -f 2 -d .`
done
fi
#####################
# Make the User happy
if [ ! -x $shell ]; then
message "There is no <$shell> shell, using /bin/sh instead.\n
If you wish, you can change this choice later with 'chpass'"
shell="/bin/csh"
elif ! grep -q $shell /etc/shells; then
echo $shell >> /etc/shells
echo "<$shell> added to /etc/shells"
fi
echo "$uname:*:$uid:$gid::0:0:User &:/home/$uname:$shell" >> /etc/master.passwd
pwd_mkdb /etc/master.passwd
chown -R $uname.$gname /home/$uname
chmod -R 644 /home/$uname
chmod 755 /home/$uname
passwd $uname

View File

@ -13,7 +13,7 @@
# putting your name on top after doing something trivial like reindenting
# it, just to make it look like you wrote it!).
#
# $Id: bininst,v 1.45 1994/11/18 13:59:49 jkh Exp $
# $Id: bininst,v 1.46 1994/11/18 16:27:51 jkh Exp $
if [ "$_BININST_LOADED_" = "yes" ]; then
echo "Error, $0 loaded more than once!"
@ -64,25 +64,57 @@ to go, please remove the cpio floppy from the drive and press return!" -1 -1
do_last_config()
{
dialog --title "Auf Wiedersehen!" \
--msgbox "We now come to the end of the installation. Please remove
any floppies from the drive before exiting this dialog. At this point in
time, there's nothing fancy here, but for the release we plan to
ask some additional questions about time zone setup, what sort of
mail client this host is, etc. We just ran out of time for ALPHA!
At the very least, you may wish to check out the 'tzsetup' command;
it will at least handle the first checklist item for you. \n
The login name \"root\" has no password. If you're new to UN*X, log
in as root when prompted for a user name and run vipw to add a new
user for yourself.
dialog --title "Final Configuration!" --menu \
"We now come to the end of the installation. If there's a\n\
floppy in the boot drive, now would probably be a good time\n\
to remove it as the system will reboot when you exit the shell\n\
at the end of this stage.\n\n\
Please select one of the following options:" -1 -1 4 \
"tzsetup" "Configure your time zone" \
"user" "Add a user name for yourself to the system" \
"guest" "Simply add a user \"guest\" with all default options" \
"done" "Exit the installation." 2> ${TMP}/menu.tmp.$$
retval=$?
choice=`cat ${TMP}/menu.tmp.$$`
rm -f ${TMP}/menu.tmp.$$
if ! handle_rval $retval; then exit 0; fi
There are also many useful pre-compiled packages for ${DISTNAME}
available which you may wish to investigate. Look in:
case $choice in
tzsetup)
dialog --clear
tzsetup
dialog --clear
;;
ftp://ftp.freebsd.org/pub/FreeBSD/${DISTNAME}/packages
user)
dialog --clear
sh /stand/adduser.sh -i
;;
guest)
dialog --clear
sh /stand/adduser.sh
;;
esac
dialog --title "Auf Wiedersehen!" --msgbox \
"Don't forget that the login name \"root\" has no password.
If you didn't create any users with adduser, you can at least log in
as this user. Also be aware that root is the _superuser_, which means
that you can easily wipe out your system if you're not careful!
There are many useful pre-compiled packages for ${DISTNAME}
available which you may also wish to investigate. Look in:
ftp://ftp.freebsd.org/pub/FreeBSD/${DISTNAME}/packages
Any install-related comments to jkh@freebsd.org, phk@freebsd.org or
paul@freebsd.org." -1 -1
paul@freebsd.org.
We sincerely hope you enjoy FreeBSD 2.0!
The FreeBSD Project Team" -1 -1
}
welcome

View File

@ -20,8 +20,8 @@ ln sh -sh # init invokes the shell this way
# /sbin stuff
progs badsect basename chown clri disklabel dmesg dump dmesg fdisk fsck ft
progs ifconfig init mknod mount mount_cd9660 mount_msdos mount_nfs newfs ping
progs reboot restore swapon umount route
progs getopt ifconfig init mknod mount mount_cd9660 mount_msdos mount_nfs
progs newfs ping reboot restore route swapon tzsetup umount
ln dump rdump
ln restore rrestore
ln reboot halt

View File

@ -10,7 +10,7 @@
# putting your name on top after doing something trivial like reindenting
# it, just to make it look like you wrote it!).
#
# $Id: miscfuncs.sh,v 1.4 1994/11/18 12:54:45 jkh Exp $
# $Id: miscfuncs.sh,v 1.5 1994/11/18 15:13:37 jkh Exp $
if [ "$_MISCFUNCS_SH_LOADED_" = "yes" ]; then
return 0
@ -22,14 +22,14 @@ PATH=/usr/bin:/usr/sbin:/bin:/sbin:/stand
export PATH
# Keep this current with the distribution!
DISTNAME=2.0-ALPHA
DISTNAME=2.0-BETA
# Flagrant guesses for now. These need to be hand-edited or, much better yet,
# automatically done as part of the release process. When that's the case,
# the hardwired constants will be replaced with tokens that get sed'd for
# the real sizes.
#
BINSIZE="60MB"
BINSIZE="40MB"
GAMESIZE="8MB"
MANSIZE="8MB"
PROFSIZE="4MB"