#!/bin/bashVNAME=$1
CDROM="/mnt/cdrom/slackware"
VSDIR="/vservers"
PKGS="
a/aaa_base-12.0.0-noarch-1.tgz
a/aaa_elflibs-12.0.0-i486-3.tgz
a/aaa_terminfo-5.6-noarch-1.tgz
a/acl-2.2.39_1-i486-2.tgz
a/attr-2.4.32_1-i486-2.tgz
a/bash-3.1.017-i486-2.tgz
a/bin-11.1-i486-1.tgz
a/bzip2-1.0.4-i486-1.tgz
a/coreutils-6.9-i486-1.tgz
a/cxxlibs-6.0.8-i486-4.tgz
a/dcron-2.3.3-i486-6.tgz
a/dialog-1.1_20070528-i486-1.tgz
a/e2fsprogs-1.39-i486-1.tgz
a/ed-0.5-i486-1.tgz
a/etc-11.1-noarch-6.tgz
a/file-4.21-i486-1.tgz
a/findutils-4.2.31-i486-1.tgz
a/gawk-3.1.5-i486-3.tgz
a/gettext-0.16.1-i486-3.tgz
a/getty-ps-2.1.0b-i486-1.tgz
a/glibc-solibs-2.5-i486-4.tgz
a/glibc-zoneinfo-2.5-noarch-4.tgz
a/grep-2.5-i486-3.tgz
a/gzip-1.3.12-i486-1.tgz
a/infozip-5.52-i486-2.tgz
a/kbd-1.12-i486-2.tgz
a/less-394-i486-1.tgz
a/logrotate-3.7.4-i486-1.tgz
a/openssl-solibs-0.9.8e-i486-3.tgz
a/patch-2.5.4-i486-1.tgz
a/pkgtools-12.0.0-noarch-4.tgz
a/procps-3.2.7-i486-2.tgz
a/quota-3.13-i486-1.tgz
a/sed-4.1.5-i486-1.tgz
a/shadow-4.0.3-i486-14.tgz
a/sharutils-4.6.3-i486-1.tgz
a/sysfsutils-2.1.0-i486-1.tgz
a/sysklogd-1.4.1-i486-10.tgz
a/syslinux-3.36-i486-1.tgz
a/sysvinit-2.86-i486-5.tgz
a/sysvinit-functions-8.53-i486-2.tgz
a/sysvinit-scripts-1.2-noarch-13.tgz
a/tar-1.16.1-i486-1.tgz
a/time-1.7-i486-1.tgz
a/utempter-1.1.4-i486-1.tgz
a/util-linux-2.12r-i486-6.tgz
a/which-2.16-i486-1.tgz
l/db42-4.2.52-i486-3.tgz
l/db44-4.4.20-i486-2.tgz
l/gdbm-1.8.3-i486-4.tgz
l/glib2-2.12.12-i486-1.tgz
l/glibc-2.5-i486-4.tgz
l/glibc-i18n-2.5-noarch-4.tgz
l/glibc-profile-2.5-i486-4.tgz
l/glib-1.2.10-i486-3.tgz
l/libtermcap-1.2.3-i486-7.tgz
l/mhash-0.9.9-i486-1.tgz
l/ncurses-5.6-i486-2.tgz
l/pcre-7.0-i486-1.tgz
l/readline-5.2-i486-2.tgz
l/zlib-1.2.3-i486-2.tgz
n/bind-9.4.1-i486-1.tgz
n/curl-7.16.2-i486-1.tgz
n/cyrus-sasl-2.1.22-i486-1.tgz
n/gnupg2-2.0.4-i486-1.tgz
n/gnupg-1.4.7-i486-1.tgz
n/gnutls-1.6.2-i486-1.tgz
n/iputils-s20070202-i486-2.tgz
n/libgcrypt-1.2.4-i486-1.tgz
n/libgpg-error-1.5-i486-1.tgz
n/netkit-ftp-0.17-i486-1.tgz
n/network-scripts-12.0-noarch-4.tgz
n/net-tools-1.60-i486-1.tgz
n/openldap-client-2.3.32-i486-1.tgz
n/openssh-4.6p1-i486-1.tgz
n/openssl-0.9.8e-i486-3.tgz
n/stunnel-4.17-i486-1.tgz
n/tcpdump-3.9.6-i486-1.tgz
n/tcp_wrappers-7.6-i486-1.tgz
n/telnet-0.17-i486-1.tgz
n/wget-1.10.2-i486-2.tgz
ap/bc-1.06.95-i486-1.tgz
ap/diffutils-2.8.1-i486-3.tgz
ap/groff-1.19.2-i486-1.tgz
ap/lsof-4.78-i486-1.tgz
ap/sudo-1.6.8p12-i486-1.tgz
ap/vim-7.1.012-i486-1.tgz
"
CPFILES="
/etc/resolv.conf
/etc/motd
/etc/issue
/etc/profile
/etc/localtime
"
if [ "$1" == "" ]; then
echo "Usage: $0 VserverName"
exit 1;
fi
echo "Create Vserver $VNAME"
if [ ! -x $VSDIR ]; then
mkdir $VSDIR
fi
vserver $VNAME build -m skeleton
if [ ! -e /etc/vservers/.defaults/apps/vshelper/disabled ]; then
mkdir /etc/vservers/.defaults/apps/vshelper/
touch "/etc/vservers/.defaults/apps/vshelper/disabled"
fi
setattr --~hide /proc/uptime
echo "Install packages for $VNAME"
for i in `echo $PKGS`
do
if [ ! -e $CDROM/$i ]; then
echo "$VSDIR/$VNAME $CDROM/$i not found"
exit 1;
fi
echo " $i"
installpkg -root $VSDIR/$VNAME $CDROM/$i > /dev/null;
done
echo "Install scripts"
echo "Create rc script"
cat <<EOF >> $VSDIR/$VNAME/etc/rc.d/rc
#!/bin/bash
if [ "\$1" == "3" ]; then
/etc/rc.d/rc.M
elif [ "\$1" == "6" ]; then
/etc/rc.d/rc.6
else
echo "Invalid level."
exit 1
fi
EOF
echo "Set access modes and mount points"
chmod 755 $VSDIR/$VNAME/etc/rc.d/rc
echo /dev/hdz1 / ext2 defaults 1 1 > $VSDIR/$VNAME/etc/fstab
echo /dev/hdz1 / ext2 rw 0 0 > $VSDIR/$VNAME/etc/mtab
chmod 644 $VSDIR/$VNAME/etc/rc.d/rc.inet1
echo $VNAME > $VSDIR/$VNAME/etc/HOSTNAME
echo "Copy files from root server"
for i in `echo $CPFILES`
do
cp -r $i $VSDIR/$VNAME/etc/
done
echo "Done."
и соответственно rc
#!/bin/sh
if [ "$1" == "3" ]; then
/etc/rc.d/rc.M
elif [ "$1" == "6" ]; then
/etc/rc.d/rc.6
else
echo "Invalid level."
exit 1
fi