Appendix: Duplicate a Server
The objective of this page is to create a server that is a duplicate of the original server.
Setting up packages
export yumver=5.6
export arch=-i386
export arch=-x86_64
export site=192.168.20.254
rpm --import http://$site/mrepo/centos$yumver$arch/disc1/RPM-GPG-KEY-CentOS-5
rpm --import http://$site/mrepo/centos$yumver$arch/disc1/RPM-GPG-KEY-beta
rpm --import http://$site/mrepo/kickstart/RPM-GPG-KEY.dag.txt
mkdir /etc/yum.repos.d/archive
mv /etc/yum.repos.d/C* /etc/yum.repos.d/archive/
rm -fr /etc/yum.repos.d/CentOS-ai.repo
/bin/cat << EOF >> /etc/yum.repos.d/CentOS-ai.repo
[dag]
name=Inhouse Access Dag repository
baseurl=http://$site/mrepo/centos$yumver$arch/RPMS.dag
[extras]
name=Inhouse Access Extra repository
baseurl=http://$site/mrepo/centos$yumver$arch/RPMS.extras
#[local]
#name=Inhouse Access Local repository
#baseurl=http://$site/mrepo/centos$yumver$arch/RPMS.local
#[contrib]
#name=Inhouse Access OS repository
#baseurl=http://$site/mrepo/centos$yumver$arch/RPMS.contrib
[os]
name=Inhouse Access OS repository
baseurl=http://$site/mrepo/centos$yumver$arch/RPMS.os
[updates]
name=Inhouse Access Updatesrepository
baseurl=http://$site/mrepo/centos$yumver$arch/RPMS.updates
EOFyum -y upgrade
#Install what you want, this is just a list.yum -y install iputils libcap tcpdump lynx dhcp libjpeg gettext \
ncompress m4 authconfig automake dev86 bison byacc cdecl cpp cproto ctags \
glibc-kernheaders glibc-devel ElectricFence flex gdb make patch binutils gcc \
libdbi htmlview dovecot libdbi-dbd-mysql MyODBC \
mysql mysql-server mysqlclient10 mysqlclient10-devel mysql-bench \
openldap cups cups-libs cups-devel openldap-server krb5-workstation mc \
clamav clamd clamav-milter emacs shadow-utils cacti net-snmp-utils net-snmp \
php-imap php-domxml php php-ldap php-mysql php-imap php-odbc php-gd php-xml php-xmlrpc \
perl-Digest-SHA1 perl-Net-DNS perl-Time-HiRes perl-Digest-HMAC perl-DBI perl-DBD-MySQL mysql-devel \
perl-Convert-ASN1 perl-XML-SAX perl-LDAP perl-Crypt-SSLeay perl-XML-NamespaceSupport \
perl-HTML-Tagset perl-HTML-Parser perl-Convert-BER perl-Mon perl-Net-SSLeay
Areas that need to be replicated
- /home
- /etc (Various configuration files)
- /var/named
- /var/lib/mysql
- /var/spool/mail
- /var/www
Replicating configurations
- DNS (resolv.conf)
- HTTP
- DHCP
- SNMP
- Rsync
- NTP
- Hosts
- Dovecot (
- Samba
- sarg
- horde
export ARCHIVE=/home/rsync/fstn
cp $ARCHIVE/etc/resolv.conf /etc
mkdir -p /var/named/chroot/var/named
cp $ARCHIVE/var/named /var/named
cp -r $ARCHIVE/var/www /var/www
cp $ARCHIVE/etc/dhcpd.conf /etc
touch /var/lib/dhcpd/dhcpd.leases
/bin/rm /etc/sysconfig/dhcpd
echo "# Command line options here">>/etc/sysconfig/dhcpd
echo "DHCPDARGS=eth0">>/etc/sysconfig/dhcpd
chmod 700 /etc/rc.d/init.d/dhcpd
chown 0.0 /etc/rc.d/init.d/dhcpd
/sbin/chkconfig --add dhcpd
/sbin/chkconfig --level 345 dhcpd on
cp -f $ARCHIVE/etc/snmp/snmpd.conf /etc/snmp
/sbin/chkconfig --add snmpd
/sbin/chkconfig --level 345 snmpd on
cp $ARCHIVE/etc/ntp.conf /etc
cp $ARCHIVE/etc/ntp/step-tickers
/sbin/chkconfig --add ntpd
/sbin/chkconfig --level 345 ntpd on
cp $ARCHIVE/etc/hosts /etc
cp $ARCHIVE/etc/hosts.allow /etc
cp $ARCHIVE/etc/hosts.deny /etc
cp $ARCHIVE/etc/host.conf /etc
emacs /etc/dovecot.conf
#USERS
rm -fr /home/grep-exclude
/bin/cat << EOF >> /home/grep-exclude
x:5:
x:50:
x:51:
x:52:
x:53:
x:54:
x:55:
x:56:
x:57:
x:58:
x:59:
EOF
cat $ARCHIVE/etc/passwd|grep x:5|grep -v --file=/home/grep-exclude>>/etc/passwd
cat $ARCHIVE/etc/group|grep x:5|grep -v --file=/home/grep-exclude>>/etc/group
cat $ARCHIVE/etc/shadow|grep -v ":\!\!:">>/etc/shadow
vi /etc/passwd
vi /etc/group
vi /etc/shadow
# If you have users in in the 600, 700 range, just change the /home/grep-exlcude to reflect this.
cp $ARCHIVE/etc/samba/smb.conf /etc/samba
cp $ARCHIVE/etc/samba/smbpasswd /etc/samba