HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

General support questions
lleb
Posts: 14
Joined: 2012/03/18 14:53:14

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by lleb » 2012/03/21 17:55:37

[Moderator edit: Delete gratuitous quote of entire previous message.]

Thank you for both the link and for the luck. I think Ill be needing some. I know I will post with more questions.

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by pschaff » 2012/03/21 18:25:26

You are welcome. Please ask if you encounter difficulties, or let us know if you succeed.

lleb
Posts: 14
Joined: 2012/03/18 14:53:14

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by lleb » 2012/03/21 21:56:03

ok making some progress, but Ive hit a bit of a road block.

[code][root@rx30 ~]# LANG=C livecd-creator --config=/root/CentOS_6.2/sata-2.cfg --fslabel=CentOS_6.2-liveDVD
mke2fs 1.41.12 (17-May-2010)
Filesystem label=_CentOS_6.2-live
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
192000 inodes, 768000 blocks
7680 blocks (1.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=788529152
24 block groups
32768 blocks per group, 32768 fragments per group
8000 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912

Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 36 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
tune2fs 1.41.12 (17-May-2010)
Setting maximal mount count to -1
Setting interval between checks to 0 seconds
Retrieving http://mirror.centos.org/centos/5/os/i386/repodata/repomd.xml ...OK
Retrieving http://mirror.centos.org/centos/5/os/i386/repodata/primary.xml.gz ...OK
Retrieving http://www.nanotechnologies.qc.ca/propos/linux/centos-live/i386/live/repodata/repomd.xml ...OK
Retrieving http://www.nanotechnologies.qc.ca/propos/linux/centos-live/i386/live/repodata/primary.xml.gz ...OK
Retrieving http://mirror.centos.org/centos/5/updates/i386/repodata/repomd.xml ...OK
Retrieving http://mirror.centos.org/centos/5/updates/i386/repodata/primary.sqlite.bz2 ...OK
/usr/lib/python2.6/site-packages/imgcreate/errors.py:45: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
return unicode(self.message)
[b]Error creating Live CD : Failed to find package 'yum-plugin-security' : No package(s) available to install[/b]
[/code]




[code][root@rx30 ~]# cat CentOS_6.2/sata-2.cfg

firewall --disabled
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Network information
network --bootproto=dhcp --device=eth0 --nameserver=8.8.8.8 --onboot=on
# System authorization information
auth --useshadow --passalgo=md5
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# adding repos

repo --name=a-base --baseurl=http://mirror.centos.org/centos/5/os/$basearch
repo --name=a-updates --baseurl=http://mirror.centos.org/centos/5/updates/$basearch
repo --name=a-live --baseurl=http://www.nanotechnologies.qc.ca/propos/linux/centos-live/$basearch/live

# Installation logging level
logging --level=info
#Root password
rootpw --iscrypted $1$tX3SYG9H$X/RENO4wHFcFCZri8t02F/
# X Window System configuration information
xconfig --defaultdesktop=KDE
# Reboot after installation
#reboot
reboot --eject
# System timezone
timezone America/New_York
# System bootloader configuration
bootloader --location=mbr append vga=791
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --ondisk sda --fstype="ext3" --size=100
part / --ondisk sda --fstype="ext3" --grow --size=3000
part /usr/rx30 --ondisk sda --fstype="ext3" --grow --size=3000 --asprimary
part swap --ondisk sda --fstype="swap" --recommended

%packages
syslinux
kernel
@additional-devel
@backup-client
@base
@cifs-file-server
@compat-libraries
@console-internet
@debugging
@desktop-debugging
@development
@dial-up
@fonts
@ftp-server
@graphical-admin-tools
@graphics
@hardware-monitoring
@internet-applications
@internet-browser
@java-platform
@kde-desktop
@legacy-unix
@legacy-x
@mail-server
@mainframe-access
@mysql
@mysql-client
@network-file-system-client
@network-server
@network-tools
@nfs-file-server
@office-suite
@performance
@perl-runtime
@print-client
@print-server
@remote-desktop-clients
@server-platform
@system-admin-tools
@system-management
@web-server
@x11
@rx30-cfg
@rx30-chat
AdobeReader_enu
arptables_jf
arpwatch
bitmap-console-fonts
bitmap-fixed-fonts
bitmap-lucida-typewriter-fonts
bitmap-miscfixed-fonts
cmake
compat-gcc-34
compat-gcc-34-c++
compat-gcc-34-g77
dos2unix
dropwatch
dump
efax
ftp
gcc-objc
gcc-objc++
ghostscript-gtk
glibc-static
google-chrome
iptraf
iptstate
krb5-appl-servers
lftp
libXmu
lsscsi
m17n-db-generic
mc
memtest86+
mgetty
mgetty-sendfax
mgetty-viewfax
mtr-gtk
mutt
mysql-bench
mysql-test
ncompress
ncurses-static
openmotif
openmotif22
perl-TimeDate
perl-Bit-Vector

# other usefull packages
Cluster_Administration-en-US
Deployment_Guide-en-US
Global_File_System-en-US
Virtualization-en-US
busybox
mailx
patch
yum-fastestmirror
yum-metadata-parser
# end other usefull packages

perl-Carp-Clan
perl-Date-Calc
perl-DateManip
perl-libwww-perl
perl-Compress-Zlib
perl-HTML-Parser
perl-HTML-Tagset
perl-URI
perl-DBD-MySQL
postfix
pptp
python
rdesktop
rdist
rsh
rsyslog-gnutls
rsyslog-gnutls
rsyslog-gssapi
rsyslog-gssapi
rsyslog-mysql
rusers
screen
sg3_utils
swatch
symlinks
syslinux
system-config-lvm
tcp_wrappers
telnet
telnet-server
tftp
thunderbird
tree
tuned
udftools
unix2dos
uuidd
wireshark
xorg-x11-fonts-ethiopic
xorg-x11-fonts-75dpi
xorg-x11-fonts-ISO8859-1-75dpi
xorg-x11-fonts-ISO8859-14-100dpi
xorg-x11-fonts-ISO8859-14-75dpi
xorg-x11-fonts-ISO8859-15-75dpi
xorg-x11-fonts-ISO8859-2-100dpi
xorg-x11-fonts-ISO8859-2-75dpi
xorg-x11-fonts-ISO8859-9-100dpi
xorg-x11-fonts-ISO8859-9-75dpi
xorg-x11-twm
xorg-x11-xdm
xterm
yum-plugin-protect-packages
yum-plugin-security
libFS
xorg-x11-xfs

%post --nochroot

mkdir -p /mnt/source;mount -t iso9660 /tmp/cdrom /mnt/source
tar -xzvf /mnt/source/post/rx30sysfiles.tgz -C /mnt/sysimage/
#tar -xvzf /mnt/source/post/ltsp.tgz -C /mnt/sysimage/opt
mkdir /mnt/sysimage/tftpboot
tar -xvzf /mnt/source/post/tftpboot.tgz -C /mnt/sysimage/tftpboot
mkdir /mnt/sysimage/usr/rx30/.kde
mkdir /mnt/sysimage/usr/rx30/.kde/share
mkdir /mnt/sysimage/usr/rx30/.kde/share/config
mkdir /mnt/sysimage/usr/rx30/llinstl
mkdir /mnt/sysimage/usr/rx30/llinstl/bak

tar -xvzf /mnt/source/post/kdeshareconfig.tgz -C /mnt/sysimage/usr/rx30/.kde/share/config
cp /mnt/source/changelog /mnt/sysimage/root

########################################################################
# Create a sub-script so the output can be captured
# Must change "$" to "\$" and "`" to "\`" to avoid shell quoting
########################################################################
cat > /root/postnochroot-install << EOF_postnochroot
#!/bin/bash

# add livecd-iso-to-disk utility on the LiveCD
# only works on x86, x86_64
if [ "\$(uname -i)" = "i386" -o "\$(uname -i)" = "x86_64" ]; then
if [ ! -d \$LIVE_ROOT/LiveOS ]; then mkdir -p \$LIVE_ROOT/LiveOS ; fi
cp /usr/bin/livecd-iso-to-disk \$LIVE_ROOT/LiveOS
fi

# customize boot menu entries
grep -A4 'label linux0' \$LIVE_ROOT/isolinux/isolinux.cfg > \$LIVE_ROOT/isolinux/default.txt
grep -A2 'label memtest' \$LIVE_ROOT/isolinux/isolinux.cfg > \$LIVE_ROOT/isolinux/memtest.txt
grep -A2 'label local' \$LIVE_ROOT/isolinux/isolinux.cfg > \$LIVE_ROOT/isolinux/localboot.txt

sed "s/label linux0/label linuxtext0/" \$LIVE_ROOT/isolinux/default.txt > \$LIVE_ROOT/isolinux/textmode.txt
sed -i "s/Boot/Boot (text mode)/" \$LIVE_ROOT/isolinux/textmode.txt
sed -i "s/liveimg/liveimg 3/" \$LIVE_ROOT/isolinux/textmode.txt
sed -i "/menu default/d" \$LIVE_ROOT/isolinux/textmode.txt

touch \$LIVE_ROOT/isolinux/installer.txt
if [ -e \$INSTALL_ROOT/boot/livecd-installer.img -a -e \$INSTALL_ROOT/boot/vmlinuz-installer* ]; then
mv \$INSTALL_ROOT/boot/livecd-installer.img \$LIVE_ROOT/isolinux/install.img
mv \$INSTALL_ROOT/boot/vmlinuz-installer* \$LIVE_ROOT/isolinux/vminst
cat > \$LIVE_ROOT/isolinux/installer.txt << EOF_installer
label installer
menu label Network Installation
kernel vminst
append initrd=install.img text
EOF_installer
fi

cat \$LIVE_ROOT/isolinux/default.txt \$LIVE_ROOT/isolinux/memtest.txt \$LIVE_ROOT/isolinux/localboot.txt > \
\$LIVE_ROOT/isolinux/current.txt
diff \$LIVE_ROOT/isolinux/isolinux.cfg \$LIVE_ROOT/isolinux/current.txt | sed '/^[0-9][0-9]*/d; s/^. //; /^---$/d' > \
\$LIVE_ROOT/isolinux/cleaned.txt
cat \$LIVE_ROOT/isolinux/cleaned.txt \$LIVE_ROOT/isolinux/default.txt \$LIVE_ROOT/isolinux/textmode.txt \
\$LIVE_ROOT/isolinux/installer.txt \$LIVE_ROOT/isolinux/memtest.txt \$LIVE_ROOT/isolinux/localboot.txt > \
\$LIVE_ROOT/isolinux/isolinux.cfg
rm -f \$LIVE_ROOT/isolinux/*.txt

EOF_postnochroot

/bin/bash -x /root/postnochroot-install 2>&1 | tee /root/postnochroot-install.log




%post

## LiveCD version for the link toward the release notes
VERSION="6.2"
## locales for the Live CD
PRIMARY_LANGUAGE="en"
PRIMARY_LOCALE="en_US"

## default LiveCD user
LIVECD_USER="rx30"

########################################################################
# Create a sub-script so the output can be captured
# Must change "$" to "\$" and "`" to "\`" to avoid shell quoting
########################################################################
cat > /root/post-install << EOF_post
#!/bin/bash

echo ###################################################################
echo ## Creating the livesys init script
echo ###################################################################

cat > /etc/rc.d/init.d/livesys << EOF_initscript
#!/bin/bash
#
# live: Init script for live image
#
# chkconfig: 345 00 99
# description: Init script for live image.

. /etc/init.d/functions

if ! strstr "\\\`cat /proc/cmdline\\\`" liveimg || [ "\\\$1" != "start" ] || [ -e /.liveimg-configured ] ; then
exit 0
fi

exists() {
which \\\$1 >/dev/null 2>&1 || return
\\\$*
}

# read some variables out of /proc/cmdline
for o in \\\`cat /proc/cmdline\\\` ; do
case \\\$o in
xdriver=*)
xdriver="--set-driver=\\\${o#xdriver=}"
;;
esac
done

touch /.liveimg-configured

# mount live image
if [ -b /dev/live ]; then
mkdir -p /mnt/live
mount -o ro /dev/live /mnt/live
fi

# enable swaps unless requested otherwise
swaps=\\\`blkid -t TYPE=swap -o device\\\`
if ! strstr "\\\`cat /proc/cmdline\\\`" noswap -a [ -n "\\\$swaps" ] ; then
for s in \\\$swaps ; do
action "Enabling swap partition \\\$s" swapon \\\$s
done
fi

## fix various bugs and issues
# configure X, allowing user to override xdriver
exists system-config-display --noui --reconfig --set-depth=24 \\\$xdriver

# turn off firstboot for livecd boots
echo "RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot

# create a patch for kudzu init script
cat > /tmp/kudzu.patch << EOF_kudzupatch
--- kudzu.orig 2007-07-27 20:27:03.000000000 -0400
+++ kudzu 2007-07-27 20:27:23.000000000 -0400
@@ -35,6 +35,10 @@
action "" /bin/false
fi

+ # Reconfigure the keyboard
+ . /etc/sysconfig/keyboard
+ /usr/bin/system-config-keyboard \\\\\\\$KEYTABLE 2&> /dev/null
+
# We don't want to run this on random runlevel changes.
touch /var/lock/subsys/kudzu
# However, if they did configure X and want runlevel 5, let's
EOF_kudzupatch

# patch kudzu init script
/usr/bin/patch /etc/rc.d/init.d/kudzu /tmp/kudzu.patch > /dev/null
rm -f /tmp/kudzu.patch

# stopgap fix for RH #217966; should be fixed in HAL instead
touch /media/.hal-mtab

# workaround clock syncing on shutdown that we don't want (RH #297421)
sed -i -e 's/hwclock/no-such-hwclock/g' /etc/rc.d/init.d/halt

# workaround avahi segfault (RH #273301)
touch /etc/resolv.conf
/sbin/restorecon /etc/resolv.conf

# set the LiveCD hostname
sed -i -e 's/HOSTNAME=localhost.localdomain/HOSTNAME=livecd.localdomain/g' /etc/sysconfig/network
/bin/hostname livecd.localdomain

## create the LiveCD default user
# add default user with no password
/usr/sbin/useradd -c "LiveCD default user" $LIVECD_USER
/usr/bin/passwd -d $LIVECD_USER > /dev/null
# give default user sudo privileges
echo "$LIVECD_USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

# disable screensaver locking
gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool \
/apps/gnome-screensaver/lock_enabled false >/dev/null

# add documentation shortcuts
mkdir -p /home/$LIVECD_USER/Desktop/Documentation
cp /usr/share/applications/Cluster_Administration-en-US.desktop /home/$LIVECD_USER/Desktop/Documentation/
cp /usr/share/applications/Deployment_Guide-en-US.desktop /home/$LIVECD_USER/Desktop/Documentation/
cp /usr/share/applications/Global_File_System-en-US.desktop /home/$LIVECD_USER/Desktop/Documentation/
cp /usr/share/applications/Virtualization-en-US.desktop /home/$LIVECD_USER/Desktop/Documentation/
cat > /home/$LIVECD_USER/Desktop/Documentation/Additional_Documentation.desktop << EOF_documentation
[Desktop Entry]
Name=Additional Documentation
Comment=Enterprise Linux
Exec=firefox http://www.centos.org/docs/5/
Icon=/usr/share/pixmaps/redhat-web-browser.png
Categories=Documentation;
Type=Application
Encoding=UTF-8
Terminal=false
EOF_documentation
cat > /home/$LIVECD_USER/Desktop/Documentation/Release_Notes.desktop << EOF_release_notes
[Desktop Entry]
Name=How To Install
Comment=Enterprise Linux
Exec=firefox http://wiki.centos.org/Manuals/ReleaseNotes/CentOSLiveCD$VERSION
Icon=/usr/share/pixmaps/redhat-web-browser.png
Categories=Documentation;
Type=Application
Encoding=UTF-8
Terminal=false
EOF_release_notes

CreateDesktopIconHD()
{
cat > /home/$LIVECD_USER/Desktop/Local\ hard\ drives.desktop << EOF_HDicon
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Link
Name=Local hard drives
Name[en_US]=Local hard drives
Name[fr_CA]=Disques durs locaux
URL=/mnt/disc
Icon=/usr/share/icons/Bluecurve/48x48/devices/gnome-dev-harddisk.png
EOF_HDicon

chmod 755 /home/$LIVECD_USER/Desktop/Local\ hard\ drives.desktop
}

CreateDesktopIconLVM()
{
cat > /home/$LIVECD_USER/Desktop/Local\ logical\ volumes.desktop << EOF_LVMicon
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Link
Name=Local logical volumes
Name[en_US]=Local logical volumes
Name[fr_CA]=Volumes logiques locaux
URL=/mnt/lvm
Icon=/usr/share/icons/Bluecurve/48x48/devices/gnome-dev-harddisk.png
EOF_LVMicon

chmod 755 /home/$LIVECD_USER/Desktop/Local\ logical\ volumes.desktop
}

# don't mount disk partitions if 'nodiskmount' is given as a boot option
if ! strstr "\\\`cat /proc/cmdline\\\`" nodiskmount ; then
MOUNTOPTION="ro"
HARD_DISKS=\\\`egrep "[sh]d.\\\$" /proc/partitions | tr -s ' ' | sed 's/^ *//' | cut -d' ' -f4\\\`

echo "Mounting hard disk partitions... "
for DISK in \\\$HARD_DISKS; do
# Get the device and system info from fdisk (but only for fat and linux partitions).
FDISK_INFO=\\\`fdisk -l /dev/\\\$DISK | tr [A-Z] [a-z] | egrep "fat|linux" | egrep -v "swap|extended|lvm" | \
sed 's/*//' | tr -s ' ' | tr ' ' ':' | cut -d':' -f1,6-\\\`
for FDISK_ENTRY in \\\$FDISK_INFO; do
PARTITION=\\\`echo \\\$FDISK_ENTRY | cut -d':' -f1\\\`
MOUNTPOINT="/mnt/disc/\\\${PARTITION##/dev/}"
mkdir -p \\\$MOUNTPOINT
MOUNTED=FALSE

# get the partition type
case \\\`echo \\\$FDISK_ENTRY | cut -d':' -f2-\\\` in
*fat*)
FSTYPES="vfat"
EXTRAOPTIONS=",uid=500";;
*)
FSTYPES="ext4 ext3 ext2"
EXTRAOPTIONS="";;
esac

# try to mount the partition
for FSTYPE in \\\$FSTYPES; do
if mount -o "\\\${MOUNTOPTION}\\\${EXTRAOPTIONS}" -t \\\$FSTYPE \\\$PARTITION \\\$MOUNTPOINT &>/dev/null; then
echo "\\\$PARTITION \\\$MOUNTPOINT \\\$FSTYPE noauto,\\\${MOUNTOPTION}\\\${EXTRAOPTIONS} 0 0" >> /etc/fstab
echo -n "\\\$PARTITION "
MOUNTED=TRUE
CreateDesktopIconHD
fi
done
[ \\\$MOUNTED = "FALSE" ] && rmdir \\\$MOUNTPOINT
done
done
echo


FSTYPES="ext4 ext3 ext2"

echo "Scanning for logical volumes..."
if ! lvm vgscan 2>&1 | grep "No volume groups"; then
echo "Activating logical volumes ..."
modprobe dm_mod >/dev/null
echo "mkdmnod" | nash --quiet
lvm vgchange -ay
LOGICAL_VOLUMES=\\\`lvm lvdisplay -c | sed "s/^ *//" | cut -d: -f1\\\`
if [ ! -z "\\\$LOGICAL_VOLUMES" ]; then
echo "Making device nodes ..."
lvm vgmknodes
echo -n "Mounting logical volumes ... "
for VOLUME_NAME in \\\$LOGICAL_VOLUMES; do
VG_NAME=\\\`echo \\\$VOLUME_NAME | cut -d/ -f3\\\`
LV_NAME=\\\`echo \\\$VOLUME_NAME | cut -d/ -f4\\\`
MOUNTPOINT="/mnt/lvm/\\\${VG_NAME}-\\\${LV_NAME}"
mkdir -p \\\$MOUNTPOINT

MOUNTED=FALSE
for FSTYPE in \\\$FSTYPES; do
if mount -o \\\$MOUNTOPTION -t \\\$FSTYPE \\\$VOLUME_NAME \\\$MOUNTPOINT &>/dev/null; then
echo "\\\$VOLUME_NAME \\\$MOUNTPOINT \\\$FSTYPE defaults,\\\${MOUNTOPTION} 0 0" >> /etc/fstab
echo -n "\\\$VOLUME_NAME "
MOUNTED=TRUE
CreateDesktopIconLVM
break
fi
done
[ \\\$MOUNTED = FALSE ] && rmdir \\\$MOUNTPOINT
done
echo

else
echo "No logical volumes found"
fi
fi
fi

# give back ownership to the default user
chown -R $LIVECD_USER:$LIVECD_USER /home/$LIVECD_USER
EOF_initscript

chmod 755 /etc/rc.d/init.d/livesys
/sbin/restorecon /etc/rc.d/init.d/livesys
/sbin/chkconfig --add livesys

echo ###################################################################
echo ## Trim down the LiveCD to save some space
echo ###################################################################
# remove unneeded initrd file(s)
rm -f /boot/initrd*
# temporary RPM databases can be removed
rm -f /usr/var/lib/rpm/__db.00*
# make sure there aren't core files lying around
rm -f /core*

# remove files for unsupported languages in various applications
(cd /var/lib/scrollkeeper; \
if [ \`ls | wc -w\` -gt 11 ]; then \
mkdir ../temp_dir; \
mv C $PRIMARY_LANGUAGE $SECONDARY_LANGUAGE index scrollkeeper_docs TOC ../temp_dir; \
rm -rf *; mv ../temp_dir/* .; rmdir ../temp_dir; \
sync; \
fi)
(cd /usr/lib/locale; \
if [ \`ls | wc -w\` -gt 8 ]; then \
mkdir ../temp_dir; \
mv $PRIMARY_LOCALE* $SECONDARY_LOCALE* ../temp_dir; \
rm -rf *; mv ../temp_dir/* .; rmdir ../temp_dir; \
/usr/sbin/build-locale-archive; \
sync; \
fi)
(cd /usr/share/locale; \
if [ \`ls | wc -w\` -gt 10 ]; then \
mkdir ../temp_dir; \
mv locale.alias ../temp_dir; \
mv $PRIMARY_LANGUAGE $PRIMARY_LOCALE $SECONDARY_LANGUAGE $SECONDARY_LOCALE ../temp_dir; \
rm -rf *; mv ../temp_dir/* .; rmdir ../temp_dir; \
sync; \
fi)

# remove rarely used documentation files
(cd /usr/share/doc; \
if find . -maxdepth 1 -mmin -60 >/dev/null; then \
find . -iname changelog* -exec rm -f {} \; ;\
find . -iname changes -exec rm -f {} \; ;\
find . -iname news -exec rm -f {} \; ;\
sync; \
fi)

# remove manual pages for unsupported languages
(cd /usr/share/man; \
if [ \`ls | wc -w\` -gt 16 ]; then \
mkdir ../temp_dir; \
mv man* $PRIMARY_LANGUAGE $SECONDARY_LANGUAGE ../temp_dir; \
rm -rf *; mv ../temp_dir/* .; rmdir ../temp_dir; \
sync; \
fi)
EOF_post

/bin/bash -x /root/post-install 2>&1 | tee /root/post-install.log





tar -zxvf /etc/openfire.tgz -C /opt

if [ -e /etc/hosts.orig ]
then echo "/etc/hosts file already installed"
else echo "Installing /etc/hosts with 10 netterms..."
cp /etc/hosts /etc/hosts.orig
hostname=rx30
echo -e "127.0.0.1\tlocalhost\tlocalhost.localdomain
12.164.113.100\tll_host
192.168.0.254\t$hostname\t$hostname.localdomain
192.168.0.2\tnetterm1
192.168.0.3\tnetterm2
192.168.0.4\tnetterm3
192.168.0.5\tnetterm4
192.168.0.\tmylan
12.164.113.15\tftp.rx30.com
12.164.113.103\tsshserver
" >/etc/hosts
fi

echo -e "NETWORKING=yes
HOSTNAME=rx30.localdomain
GATEWAY=192.168.0.1" >/etc/sysconfig/network
# new kluge to eliminate NM_controlled, MTU and MAC lines in CentOS6
mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/ifcfg-eth0.BAK

echo -e "DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.254
NETMASK=255.255.255.0
DNS1=208.67.222.222" >/etc/sysconfig/network-scripts/ifcfg-eth0

## Timestamp root history
echo "export HISTTIMEFORMAT='%m %d %Y- %H:%M:%S '" >>/root/.bash_profile

cp /usr/bin/vpninstl /root
if [ -e /etc/profile.orig ]
then echo "/etc/profile already updated"
else echo "Updating /etc/profile..."
cp /etc/profile /etc/profile.orig
echo "
if [ -r /etc/default/timezone ]
then TZ=\`cat /etc/default/timezone\`
export TZ
fi
INIT_TTY=\`tty\`
TTY1=\`basename \$INIT_TTY\`
TTY=\`echo \$TTY1 | cut -c1-3\`
if [ \$TTY = \"tty\" ]
then
unicode_stop
fi
" >/etc/profile
fi

if [ -e /etc/rc.d/rc.local.orig ]
then echo "/etc/rc.d/rc.local already updated"
else echo "Updating /etc/rc.local..."
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.orig
echo "
chmod 777 /dev/ttyS*
/bin/loadkeys << EOF
keycode 14 = BackSpace
keycode 111 = Delete
EOF
initctl start tty TTY=tty1 &
chmod 666 /etc/sane.d/net.conf" >> /etc/rc.d/rc.local
fi

/usr/sbin/groupadd -f -g 505 group
if [ $? -ne 0 ]
then echo "Groupadd group FAILED"
fail=`expr $fail + 1`
fi

#install swatch file into place

cp /opt/extras/swatch.sata /etc/swatch.conf

echo -e "
*.mozilla*
*.kde*" >> /usr/rx30/excludes.conf

mkdir /usr/rx30/Desktop
cp /etc/skel/Desktop/* /usr/rx30/Desktop
ln -s /usr/sbin/openvpn /usr/local/sbin/openvpn
mv /usr/bin/rxupdate.sh /usr/rx30
mv /usr/bin/rxutils.sh /usr/rx30
mv /usr/bin/rbld.sh /usr/rx30
mv /usr/bin/rx30dcs.dcr /usr/rx30
mv /usr/bin/browser.sh /usr/rx30
mv /usr/bin/tdsinstall.gui /usr/rx30
mv /usr/bin/getlogs.sh /usr/rx30
rm /usr/rx30/.kde/share/apps/konsole/Shell.profile
mv /usr/share/konsole/Shell.profile /usr/rx30/.kde/share/apps/konsole
mv /usr/share/konsole/Ansi.profile /usr/rx30/.kde/share/apps/konsole
mv /usr/share/konsole/Scoansi.profile /usr/rx30/.kde/share/apps/konsole

# Creating rx30 user and fixing permissions

echo "rx30:\$1\$7czGzB77\$UYXB/n5VuwAYdDEn8fdz7.:13472:0:99999:7:::" >> /etc/shadow
echo -e "rx30:x:502:505:Rx30 Pharmacy System:/usr/rx30:/bin/bash" >> /etc/passwd
chown -R rx30:group /usr/rx30
cp /etc/skel/.bash_profile /usr/rx30
cp /etc/skel/.bashrc /usr/rx30
chown -R rx30:group /usr/rx30/.bash_profile /usr/rx30/excludes.conf /usr/rx30/.bashrc /usr/rx30/.kde /usr/rx30
chmod -R 775 /usr/rx30/.bash_profile /usr/rx30/excludes.conf /usr/rx30/.kde

if [ '!' -e /usr/rx30/prt2dsk ]
then cp -p /usr/bin/prt2dsk /usr/rx30
cp -p /usr/bin/prt2dsk.cnf /usr/rx30
chown rx30:group /usr/rx30/prt2dsk*
fi
# Make mount directories
mkdir /mnt/dvd /mnt/cdrom /mnt/floppy /mnt/usb
# adding mount point for usb backup stick with vol label
echo "LABEL=rx30usbbackup /mnt/usb ext3 user,rw,noauto 0 0" >>/etc/fstab

# Copy ltsp related stuff into place
#cp /opt/extras/rx30ltsp/Xsetup_workstation /etc/X11/xdm
#cp /opt/extras/rx30ltsp/rx30ltsp.jpg /etc/X11/xdm
#cp /opt/extras/rx30ltsp/kbd_mode /opt/ltsp/i386/bin
cp -R /opt/ltsp/i386/etc/sane.d /etc
mkdir -p /var/opt/ltsp/swapfiles

# copy luxi fonts into rx30
# seems to be the only fonts that work with gui rx30
cp /opt/ltsp/i386/usr/X11R6/lib/X11/fonts/TTF/* /usr/share/X11/fonts/TTF/

# Turn services on for filtering and jammins and misc networking

chkconfig --add ipfilter
chkconfig --add postfix
chkconfig dhcpd on
chkconfig nfs on
chkconfig vsftpd on
chkconfig ntpd on
chkconfig smb on
chkconfig xfs on
#Turn off System monitoring

chkconfig mdmonitor off
rm -rf /etc/cron.daily/0logwatch
chkconfig swatch off
#chkconfig swatch on

# Turn off un-needed services

chkconfig gpm off
chkconfig sendmail off
chkconfig smartd off
chkconfig hplip off
chkconfig nasd off
chkconfig iptables off
chkconfig ip6tables off
chkconfig postfix off
chkconfig NetworkManager off
# Change file modes for Misc RX30 purposes.

ln -s /usr/bin/xauth /usr/X11R6/xauth
chmod +x /usr/rx30/Desktop/RX30.desktop
chmod 4555 /usr/sbin/pppd
chown rx30 /etc/ppp/chap-*
chown rx30 /etc/ppp/pap-*
chmod -R 777 /etc/ppp
chmod -R 775 /usr/rx30
chmod 775 /usr/rx30/.bashrc
chown root /sbin/uugetty
chgrp root /sbin/uugetty
chmod 755 /sbin/uugetty
chmod 440 /etc/sudoers
chmod 700 /usr/bin/tdsconfig
cp /bin/ll_instl /usr/rx30
chown rx30 /usr/rx30/ll_instl
chmod 6711 /bin/ll_instl
chmod 6711 /bin/ll_tcpd
# location of dhcpd.conf changed in CentOS 6
mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.orig
ln -s /etc/dhcpd.conf /etc/dhcp/dhcpd.conf
ln -s /tftpboot/* /var/lib/tftpboot/
%end[/code]
[Moderator edit: Wrap [b]long[/b] lines.]

That is the kickstart file i am using.

some guidance is needed. many thanks in advance.

lleb
Posts: 14
Joined: 2012/03/18 14:53:14

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by lleb » 2012/03/21 21:57:35

sorry, here is the working directory that I am using:

[code][root@rx30 ~]# ls -l CentOS_6.2/
total 316
-r--r--r-- 1 rx30 group 14 Dec 16 18:58 CentOS_BuildTag
-r--r--r-- 1 rx30 group 212 Dec 9 07:57 EULA
-r--r--r-- 1 rx30 group 18009 Dec 9 07:57 GPL
dr-xr-xr-x 5 rx30 group 86016 Mar 21 17:44 Packages
-r--r--r-- 1 rx30 group 1354 Dec 9 07:58 RELEASE-NOTES-en-US.html
-r--r--r-- 1 rx30 group 1706 Dec 9 07:57 RPM-GPG-KEY-CentOS-6
-r--r--r-- 1 rx30 group 1730 Dec 9 07:57 RPM-GPG-KEY-CentOS-Debug-6
-r--r--r-- 1 rx30 group 1730 Dec 9 07:57 RPM-GPG-KEY-CentOS-Security-6
-r--r--r-- 1 rx30 group 1734 Dec 9 07:57 RPM-GPG-KEY-CentOS-Testing-6
-r--r--r-- 1 rx30 group 5847 Feb 27 09:56 TRANS.TBL
drwxr-xr-x 2 root root 4096 Mar 21 17:40 a-base
drwxr-xr-x 2 root root 4096 Mar 21 17:41 a-live
drwxr-xr-x 2 root root 4096 Mar 21 17:41 a-updates
-r-xr-xr-x 1 rx30 group 9227 Feb 16 09:26 ide.cfg
-r-xr-xr-x 1 rx30 group 9255 Feb 16 09:26 ideNV.cfg
-r-xr-xr-x 1 rx30 group 9237 Feb 16 09:27 iderestore.cfg
-r-xr-xr-x 1 rx30 group 9265 Feb 16 09:29 iderestoreNV.cfg
dr-xr-xr-x 3 rx30 group 4096 Jan 26 10:17 images
dr-xr-xr-x 2 rx30 group 4096 Feb 14 17:32 isolinux
-r-xr-xr-x 1 rx30 group 7300 Jun 27 2011 ksraid.cfg
dr-xr-xr-x 2 rx30 group 4096 Feb 27 09:56 post
-r-xr-xr-x 1 rx30 group 7667 Mar 10 2011 postinstall.sh
-r-xr-xr-x 1 rx30 group 7685 Jun 27 2011 raidrescue.cfg
dr-xr-xr-x 2 rx30 group 4096 Feb 27 09:56 repodata
-rw-rw-r-- 1 rx30 group 22633 Mar 21 16:56 sata-2.cfg
-r-xr-xr-x 1 rx30 group 9141 Feb 16 09:25 sata.cfg
-r--r--r-- 1 rx30 group 9193 Feb 16 09:25 sataNV.cfg
-r-xr-xr-x 1 rx30 group 9238 Feb 16 09:25 satarestore.cfg
-r--r--r-- 1 rx30 group 9289 Feb 16 09:26 satarestoreNV.cfg
[/code]

so the Packages directory is there, but how do I tell livecd-creator to look there?

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by pschaff » 2012/03/21 22:57:46

[quote]
lleb wrote:
...
Retrieving http://mirror.centos.org/centos/5/os/i386/repodata/repomd.xml ...OK
...[/quote]
Please limit your posts to essential data. That's [b][i]way[/i][/b] too much for me to attempt to digest in detail, but you copied much too faithfully and blindly. You are using CentOS-5 repos rather than CentOS-6. You should also use a nearby [url=http://www.centos.org/modules/tinycontent/index.php?id=30]mirror[/url] rather than the main site.

lleb
Posts: 14
Joined: 2012/03/18 14:53:14

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by lleb » 2012/03/22 12:18:10

thanks, i feel like a bit of an idiot on that one. i should of checked before i put those in there...

lleb
Posts: 14
Joined: 2012/03/18 14:53:14

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by lleb » 2012/03/22 13:14:28

[code]/usr/lib/python2.6/site-packages/imgcreate/errors.py:45: DeprecationWarning: BaseException.message has been deprecated as of Python 2.6
return unicode(self.message)
Error creating Live CD : Unable to install: Could not run transaction.[/code]

well buggers. i got it to grab all kinds of files and to run about 30min then it failed here... what transaction is it referring to? is this due to the older python, or something else?

lleb
Posts: 14
Joined: 2012/03/18 14:53:14

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by lleb » 2012/03/22 14:47:52

this seems to be an out of memory type error. how do i fix this so i can partition more space to were ever the liveOS is being created?

[code][root@rx30 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 65G 9.0G 52G 15% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/sda1 97M 32M 61M 35% /boot
/dev/sda2 65G 202M 61G 1% /usr/rx30
[root@rx30 ~]# free -m
total used free shared buffers cached
Mem: 3922 1589 2332 0 13 1464
-/+ buffers/cache: 112 3809
Swap: 6111 0 6111
[/code]

pschaff
Retired Moderator
Posts: 18276
Joined: 2006/12/13 20:15:34
Location: Tidewater, Virginia, North America
Contact:

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by pschaff » 2012/03/22 20:46:28

You seem to have plenty of free space and swap is not in use, so no sign of a problem with either disk space or memory. The python message seems to be only a warning.

I'd suggest trying to create a very minimal LiveCD as a first test case.

lleb
Posts: 14
Joined: 2012/03/18 14:53:14

Re: HOWTO create a LiveDVD/USB from a custom build of CentOS 6.2

Post by lleb » 2012/03/22 21:35:33

i think i resolved this issue, but now im getting errors when it starts to end. it never umounts the virtual partitions and drives leaving me with no .iso. i have made some major changes tot he kickstart script.

[code]
firewall --disabled
# Install OS instead of upgrade
install
# Use CDROM installation media
cdrom
# Network information
network --bootproto=dhcp --device=eth0 --nameserver=8.8.8.8 --onboot=on
# System authorization information
auth --useshadow --passalgo=md5
# Use graphical install
graphical
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# adding repos

repo --name=a-base --baseurl=http://mirror.centos.org/centos/6.2/os/i386
repo --name=a-updates --baseurl=http://mirror.centos.org/centos/6.2/updates/i386
repo --name=a-live --baseurl=http://www.nanotechnologies.qc.ca/propos/linux/centos-live/i386/live
repo --name=a-google-chrome --baseurl=http://dl.google.com/linux/chrome/rpm/stable/i386

# Installation logging level
logging --level=info
#Root password
rootpw --iscrypted $1$tX3SYG9H$X/RENO4wHFcFCZri8t02F/
# X Window System configuration information
xconfig --defaultdesktop=KDE
# Reboot after installation
#reboot
reboot --eject
# System timezone
timezone America/New_York
# System bootloader configuration
bootloader --location=mbr append vga=791
# Partition clearing information
clearpart --all --initlabel
# Disk partitioning information
part /boot --ondisk sda --fstype="ext3" --size=100
part / --ondisk sda --fstype="ext3" --grow --size=9000
part /usr/rx30 --ondisk sda --fstype="ext3" --grow --size=9000 --asprimary
part swap --ondisk sda --fstype="swap" --recommended

%packages
syslinux
kernel
@additional-devel
@backup-client
@base
@cifs-file-server
@compat-libraries
@console-internet
@debugging
@desktop-debugging
@development
@dial-up
@fonts
@ftp-server
@graphical-admin-tools
@graphics
@hardware-monitoring
@internet-applications
@internet-browser
@java-platform
@kde-desktop
@legacy-unix
@legacy-x
@mail-server
@mainframe-access
@mysql
@mysql-client
@network-file-system-client
@network-server
@network-tools
@nfs-file-server
@office-suite
@performance
@perl-runtime
@print-client
@print-server
@remote-desktop-clients
@server-platform
@system-admin-tools
@system-management
@web-server
@x11
@rx30-cfg
@rx30-chat
#AdobeReader_enu
arptables_jf
arpwatch
bitmap-console-fonts
bitmap-fixed-fonts
bitmap-lucida-typewriter-fonts
bitmap-miscfixed-fonts
cmake
compat-gcc-34
compat-gcc-34-c++
compat-gcc-34-g77
dos2unix
dropwatch
dump
efax
ftp
gcc-objc
gcc-objc++
ghostscript-gtk
glibc-static
google-chrome
iptraf
iptstate
krb5-appl-servers
lftp
libXmu
lsscsi
m17n-db-generic
mc
memtest86+
mgetty
mgetty-sendfax
mgetty-viewfax
mtr-gtk
mutt
mysql-bench
mysql-test
ncompress
ncurses-static
openmotif
openmotif22
perl-TimeDate
perl-Bit-Vector

# other usefull packages
#Cluster_Administration-en-US
#Deployment_Guide-en-US
#Global_File_System-en-US
#Virtualization-en-US
#busybox
#mailx
#patch
yum-fastestmirror
yum-metadata-parser
# end other usefull packages

perl-Carp-Clan
perl-Date-Calc
perl-DateManip
perl-libwww-perl
perl-Compress-Zlib
perl-HTML-Parser
perl-HTML-Tagset
perl-URI
perl-DBD-MySQL
postfix
pptp
python
rdesktop
rdist
rsh
rsyslog-gnutls
rsyslog-gnutls
rsyslog-gssapi
rsyslog-gssapi
rsyslog-mysql
rusers
screen
sg3_utils
#swatch
symlinks
syslinux
system-config-lvm
tcp_wrappers
telnet
telnet-server
tftp
thunderbird
tree
tuned
udftools
unix2dos
uuidd
wireshark
xorg-x11-fonts-ethiopic
xorg-x11-fonts-75dpi
xorg-x11-fonts-ISO8859-1-75dpi
xorg-x11-fonts-ISO8859-14-100dpi
xorg-x11-fonts-ISO8859-14-75dpi
xorg-x11-fonts-ISO8859-15-75dpi
xorg-x11-fonts-ISO8859-2-100dpi
xorg-x11-fonts-ISO8859-2-75dpi
xorg-x11-fonts-ISO8859-9-100dpi
xorg-x11-fonts-ISO8859-9-75dpi
xorg-x11-twm
xorg-x11-xdm
xterm
yum-plugin-protect-packages
yum-plugin-security
#libFS
#xorg-x11-xfs

%post --nochroot

mkdir -p /mnt/source;mount -t iso9660 /tmp/cdrom /mnt/source
tar -xzvf /mnt/source/post/rx30sysfiles.tgz -C /mnt/sysimage/
#tar -xvzf /mnt/source/post/ltsp.tgz -C /mnt/sysimage/opt
mkdir /mnt/sysimage/tftpboot
tar -xvzf /mnt/source/post/tftpboot.tgz -C /mnt/sysimage/tftpboot
mkdir /mnt/sysimage/usr/rx30/.kde
mkdir /mnt/sysimage/usr/rx30/.kde/share
mkdir /mnt/sysimage/usr/rx30/.kde/share/config
mkdir /mnt/sysimage/usr/rx30/llinstl
mkdir /mnt/sysimage/usr/rx30/llinstl/bak

tar -xvzf /mnt/source/post/kdeshareconfig.tgz -C /mnt/sysimage/usr/rx30/.kde/share/config
cp /mnt/source/changelog /mnt/sysimage/root

########################################################################
# Create a sub-script so the output can be captured
# Must change "$" to "\$" and "`" to "\`" to avoid shell quoting
########################################################################
cat > /root/postnochroot-install << EOF_postnochroot
#!/bin/bash

# add livecd-iso-to-disk utility on the LiveCD
# only works on x86, x86_64
if [ "\$(uname -i)" = "i386" -o "\$(uname -i)" = "x86_64" ]; then
if [ ! -d \$LIVE_ROOT/LiveOS ]; then mkdir -p \$LIVE_ROOT/LiveOS ; fi
cp /usr/bin/livecd-iso-to-disk \$LIVE_ROOT/LiveOS
fi

# customize boot menu entries
grep -A4 'label linux0' \$LIVE_ROOT/isolinux/isolinux.cfg > \$LIVE_ROOT/isolinux/default.txt
grep -A2 'label memtest' \$LIVE_ROOT/isolinux/isolinux.cfg > \$LIVE_ROOT/isolinux/memtest.txt
grep -A2 'label local' \$LIVE_ROOT/isolinux/isolinux.cfg > \$LIVE_ROOT/isolinux/localboot.txt

sed "s/label linux0/label linuxtext0/" \$LIVE_ROOT/isolinux/default.txt > \$LIVE_ROOT/isolinux/textmode.txt
sed -i "s/Boot/Boot (text mode)/" \$LIVE_ROOT/isolinux/textmode.txt
sed -i "s/liveimg/liveimg 3/" \$LIVE_ROOT/isolinux/textmode.txt
sed -i "/menu default/d" \$LIVE_ROOT/isolinux/textmode.txt

touch \$LIVE_ROOT/isolinux/installer.txt
if [ -e \$INSTALL_ROOT/boot/livecd-installer.img -a -e \$INSTALL_ROOT/boot/vmlinuz-installer* ]; then
mv \$INSTALL_ROOT/boot/livecd-installer.img \$LIVE_ROOT/isolinux/install.img
mv \$INSTALL_ROOT/boot/vmlinuz-installer* \$LIVE_ROOT/isolinux/vminst
cat > \$LIVE_ROOT/isolinux/installer.txt << EOF_installer
label installer
menu label Network Installation
kernel vminst
append initrd=install.img text
EOF_installer
fi

cat \$LIVE_ROOT/isolinux/default.txt \$LIVE_ROOT/isolinux/memtest.txt \$LIVE_ROOT/isolinux/localboot.txt > \$LIVE_ROOT/isolinux/current.txt
diff \$LIVE_ROOT/isolinux/isolinux.cfg \$LIVE_ROOT/isolinux/current.txt | sed '/^[0-9][0-9]*/d; s/^. //; /^---$/d' > \$LIVE_ROOT/isolinux/cleaned.txt
cat \$LIVE_ROOT/isolinux/cleaned.txt \$LIVE_ROOT/isolinux/default.txt \$LIVE_ROOT/isolinux/textmode.txt \$LIVE_ROOT/isolinux/installer.txt \$LIVE_ROOT/isolinux/memtest.txt \$LIVE_ROOT/isolinux/localboot.txt > \$LIVE_ROOT/isolinux/isolinux.cfg
rm -f \$LIVE_ROOT/isolinux/*.txt

EOF_postnochroot

/bin/bash -x /root/postnochroot-install 2>&1 | tee /root/postnochroot-install.log




%post

## LiveCD version for the link toward the release notes
VERSION="6.2"
## locales for the Live CD
PRIMARY_LANGUAGE="en"
PRIMARY_LOCALE="en_US"

## default LiveCD user
LIVECD_USER="rx30"

########################################################################
# Create a sub-script so the output can be captured
# Must change "$" to "\$" and "`" to "\`" to avoid shell quoting
########################################################################
cat > /root/post-install << EOF_post
#!/bin/bash

echo ###################################################################
echo ## Creating the livesys init script
echo ###################################################################

cat > /etc/rc.d/init.d/livesys << EOF_initscript
#!/bin/bash
#
# live: Init script for live image
#
# chkconfig: 345 00 99
# description: Init script for live image.

. /etc/init.d/functions

if ! strstr "\\\`cat /proc/cmdline\\\`" liveimg || [ "\\\$1" != "start" ] || [ -e /.liveimg-configured ] ; then
exit 0
fi

exists() {
which \\\$1 >/dev/null 2>&1 || return
\\\$*
}

# read some variables out of /proc/cmdline
for o in \\\`cat /proc/cmdline\\\` ; do
case \\\$o in
xdriver=*)
xdriver="--set-driver=\\\${o#xdriver=}"
;;
esac
done

touch /.liveimg-configured

# mount live image
if [ -b /dev/live ]; then
mkdir -p /mnt/live
mount -o ro /dev/live /mnt/live
fi

# enable swaps unless requested otherwise
swaps=\\\`blkid -t TYPE=swap -o device\\\`
if ! strstr "\\\`cat /proc/cmdline\\\`" noswap -a [ -n "\\\$swaps" ] ; then
for s in \\\$swaps ; do
action "Enabling swap partition \\\$s" swapon \\\$s
done
fi

## fix various bugs and issues
# configure X, allowing user to override xdriver
exists system-config-display --noui --reconfig --set-depth=24 \\\$xdriver

# turn off firstboot for livecd boots
echo "RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot

# create a patch for kudzu init script
cat > /tmp/kudzu.patch << EOF_kudzupatch
--- kudzu.orig 2007-07-27 20:27:03.000000000 -0400
+++ kudzu 2007-07-27 20:27:23.000000000 -0400
@@ -35,6 +35,10 @@
action "" /bin/false
fi

+ # Reconfigure the keyboard
+ . /etc/sysconfig/keyboard
+ /usr/bin/system-config-keyboard \\\\\\\$KEYTABLE 2&> /dev/null
+
# We don't want to run this on random runlevel changes.
touch /var/lock/subsys/kudzu
# However, if they did configure X and want runlevel 5, let's
EOF_kudzupatch

# patch kudzu init script
/usr/bin/patch /etc/rc.d/init.d/kudzu /tmp/kudzu.patch > /dev/null
rm -f /tmp/kudzu.patch

# stopgap fix for RH #217966; should be fixed in HAL instead
touch /media/.hal-mtab

# workaround clock syncing on shutdown that we don't want (RH #297421)
sed -i -e 's/hwclock/no-such-hwclock/g' /etc/rc.d/init.d/halt

# workaround avahi segfault (RH #273301)
touch /etc/resolv.conf
/sbin/restorecon /etc/resolv.conf

# set the LiveCD hostname
sed -i -e 's/HOSTNAME=localhost.localdomain/HOSTNAME=livecd.localdomain/g' /etc/sysconfig/network
/bin/hostname livecd.localdomain

## create the LiveCD default user
# add default user with no password
/usr/sbin/useradd -c "LiveCD default user" $LIVECD_USER
/usr/bin/passwd -d $LIVECD_USER > /dev/null
# give default user sudo privileges
echo "$LIVECD_USER ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

# disable screensaver locking
gconftool-2 --direct --config-source=xml:readwrite:/etc/gconf/gconf.xml.defaults -s -t bool /apps/gnome-screensaver/lock_enabled false >/dev/null

# add documentation shortcuts
mkdir -p /home/$LIVECD_USER/Desktop/Documentation
cp /usr/share/applications/Cluster_Administration-en-US.desktop /home/$LIVECD_USER/Desktop/Documentation/
cp /usr/share/applications/Deployment_Guide-en-US.desktop /home/$LIVECD_USER/Desktop/Documentation/
cp /usr/share/applications/Global_File_System-en-US.desktop /home/$LIVECD_USER/Desktop/Documentation/
cp /usr/share/applications/Virtualization-en-US.desktop /home/$LIVECD_USER/Desktop/Documentation/
cat > /home/$LIVECD_USER/Desktop/Documentation/Additional_Documentation.desktop << EOF_documentation
[Desktop Entry]
Name=Additional Documentation
Comment=Enterprise Linux
Exec=firefox http://www.centos.org/docs/5/
Icon=/usr/share/pixmaps/redhat-web-browser.png
Categories=Documentation;
Type=Application
Encoding=UTF-8
Terminal=false
EOF_documentation
cat > /home/$LIVECD_USER/Desktop/Documentation/Release_Notes.desktop << EOF_release_notes
[Desktop Entry]
Name=How To Install
Comment=Enterprise Linux
Exec=firefox http://wiki.centos.org/Manuals/ReleaseNotes/CentOSLiveCD$VERSION
Icon=/usr/share/pixmaps/redhat-web-browser.png
Categories=Documentation;
Type=Application
Encoding=UTF-8
Terminal=false
EOF_release_notes

CreateDesktopIconHD()
{
cat > /home/$LIVECD_USER/Desktop/Local\ hard\ drives.desktop << EOF_HDicon
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Link
Name=Local hard drives
Name[en_US]=Local hard drives
Name[fr_CA]=Disques durs locaux
URL=/mnt/disc
Icon=/usr/share/icons/Bluecurve/48x48/devices/gnome-dev-harddisk.png
EOF_HDicon

chmod 755 /home/$LIVECD_USER/Desktop/Local\ hard\ drives.desktop
}

CreateDesktopIconLVM()
{
cat > /home/$LIVECD_USER/Desktop/Local\ logical\ volumes.desktop << EOF_LVMicon
[Desktop Entry]
Encoding=UTF-8
Version=1.0
Type=Link
Name=Local logical volumes
Name[en_US]=Local logical volumes
Name[fr_CA]=Volumes logiques locaux
URL=/mnt/lvm
Icon=/usr/share/icons/Bluecurve/48x48/devices/gnome-dev-harddisk.png
EOF_LVMicon

chmod 755 /home/$LIVECD_USER/Desktop/Local\ logical\ volumes.desktop
}

# don't mount disk partitions if 'nodiskmount' is given as a boot option
if ! strstr "\\\`cat /proc/cmdline\\\`" nodiskmount ; then
MOUNTOPTION="ro"
HARD_DISKS=\\\`egrep "[sh]d.\\\$" /proc/partitions | tr -s ' ' | sed 's/^ *//' | cut -d' ' -f4\\\`

echo "Mounting hard disk partitions... "
for DISK in \\\$HARD_DISKS; do
# Get the device and system info from fdisk (but only for fat and linux partitions).
FDISK_INFO=\\\`fdisk -l /dev/\\\$DISK | tr [A-Z] [a-z] | egrep "fat|linux" | egrep -v "swap|extended|lvm" | sed 's/*//' | tr -s ' ' | tr ' ' ':' | cut -d':' -f1,6-\\\`
for FDISK_ENTRY in \\\$FDISK_INFO; do
PARTITION=\\\`echo \\\$FDISK_ENTRY | cut -d':' -f1\\\`
MOUNTPOINT="/mnt/disc/\\\${PARTITION##/dev/}"
mkdir -p \\\$MOUNTPOINT
MOUNTED=FALSE

# get the partition type
case \\\`echo \\\$FDISK_ENTRY | cut -d':' -f2-\\\` in
*fat*)
FSTYPES="vfat"
EXTRAOPTIONS=",uid=500";;
*)
FSTYPES="ext4 ext3 ext2"
EXTRAOPTIONS="";;
esac

# try to mount the partition
for FSTYPE in \\\$FSTYPES; do
if mount -o "\\\${MOUNTOPTION}\\\${EXTRAOPTIONS}" -t \\\$FSTYPE \\\$PARTITION \\\$MOUNTPOINT &>/dev/null; then
echo "\\\$PARTITION \\\$MOUNTPOINT \\\$FSTYPE noauto,\\\${MOUNTOPTION}\\\${EXTRAOPTIONS} 0 0" >> /etc/fstab
echo -n "\\\$PARTITION "
MOUNTED=TRUE
CreateDesktopIconHD
fi
done
[ \\\$MOUNTED = "FALSE" ] && rmdir \\\$MOUNTPOINT
done
done
echo


FSTYPES="ext4 ext3 ext2"

echo "Scanning for logical volumes..."
if ! lvm vgscan 2>&1 | grep "No volume groups"; then
echo "Activating logical volumes ..."
modprobe dm_mod >/dev/null
echo "mkdmnod" | nash --quiet
lvm vgchange -ay
LOGICAL_VOLUMES=\\\`lvm lvdisplay -c | sed "s/^ *//" | cut -d: -f1\\\`
if [ ! -z "\\\$LOGICAL_VOLUMES" ]; then
echo "Making device nodes ..."
lvm vgmknodes
echo -n "Mounting logical volumes ... "
for VOLUME_NAME in \\\$LOGICAL_VOLUMES; do
VG_NAME=\\\`echo \\\$VOLUME_NAME | cut -d/ -f3\\\`
LV_NAME=\\\`echo \\\$VOLUME_NAME | cut -d/ -f4\\\`
MOUNTPOINT="/mnt/lvm/\\\${VG_NAME}-\\\${LV_NAME}"
mkdir -p \\\$MOUNTPOINT

MOUNTED=FALSE
for FSTYPE in \\\$FSTYPES; do
if mount -o \\\$MOUNTOPTION -t \\\$FSTYPE \\\$VOLUME_NAME \\\$MOUNTPOINT &>/dev/null; then
echo "\\\$VOLUME_NAME \\\$MOUNTPOINT \\\$FSTYPE defaults,\\\${MOUNTOPTION} 0 0" >> /etc/fstab
echo -n "\\\$VOLUME_NAME "
MOUNTED=TRUE
CreateDesktopIconLVM
break
fi
done
[ \\\$MOUNTED = FALSE ] && rmdir \\\$MOUNTPOINT
done
echo

else
echo "No logical volumes found"
fi
fi
fi

# give back ownership to the default user
chown -R $LIVECD_USER:$LIVECD_USER /home/$LIVECD_USER
EOF_initscript

chmod 755 /etc/rc.d/init.d/livesys
/sbin/restorecon /etc/rc.d/init.d/livesys
/sbin/chkconfig --add livesys

echo ###################################################################
echo ## Trim down the LiveCD to save some space
echo ###################################################################
# remove unneeded initrd file(s)
rm -f /boot/initrd*
# temporary RPM databases can be removed
rm -f /usr/var/lib/rpm/__db.00*
# make sure there aren't core files lying around
rm -f /core*

# remove files for unsupported languages in various applications
(cd /var/lib/scrollkeeper; \
if [ \`ls | wc -w\` -gt 11 ]; then \
mkdir ../temp_dir; \
mv C $PRIMARY_LANGUAGE $SECONDARY_LANGUAGE index scrollkeeper_docs TOC ../temp_dir; \
rm -rf *; mv ../temp_dir/* .; rmdir ../temp_dir; \
sync; \
fi)
(cd /usr/lib/locale; \
if [ \`ls | wc -w\` -gt 8 ]; then \
mkdir ../temp_dir; \
mv $PRIMARY_LOCALE* $SECONDARY_LOCALE* ../temp_dir; \
rm -rf *; mv ../temp_dir/* .; rmdir ../temp_dir; \
/usr/sbin/build-locale-archive; \
sync; \
fi)
(cd /usr/share/locale; \
if [ \`ls | wc -w\` -gt 10 ]; then \
mkdir ../temp_dir; \
mv locale.alias ../temp_dir; \
mv $PRIMARY_LANGUAGE $PRIMARY_LOCALE $SECONDARY_LANGUAGE $SECONDARY_LOCALE ../temp_dir; \
rm -rf *; mv ../temp_dir/* .; rmdir ../temp_dir; \
sync; \
fi)

# remove rarely used documentation files
(cd /usr/share/doc; \
if find . -maxdepth 1 -mmin -60 >/dev/null; then \
find . -iname changelog* -exec rm -f {} \; ;\
find . -iname changes -exec rm -f {} \; ;\
find . -iname news -exec rm -f {} \; ;\
sync; \
fi)

# remove manual pages for unsupported languages
(cd /usr/share/man; \
if [ \`ls | wc -w\` -gt 16 ]; then \
mkdir ../temp_dir; \
mv man* $PRIMARY_LANGUAGE $SECONDARY_LANGUAGE ../temp_dir; \
rm -rf *; mv ../temp_dir/* .; rmdir ../temp_dir; \
sync; \
fi)
EOF_post

/bin/bash -x /root/post-install 2>&1 | tee /root/post-install.log





tar -zxvf /etc/openfire.tgz -C /opt

if [ -e /etc/hosts.orig ]
then echo "/etc/hosts file already installed"
else echo "Installing /etc/hosts with 10 netterms..."
cp /etc/hosts /etc/hosts.orig
hostname=rx30
echo -e "127.0.0.1\tlocalhost\tlocalhost.localdomain
12.164.113.100\tll_host
192.168.0.254\t$hostname\t$hostname.localdomain
192.168.0.2\tnetterm1
192.168.0.3\tnetterm2
192.168.0.4\tnetterm3
192.168.0.5\tnetterm4
192.168.0.\tmylan
12.164.113.15\tftp.rx30.com
12.164.113.103\tsshserver
" >/etc/hosts
fi

echo -e "NETWORKING=yes
HOSTNAME=rx30.localdomain
GATEWAY=192.168.0.1" >/etc/sysconfig/network
# new kluge to eliminate NM_controlled, MTU and MAC lines in CentOS6
mv /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/ifcfg-eth0.BAK

echo -e "DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=192.168.0.254
NETMASK=255.255.255.0
DNS1=208.67.222.222" >/etc/sysconfig/network-scripts/ifcfg-eth0

## Timestamp root history
echo "export HISTTIMEFORMAT='%m %d %Y- %H:%M:%S '" >>/root/.bash_profile

cp /usr/bin/vpninstl /root
if [ -e /etc/profile.orig ]
then echo "/etc/profile already updated"
else echo "Updating /etc/profile..."
cp /etc/profile /etc/profile.orig
echo "
if [ -r /etc/default/timezone ]
then TZ=\`cat /etc/default/timezone\`
export TZ
fi
INIT_TTY=\`tty\`
TTY1=\`basename \$INIT_TTY\`
TTY=\`echo \$TTY1 | cut -c1-3\`
if [ \$TTY = \"tty\" ]
then
unicode_stop
fi
" >/etc/profile
fi

if [ -e /etc/rc.d/rc.local.orig ]
then echo "/etc/rc.d/rc.local already updated"
else echo "Updating /etc/rc.local..."
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.orig
echo "
chmod 777 /dev/ttyS*
/bin/loadkeys << EOF
keycode 14 = BackSpace
keycode 111 = Delete
EOF
initctl start tty TTY=tty1 &
chmod 666 /etc/sane.d/net.conf" >> /etc/rc.d/rc.local
fi

/usr/sbin/groupadd -f -g 505 group
if [ $? -ne 0 ]
then echo "Groupadd group FAILED"
fail=`expr $fail + 1`
fi

#install swatch file into place

cp /opt/extras/swatch.sata /etc/swatch.conf

echo -e "
*.mozilla*
*.kde*" >> /usr/rx30/excludes.conf

mkdir /usr/rx30/Desktop
cp /etc/skel/Desktop/* /usr/rx30/Desktop
ln -s /usr/sbin/openvpn /usr/local/sbin/openvpn
mv /usr/bin/rxupdate.sh /usr/rx30
mv /usr/bin/rxutils.sh /usr/rx30
mv /usr/bin/rbld.sh /usr/rx30
mv /usr/bin/rx30dcs.dcr /usr/rx30
mv /usr/bin/browser.sh /usr/rx30
mv /usr/bin/tdsinstall.gui /usr/rx30
mv /usr/bin/getlogs.sh /usr/rx30
rm /usr/rx30/.kde/share/apps/konsole/Shell.profile
mv /usr/share/konsole/Shell.profile /usr/rx30/.kde/share/apps/konsole
mv /usr/share/konsole/Ansi.profile /usr/rx30/.kde/share/apps/konsole
mv /usr/share/konsole/Scoansi.profile /usr/rx30/.kde/share/apps/konsole

# Creating rx30 user and fixing permissions

echo "rx30:\$1\$7czGzB77\$UYXB/n5VuwAYdDEn8fdz7.:13472:0:99999:7:::" >> /etc/shadow
echo -e "rx30:x:502:505:Rx30 Pharmacy System:/usr/rx30:/bin/bash" >> /etc/passwd
chown -R rx30:group /usr/rx30
cp /etc/skel/.bash_profile /usr/rx30
cp /etc/skel/.bashrc /usr/rx30
chown -R rx30:group /usr/rx30/.bash_profile /usr/rx30/excludes.conf /usr/rx30/.bashrc /usr/rx30/.kde /usr/rx30
chmod -R 775 /usr/rx30/.bash_profile /usr/rx30/excludes.conf /usr/rx30/.kde

if [ '!' -e /usr/rx30/prt2dsk ]
then cp -p /usr/bin/prt2dsk /usr/rx30
cp -p /usr/bin/prt2dsk.cnf /usr/rx30
chown rx30:group /usr/rx30/prt2dsk*
fi
# Make mount directories
mkdir /mnt/dvd /mnt/cdrom /mnt/floppy /mnt/usb
# adding mount point for usb backup stick with vol label
echo "LABEL=rx30usbbackup /mnt/usb ext3 user,rw,noauto 0 0" >>/etc/fstab

# Copy ltsp related stuff into place
#cp /opt/extras/rx30ltsp/Xsetup_workstation /etc/X11/xdm
#cp /opt/extras/rx30ltsp/rx30ltsp.jpg /etc/X11/xdm
#cp /opt/extras/rx30ltsp/kbd_mode /opt/ltsp/i386/bin
cp -R /opt/ltsp/i386/etc/sane.d /etc
mkdir -p /var/opt/ltsp/swapfiles

# copy luxi fonts into rx30
# seems to be the only fonts that work with gui rx30
cp /opt/ltsp/i386/usr/X11R6/lib/X11/fonts/TTF/* /usr/share/X11/fonts/TTF/

# Turn services on for filtering and jammins and misc networking

chkconfig --add ipfilter
chkconfig --add postfix
chkconfig dhcpd on
chkconfig nfs on
chkconfig vsftpd on
chkconfig ntpd on
chkconfig smb on
chkconfig xfs on
#Turn off System monitoring

chkconfig mdmonitor off
rm -rf /etc/cron.daily/0logwatch
chkconfig swatch off
#chkconfig swatch on

# Turn off un-needed services

chkconfig gpm off
chkconfig sendmail off
chkconfig smartd off
chkconfig hplip off
chkconfig nasd off
chkconfig iptables off
chkconfig ip6tables off
chkconfig postfix off
chkconfig NetworkManager off
# Change file modes for Misc RX30 purposes.

ln -s /usr/bin/xauth /usr/X11R6/xauth
chmod +x /usr/rx30/Desktop/RX30.desktop
chmod 4555 /usr/sbin/pppd
chown rx30 /etc/ppp/chap-*
chown rx30 /etc/ppp/pap-*
chmod -R 777 /etc/ppp
chmod -R 775 /usr/rx30
chmod 775 /usr/rx30/.bashrc
chown root /sbin/uugetty
chgrp root /sbin/uugetty
chmod 755 /sbin/uugetty
chmod 440 /etc/sudoers
chmod 700 /usr/bin/tdsconfig
cp /bin/ll_instl /usr/rx30
chown rx30 /usr/rx30/ll_instl
chmod 6711 /bin/ll_instl
chmod 6711 /bin/ll_tcpd
# location of dhcpd.conf changed in CentOS 6
mv /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.orig
ln -s /etc/dhcpd.conf /etc/dhcp/dhcpd.conf
ln -s /tftpboot/* /var/lib/tftpboot/
%end[/code]

again thanks for the help and guidance.

Post Reply