Fileserver (Samba and DHCP)

#!/bin/bash
 
# set domU name
DOMAIN_NAME=srv
 
# install vm
xen-create-image --hostname=$DOMAIN_NAME --dhcp --mac=00:11:cc:ab:cd:ef \
--lvm=vg01 --dist=jaunty --mirror=http://archive.ubuntu.com/ubuntu/ --size=4Gb --memory=1Gb --swap=1Gb
 
# rename config file
mv /etc/xen/${DOMAIN_NAME}.cfg /etc/xen/${DOMAIN_NAME}
 
# add to autostart
ln -s /etc/xen/${DOMAIN_NAME} /etc/xen/auto
 
# create lvm for home
lvcreate --name ${DOMAIN_NAME}-media --size 200G vg01
mkfs.ext3 /dev/vg01/${DOMAIN_NAME}-media
 
# configure domU
vi /etc/xen/${DOMAIN_NAME}
(add)
'phy:/dev/vg01/srv-media,xvda3,w'
 
# start domain
xm create -c ${DOMAIN_NAME}
 
# set root password
passwd
 
# add media to fstab
cat <<EOF>> /etc/fstab
/dev/xvda3 /media ext3 defaults 0 0
EOF
 
# install and configure dhcp
apt-get install -y dhcp3-server
?? apt-get install winbind
cp /etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf.$(date -I)
cp /mnt/etc/dhcp3/dhcpd.conf /etc/dhcp3/dhcpd.conf
/etc/init.d/dhcp3-server restart
 
# install and configure samba
apt-get install -y samba
cp /etc/samba/smb.conf /etc/samba/smb.conf.$(date -I)
cp /mnt/smb.conf /etc/samba/smb.conf
/etc/init.d/samba restart
smbpasswd -a root
 
# install and configure pxe server
apt-get install -y tftpd-hpa syslinux openbsd-inetd
 
# move files to /media/tftpboot
mv /var/lib/tftpboot/ /var/lib/tftpboot.org
mkdir /media/tftpboot
ln -s /media/tftpboot/ /var/lib/tftpboot
/etc/init.d/openbsd-inetd restart
 
# install and configure new pxe envirement (optional)
apt-get install -y syslinux
cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/lib/syslinux/vesamenu.c32 /var/lib/tftpboot/
cp /usr/lib/syslinux/menu.c32 /var/lib/tftpboot/
cp /usr/lib/syslinux/memdisk /var/lib/tftpboot/
 
# nfs server
apt-get install -y nfs-kernel-server
cp /etc/exports /etc/exports.$(date -I)
cp /mnt/exports /etc/exports
/etc/init.d/nfs-kernel-server restart
 
# webserver
apt-get -y install apache2 php5
/etc/init.d/apache2 restart
mv /var/www /media/
ln -s /media/www/ /var/
 
# java
# install debconf-utils
apt-get install debconf-utils
 
# create answer file
debconf-set-selections <<\EOF
sun-java6-bin shared/accepted-sun-dlj-v1-1    boolean true
msttcorefonts   msttcorefonts/defoma    note
EOF
apt-get install -y sun-java6-jre
 
 
 
# Links
http://wiki.ubuntuusers.de/Samba_Server