DSmanager templates

From ISPWiki

Jump to: navigation, search

Contents

RecoveryMode templates

FreeBSD

If you run FreeBSD 7, boot via NFS is supported in GENERIC.

Compile PXE to work with TFTP

Take from /boot/pxeboot

The loader can be compiled in any place, because it is not related to a FreeBSD version.

  1. cd /usr/src/sys/boot
  2. make clean depend
  3. make -DLOADER_TFTP_SUPPORT=yes
  4. locate the result in i386/pxeldr/

Create a template to boot via pxe

  • Through sysinstall install into a separate FreeBSd directory (base and kernel).
  • Delete the files /boot/GENERIC/*.symbols.
  • In /boot/loader.conf specify
kernel="GENERIC"
autoboot_delay="1"
  • In /etc/ssh/sshd_config specify
PermitRootLogin yes
PasswordAuthentication yes
  • Create empty /etc/fstab.
  • Create the /DS/mnt directory .
  • Upload /etc/rc.local (a script for remote OS installation). In case of the recovery mode it will be removed.
  • Upload /Clone.sh (a script for creation of temporary copies). It is used in the recovery mode.
  • Copy /boot/pxeboot into /pxe

That is all. Perform the following steps to disable additional functionality to prevent possible errors.

  • In /etc/ttys remove all the non-networked consoles (leave Pseudo terminals only).
  • In /etc/rc.conf specify
sendmail_enable="NONE"
sendmail_submit_enable="NO"
cron_enable="NO"
syslogd_enable="NO"

Execute:

#!/bin/sh

FOLDER=${1:-FreeBSD}
if [ -d $FOLDER ]; then
 echo "Some data already exists in this ($FOLDER) folder"
 exit 1
fi

mkdir $FOLDER
/usr/sbin/sysinstall
rm $FOLDER/boot/GENERIC/*.symbols
grep nameserver /etc/resolv.conf > $FOLDER/etc/resolv.conf
echo "emptyserverpassword" | pw -V $FOLDER/etc usermod root -h0
echo 'kernel="GENERIC"' > $FOLDER/boot/loader.conf
echo 'autoboot_delay="1"' >> $FOLDER/boot/loader.conf
echo 'PermitRootLogin yes' >> $FOLDER/etc/ssh/sshd_config
echo 'PasswordAuthentication yes' >> $FOLDER/etc/ssh/sshd_config
echo 'sendmail_enable="NONE"' > $FOLDER/etc/rc.conf
echo 'sendmail_submit_enable="NO"' >> $FOLDER/etc/rc.conf
echo 'cron_enable="NO"' >> $FOLDER/etc/rc.conf
echo 'syslogd_enable="NO"' >> $FOLDER/etc/rc.conf

touch $FOLDER/etc/fstab
grep network $FOLDER/etc/ttys > /tmp/ttys
cat /tmp/ttys > $FOLDER/etc/ttys

Copy this template for RecoveryMode

  • Enable SSH access in /etc/rc.conf
sshd_enable="YES"
  • Delete unnecessary files
rm -rf /tmp/*
rm -rf /var/log/*
rm -f /var/run/*
rm /root/.bash_history

Execute:

#!/bin/sh

TO=${1:-Error}
FROM=${2:-FreeBSD}
if [ $TO = "Error" ]; then
 echo "You must specify folder where your new linux root will be created"
 exit 1
fi
if [ -d $TO ]; then
 echo "Some data already exists in this ($TO) folder"
 exit 1
fi
if [ ! -d $FROM ]; then
 echo "Folder with source data ($FROM) not found"
 exit 1
fi

mkdir $TO
tar -c -f- -C $FROM . | tar -x -f- -p -C $TO
echo 'sshd_enable="YES"' >> $TO/etc/rc.conf
rm -f $TO/var/log/*
rm -f $TO/var/run/*
rm -f $TO/tmp/*

# these files should not be present.
# Unlike Linux, you do not need to boot with the FreeBSD template.
rm -f $TO/etc/ssh/ssh_host_*
rm -f $TO/root/.bash_history

Linux

Create a template to boot via pxe

rpm -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/expat-1.95.8-8.2.1.i386.rpm
rpm -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/python-elementtree-1.2.6-5.i386.rpm
rpm -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
rpm -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/python-sqlite-1.1.7-1.2.1.i386.rpm
rpm --nodeps -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/rpm-python-4.4.2-48.el5.i386.rpm
rpm -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/m2crypto-0.16-6.el5.2.i386.rpm
rpm -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/python-urlgrabber-3.1.0-2.noarch.rpm
rpm -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/libxml2-2.6.26-2.1.2.1.i386.rpm
rpm -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-2.el5.i386.rpm
rpm -ivh http://ftp.belnet.be/packages/centos/5/os/i386/CentOS/yum-3.2.8-9.el5.centos.1.noarch.rpm
  • Installnfs-utils
yum install nfs-utils
  • Create the file /etc/sysconfig/network (otherwise portmap won't work causing the nfs client to fail)
  • Installwget
yum install wget
  • Install grub
yum install grub
  • Enable the server
  • Disable the services you do not need
rm -f S18rpcidmapd S19rpcgssd K69rpcsvcgssd S08iptables K20nfs S14nfslock
# Disable ssh, because it is not required for the OS installation
# In RecoveryMode enable it
rm -f S55sshd
rm -f /etc/ssh/ssh_host_*
  • Then
rm $FOLDER/root/.bash_history $FOLDER/root/.bash_logout

Execute: (this script should be executed twice)

#!/bin/sh

FOLDER=${1:-Linux}
DISTR=${2:-centos-5-i386-minimal.tar.gz}
if [ ! -d $FOLDER ]; then
 if [ ! -f $DISTR ]; then
   echo "Distribution $DISTR not found"
   exit 1
 fi
 mkdir $FOLDER
 tar xfz $DISTR -C $FOLDER
 grep nameserver /etc/resolv.conf > $FOLDER/etc/resolv.conf
 grep -v '^root:' $FOLDER/etc/shadow > /tmp/shadow

 echo 'root:$1$awFD3$voBR8.XDYTONh61S7PvZC.:14012:0:99999:7:::' > $FOLDER/etc/shadow
 cat /tmp/shadow >> $FOLDER/etc/shadow
 rm /tmp/shadow
 mknod $FOLDER/dev/console c 5 1
 chmod 600 $FOLDER/dev/console
 mknod $FOLDER/dev/urandom c 1 9
 chmod 444 $FOLDER/dev/urandom
 touch $FOLDER/etc/sysconfig/network

 echo "install yum, nfs-utils, grub and wget !!!"
 echo
 echo "Start some server with this new image. Login to it with password: emptyserverpassword"

 exit 0
else
 rm -f $FOLDER/etc/rc3.d/S18rpcidmapd
 rm -f $FOLDER/etc/rc3.d/S19rpcgssd
 rm -f $FOLDER/etc/rc3.d/K69rpcsvcgssd
 rm -f $FOLDER/etc/rc3.d/S08iptables
 rm -f $FOLDER/etc/rc3.d/K20nfs
 rm -f $FOLDER/etc/rc3.d/S14nfslock
 rm -f $FOLDER/etc/rc3.d/S55sshd
 echo "SSH access disabled"
 rm -f $FOLDER/root/.bash_history $FOLDER/root/.bash_logout
 rm -f $FOLDER/etc/ssh/ssh_host_*
fi

Copy this template for RecoveryMode

#!/bin/sh

TO=${1:-Error}
FROM=${2:-Linux}
if [ $TO = "Error" ]; then
 echo "You must specify folder where your new linux root will be created"
 exit 1
fi
if [ -d $TO ]; then
 echo "Some data already exists in this ($TO) folder"
 exit 1
fi
if [ ! -d $FROM ]; then
 echo "Folder with source data ($FROM) not found"
 exit 1
fi

mkdir $TO
tar -c -f- -C $FROM . | tar -x -f- -p -C $TO
touch $TO/fastboot
rm -f $TO/var/lib/random-seed
rm -f $TO/var/empty/sshd/etc/localtime
rm -f $TO/etc/ssh/ssh_host_*
rm -f $TO/root/.bash_history
rm -f $TO/var/run/utmp
rm -f $TO/var/log/*
ln -s ../init.d/sshd $TO/etc/rc3.d/S55sshd
Was this helpful? Yes | No
Views
Personal tools