This is a quick-and-dirty Slackware Vserver Howto as I haven't seen anything about vserver on slack. The advantage of this approach is that you can easily setup new vsevers and keep all of them up to date with the slackware packaging system, with just few commands. |
This is a quick-and-dirty Slackware Vserver Howto as I haven't seen anything about vserver on slack. The advantage of this approach is that you can easily setup new vsevers and keep all of them up to date with the slackware packaging system, with just a few commands. There is also a portuguese[1] version of this howto.
Note that this howto is a from scratch way to do the job, there's a tool called [simplepkg] that uses templates do create vservers and have some scripts to keep all the jails updated. |
Create a default skeleton for your vserver's config (skel.conf) and put it the the same dir of the scripts. |
Create a default skeleton for your vserver's config (skel.conf) and put it the the same dir of the scripts. You'll also need a tgz file with a small /dev folder containing the following devices/subfolders:
<code> crw-r -rw-r srw-rw-rw- 1 root root 0 2005-07-23 09:35 log crw-r crw-r drwxr-xr-x 2 root root 0 2005-07-22 18:28 pts crw-r crw-r crw-r crw-r </code> |
#
# mkjail: create vservers # feedback: rhatto at riseup.net ## adjust this to where your packages live PACKAGES=/slackware # this is where you put the rc's scripts SCRIPTS=/scripts # which disk sets you want to install SERIES="a ap l n" |
#
# mkjail v0.2: chroot jail maker (slack 10.1.0) # feedback: rhatto at riseup.net | GPL ## adjust this to where your things live PACKAGES="/storage/vserver/slack/" DEVICES="/storage/vserver/devices.tar.gz" SCRIPTS="/storage/vserver/etc/" GPGKEY="/storage/vserver/slack/GPG-KEY" SKEL="/storage/vserver/skel.conf" if ($# != 1)?; then echo "usage: $0 <server-name>" exit 1 fi |
if ($# != 1)?; then
echo "usage: $0 <server-name>" exit 1 fi server=$1 mkdir /vservers/$server |
server=$1
mkdir /vservers/$server |
echo "installing the packages" |
echo "instaling packages..." |
for dir in $SERIES; do
cd $dir; installpkg -root /vservers/$server *tgz; cd .. done |
for dir in a ap n extra contrib; do
cd $dir; installpkg -root /vservers/$server *tgz; cd .. done |
echo "copying initialization scripts"
cp $SCRIPTS/rc.* /vservers/$server/etc/rc.d/ |
echo "creating /etc/ and copying init scripts"
rsync -Cav $SCRIPTS/ /vservers/$server/etc/ |
echo "creating /etc/fstab /etc/mtab /etc/localtime /etc/profile" echo /dev/hdv1 / ext2 defaults 1 1 > /vservers/$server/etc/fstab echo /dev/hdv1 / ext2 rw 0 0 > /vservers/$server/etc/mtab |
cp $SCRIPTS/profile /vservers/$server/etc |
echo /dev/hdv1 / ext2 defaults 1 1 > /vservers/$server/etc/fstab
echo /dev/hdv1 / ext2 rw 0 0 > /vservers/$server/etc/mtab |
echo "creating dependency cache"
cd /vservers/$server/ tar xvf /storage/vserver/vserver-dev.tar ln -s lib/ld-2.3.2.so lib/ld-linux.so.2 chroot /vservers/$server/ sbin/ldconfig echo "creating config file" cp $SCRIPTS/skel.conf /etc/vservers/$server.conf |
echo "creating devices and dependencies"
cd /vservers/$server/ tar zxvf $DEVICES chroot /vservers/$server/ sbin/ldconfig echo "creating /etc/vservers/$server.conf" cp $SKEL /etc/vservers/$server.conf echo "importing slack gpg pubkey" mkdir /vservers/$server/root/.gnupg gpg |
# todo: add rebootmgr |
echo "then, route your server thru iptables and start it"
echo "dont forget to change your vserver's root passwd" |
echo "then, set iptables rules and start $server vserver"
echo "dont forget to change root's password" |
#!/bin/bash |
#!/bin/sh
#
# vserver-upgrade v0.2: fabulous script for slack vserver upgrade # feedback: rhatto at riseup.net | GPL ## Uses some functions from pkgtools, which license is: |
# vserver-upgrade |
# Copyright 1999 Patrick Volkerding, Moorhead, Minnesota, USA
# Copyright 2001, 2002, 2003 Slackware Linux, Inc., Concord, California, USA # All rights reserved. ## Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: ## 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. ## THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
# where your patches live
PATCHES=/slackware/patches/packages/ |
PACKAGE_DIR=/storage/packages/patches/ |
cd $PATCHES
for file in $(ls *tgz); do pack=$(echo $file | cut -d - -f 1) # this upgrades your main system if [ -f /var/log/packages/$pack* ]; then upgradepkg $pack*tgz |
# pkgtool stuff
package_name() { STRING=`basename $1 .tgz` # Check for old style package name with one segment: if [ "`echo $STRING | cut -f 1 -d -`" = "`echo $STRING | cut -f 2 -d -`" ]; then echo $STRING else # has more than one dash delimited segment # Count number of segments: INDEX=1 while [ ! "`echo $STRING | cut -f $INDEX -d -`" = "" ]; do INDEX=`expr $INDEX + 1` done INDEX=`expr $INDEX - 1` # don't include the null value # If we don't have four segments, return the old-style (or out of spec) package name: if [ "$INDEX" = "2" -o "$INDEX" = "3" ]; then echo $STRING else # we have four or more segments, so we'll consider this a new-style name: NAME=`expr $INDEX - 3` NAME="`echo $STRING | cut -f 1-$NAME -d -`" echo $NAME fi |
# this upgrades packages on every vserver running slackware
for vserver in $(ls /vservers); do if [ -f /vservers/$vserver/var/log/packages/$pack* ]; then ROOT=/vservers/$vserver upgradepkg $pack*tgz |
}
# vserver stuff cd $PACKAGE_DIR for file in `ls *tgz`; do pack=`package_name $file` for installed in `ls /var/log/packages/$pack* 2> /dev/null`; do if [[ "$pack" == "`package_name $installed.tgz`" ]]; then if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then upgradepkg $file fi |
for vserver in `ls /vservers`; do
for installed in `ls /vservers/$vserver/var/log/packages/$pack* 2> /dev/null`; do if [[ $pack == `package_name $installed.tgz` ]]; then if [[ "`basename $installed`" != "`basename $file .tgz`" ]]; then ROOT=/vservers/$vserver upgradepkg $file fi fi done done |
=== Config format ===
If you're using the new configuration method for your vservers and want to use the sysv init style, you should create the following /etc/rc.d/rc script inside your vserver: <code> #!/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 </code> === Passive FTP === |
*Any questions/comments: rhatto at riseup.net |
=== Contact ===
Any questions/comments: rhatto at riseup.net |