From: Jerker Nyberg (jerker_at_update.uu.se)
Date: Sat 23 Feb 2002 - 13:37:11 GMT
Hello Roderick,
I have only been experimenting with vserver a little, but I did something
like that, built an small system from the Red Hat 7.2 installation from
scratch a few months ago.
I include the installation-script in the end of this mail. It is ugly, I
know, but it seemed to get the job done for me anyway. :-)
What really would like to do is to run the Red Hat kickstart-installation
in a virtual server some way, but I guess this will do until then. Or at
least have a tool that will take a name of a package and then install all
the packages it is depending on first. As you can see below I just
experimented my way through the dependencies.
The script would like all the Red Hat 7.2 RPMs (or symlinks to them) in
"/disk1/rh72allrpms/". The reference-server (that the others get unified
to) is called "experiment". You can change those in the script. You may
need to change the script to use it with the latest vserver, I used
vserver-0.7-1 and kernel-2.4.16ctx-4.
I used the script like this (it will take some time to run it).
./create.rpm.sh experiment 10 127.0.0.10
./create.rpm.sh vserver1 11 127.0.0.11
./create.rpm.sh vserver2 12 127.0.0.12
./create.rpm.sh vserver3 13 127.0.0.13
./create.rpm.sh vserver4 14 127.0.0.14
./create.rpm.sh vserver5 15 127.0.0.15
/etc/init.d/vserver start
And after I created a correct /etc/hosts on the host system I could do
"ssh vserver1 -l root" and using "vserver1" as password.
If you add any new RPMs in the script you can just run it again with
the same arguments.
Regards,
Jerker Nyberg.
Uppsala Sweden.
On Fri, 22 Feb 2002, Roderick A. Anderson wrote:
> I've come to this list kind of late in my experience so I have a server
> running vserver kernel-2.4.16ctx-4 (I think). I installed
> vmlinuz-2.4.17ctx-7 but can't remeber if I restarted the server using it
> (not the default setting).
> While setting the system up I made some less than optimal - for a
> unified vserver - configurations choices. I think I can recover from
> these without taking the system down. But before doing that I want get
> my stuff in order.
> My plan is to create a very basic server setup that I can use to
> build other vservers. I'm trying to figure out what is the minimum list
> of packages I need to install to have a barely working vserver. Has
> anyone already done this or can you point me at sources of information
> on the topic?
- - -
#!/bin/bash
if test "$#" != "3" ; then
echo Usage: $0 name_of_server_root number IP-address
exit
fi
VSNAME=$1
S_CONTEXT=$2
IPROOT=$3
REFERENCE=experiment
VSROOT=/vservers/$1
RPMDIR=/disk1/rh72allrpms/
INSTALLEDRPMS=/root/installed.rpms.txt
if test ! -e /etc/vservers/${1}.conf ; then
echo Createing /etc/vservers/${1}.conf
cat >/etc/vservers/${1}.conf <<EOF
IPROOT=$IPROOT
IPROOTDEV=lo
ONBOOT=yes
S_CONTEXT=$S_CONTEXT
S_DOMAINNAME=levonline.com
S_HOSTNAME=$VSNAME.levonline.com
S_NICE=1
S_FLAGS="lock sched nproc"
ULIMIT="-H -u 200"
EOF
fi
. /etc/vservers/$1.conf
function install_rpm () {
if test "$1" = "--nopre" ; then
ARGUMENT="--nopre "
shift
fi
RPMTOINSTALL=""
pushd $RPMDIR &>/dev/null
for i in $* ; do
if rpm -q --root=$VSROOT $i &>/dev/null; then
#echo "redan installerat $i"
echo -n ""
else
if test "$RPMTOINSTALL" != "" ; then
RPMTOINSTALL=$RPMTOINSTALL" "$i
else
RPMTOINSTALL=$i
fi
fi
done
if test "$RPMTOINSTALL" != "" ; then
if echo $RPMTOINSTALL | grep ' ' &>/dev/null; then
RPMLISTA='{'`echo $RPMTOINSTALL | sed 's/ /,/g'`'}'
else
RPMLISTA=$RPMTOINSTALL
fi
eval rpm -ivh $ARGUMENT --root=$VSROOT $RPMDIR/${RPMLISTA}-{0,1,2,3,4,5,6,7,8,9}*.rpm
#echo rpm -ivh $ARGUMENT --root=$VSROOT $RPMDIR/${RPMLISTA}-{0,1,2,3,4,5,6,7,8,9}*.rpm
echo $RPMTOINSTALL >>$VSROOT/$INSTALLEDRPMS
fi
popd &>/dev/null
c}
function create_device () {
if test ! -e $VSROOT/$1 ; then
mknod $VSROOT/$1 $2 $3 $4
chmod $5 $VSROOT/$1
fi
}
if test ! -d $VSROOT ; then
mkdir $VSROOT
fi
if test ! -d $VSROOT/var/lib/rpm ; then
mkdir -p $VSROOT/var/lib/rpm
fi
install_rpm glibc basesystem glibc-common setup filesystem
install_rpm bash mktemp libtermcap termcap
install_rpm info ncurses
install_rpm shadow-utils
install_rpm fileutils
install_rpm textutils
install_rpm grep sed gawk
install_rpm iputils
install_rpm iproute
install_rpm which
install_rpm zlib db1 db2 db3 popt glib bzip2-libs
install_rpm cracklib cracklib-dicts words
install_rpm chkconfig
install_rpm diffutils
install_rpm mount
install_rpm procps
install_rpm pwdb
install_rpm mingetty
install_rpm e2fsprogs
install_rpm logrotate
install_rpm sysklogd
install_rpm psmisc
install_rpm modutils
install_rpm SysVinit pam initscripts util-linux sh-utils ##
install_rpm rpm
install_rpm perl gdbm #
install_rpm openssl
install_rpm openssh openssh-server openssh-clients ##
install_rpm readline
install_rpm gmp
install_rpm python #
install_rpm file
install_rpm findutils
install_rpm mm
install_rpm apache mailcap ##
install_rpm mod_php mod_perl ##
install_rpm less
install_rpm libstdc++
install_rpm groff
install_rpm man ##
install_rpm telnet ##
install_rpm indexhtml
install_rpm lynx ##
install_rpm emacs emacs-nox ##
install_rpm net-tools ##
install_rpm gzip tar
install_rpm binutils cpp
install_rpm losetup
install_rpm mkinitrd
install_rpm kernel
install_rpm glibc-devel kernel-headers
install_rpm libstdc++ libstdc++-devel
install_rpm gcc gcc-c++ ##
install_rpm ftp ncftp ##
install_rpm xinetd #
install_rpm telnet-server ##
install_rpm wu-ftpd ##
install_rpm cyrus-sasl-plain cyrus-sasl-md5 cyrus-sasl
install_rpm procmail
install_rpm krb5-libs
install_rpm openldap
install_rpm sendmail ##
install_rpm passwd ##
install_rpm newt newt-devel
install_rpm slang slang-devel
install_rpm authconfig ##
install_rpm slocate ##
chroot $VSROOT &>/dev/null <<EOF
chkconfig --level 2345 httpd on
chkconfig --level 2345 sshd on
chkconfig --level 2345 sendmail on
chkconfig --level 2345 xinetd on
chkconfig telnet on
chkconfig wu-ftpd on
#
echo $VSNAME | passwd --stdin root
authconfig --kickstart --enableshadow --enablemd5
#
chkconfig --level 2345 nscd off
chkconfig --level 2345 network off
chkconfig --level 2345 syslog off
chkconfig --level 2345 random off
EOF
cat >$VSROOT/etc/hosts <<EOF
$IPROOT $VSNAME $S_HOSTNAME localhost localhost.localdomain
EOF
cat >$VSROOT/etc/sysconfig/network <<EOF
NETWORKING=yes
HOSTNAME=$S_HOSTNAME
EOF
cat >$VSROOT/etc/fstab <<EOF
/dev/hdv1 / ext2 defaults 1 1
none /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
EOF
cat >$VSROOT/etc/mtab <<EOF
/dev/hdv1 / ext2 rw 0 0
none /proc proc defaults 0 0
none /dev/pts devpts gid=5,mode=620 0 0
EOF
rm -f $VSROOT/dev/null
create_device dev/null c 1 3 666
create_device dev/zero c 1 5 666
create_device dev/full c 1 7 666
create_device dev/random c 1 8 644
create_device dev/urandom c 1 9 644
create_device dev/tty c 5 0 666
create_device dev/ptmx c 5 2 666
rm -f $VSROOT/etc/rc.d/rc6.d/S*reboot
rm -f $VSROOT/root/.bash_history
if test "$REFERENCE" != "$VSNAME" ; then
/usr/lib/vserver/vunify $REFERENCE $VSNAME -- `cat $VSROOT/$INSTALLEDRPMS`
fi
- - -