* [gentoo-dev] Simple batch install script
@ 2003-09-14 22:24 99% Vano D
0 siblings, 0 replies; 1+ results
From: Vano D @ 2003-09-14 22:24 UTC (permalink / raw
To: gentoo-dev
[-- Attachment #1: Type: text/plain, Size: 1021 bytes --]
Hi all,
I have written a simple automatic install script for myself and thought
someone else might find it usefull so here it goes.
The way to use it is to modify the variables at the beginning of the
script file (there are comments don't get scared already) to suit your
needs. Then grab a stage3 file, a portage snapshot, and ideally the bz2
packages listed in the file, if not it will emerge them anyway but will
obviously take longer. A copy of a kernel and modules also can be used
if you have one available. If not you can modify the script (it says how
inside the comments) so that it will use genkern to create a kernel and
modules.
The script doesnt do any fdisking as I did not need this. Nor does it
do any grubbing, although it installs grub and informs the user about
it.
Once you configure the options at the top of the script and if you have
all the required/optional files, the whole installation takes 5 mins.
Hope someone else finds this usefull.
--
Vano D <gentoo-dev@europeansoftware.com>
[-- Attachment #2: install.sh --]
[-- Type: text/x-sh, Size: 6854 bytes --]
#!/bin/bash
#install.sh : Automatic batch Gentoo installer.
#by Vano Dolukhanian (gentoo-dev@europeansoftware.com)
#http://gentoo-dev.europeansoftware.com
#
#This script uses a stage3 file and a portage snapshot to create a basic gentoo
# installation automatically. It still requires a pregenerated kernel and
# modules package, but this can be changed so that the kernel is generated
# using this script (See below). Also note that the script makes use of any
# packages from PACKAGES_DIR. These can be found on a GRP install or generated
# beforehand (See below for more info).
# NOTE: if you see broken pipe error messages and an error message regarding a
# command not found... don't worry. Seems to be a portage/ebuild problem.
#CHROOT is the directory where the system will be created.
# This directory has to exist.
CHROOT=./chroot
#STAGE is a stage 3 file and PORTAGE is a portage snapshot
STAGE=./stage3-x86-1.4-20030806.tar.bz2
PORTAGE=./portage-20030910.tar.bz2
#KERNEL is a precompiled kernel with modules. The script can compile a kernel
# if you comment line 90 and uncomment line 144. (FIX THIS to make it automatic)
KERNEL=./kernel-and-modules.bz2
#PACKAGES_DIR is the directory where tbz2 packages can be found. If no packages
# exist, the tarballs will be downloaded and compiled as per usual. But the
# directory PACKAGES_DIR needs to exist. (FIX THIS to make it automatic).
# The packages which will be installed are shown below. Having them
# precompiled will skip the need to download and compile them therefore
# streamlining the installation process.
#
# dcron-2.9.tbz2
# genkernel-1.7.tbz2
# gentoo-sources-2.4.20-r6.tbz2
# grub-0.93.20030118.tbz2
# hotplug-20030501-r2.tbz2
# libol-0.3.9.tbz2
# mailbase-0.00-r5.tbz2
# pciutils-2.1.11.tbz2
# ssmtp-2.48.tbz2
# syslog-ng-1.6.0_rc3.tbz2
# usbutils-0.11-r1.tbz2
PACKAGES_DIR=./packages
#Below are the fields used to configure the system... pretty self explanatory.
# note regarding ZONEINFO.. this is the directory/file under /usr/share/zoneinfo/
RESOLVE="nameserver 192.168.0.110\nnameserver 192.168.0.100"
MYUSE="-nls"
MYCFLAGS="-O2 -mcpu=i586"
ZONEINFO="Europe/Madrid"
ROOTPARTITION="hdb1"
SWAPPARTITION="hdb2"
USER="vano"
MYHOSTNAME="gentoo-test"
MYDOMAIN="europeansoftware.com"
MYIP="192.168.0.100"
MYGATEWAY="192.168.0.1"
MYKEYMAP="es"
MYCLOCK="local"
MYEDITOR="vim"
#### Configuration section ends here.
error () {
echo
echo "!!!! FAILED !!!!"
echo
exit
}
ok () {
echo "Done."
}
outside_chroot () {
echo -n "* Extracting $STAGE into chroot... "
tar xjpf $STAGE -C $CHROOT || error && \
ok
echo -n "* Extracting the Portage snapshot $PORTAGE into the chroot... "
tar xjpf $PORTAGE -C $CHROOT/usr/ || error && \
ok
echo -n "* Copying packages from $PACKAGES_DIR into the chroot... "
cp -r $PACKAGES_DIR $CHROOT/usr/portage/ || error && \
ok
echo -n "* Extracting kernel and modules into chroot... "
tar xjpf $KERNEL -C $CHROOT/ || error && \
ok
echo -n "* Mounting proc inside chroot... "
mount -t proc proc $CHROOT/proc || error && \
ok
echo -n "* Creating /etc/resolv.conf file inside chroot... "
echo -e $RESOLVE >$CHROOT/etc/resolv.conf || error && \
ok
echo "* Chrooting... "
(touch $CHROOT/inside_chroot && cp ./install.sh $CHROOT/ && chroot $CHROOT /install.sh) || error && \
ok
rm -Rf $CHROOT/install.sh
rm -Rf $CHROOT/inside_chroot
umount $CHROOT/proc
}
inside_chroot () {
env-update
source ./etc/profile
#echo "* Syncing portage tree..."
#emerge sync
echo -n "* Configuring /etc/make.conf... "
(cat ./etc/make.conf | sed "/#USE/{x;s/^/USE=\"$MYUSE\"/;x;g;}" > ./etc/make.conf.new && \
cat ./etc/make.conf.new | sed "/CFLAGS=\"-O3 -mcpu=i686 -funroll-loops -pipe\"/{x;s/^/CFLAGS=\"$MYCFLAGS\"/;x;g;}" > ./etc/make.conf) || error && \
ok
echo -n "* Using $ZONEINFO as timezone... "
ln -sf ./usr/share/zoneinfo/$ZONEINFO ./etc/localtime || error && \
ok
echo -n "* Configuring /etc/fstab with $ROOTPARTITION as / and $SWAPPARTITION as swap... "
echo -e >./etc/fstab "\
/dev/$ROOTPARTITION / ext3 noatime 1 1
/dev/$SWAPPARTITION none swap sw 0 0
proc /proc proc defaults 0 0
tmpfs /dev/shm tmpfs defaults 0 0
" || error && \
ok
echo "* Installing kernel sources... "
(emerge >/dev/null -k gentoo-sources && emerge >/dev/null -k genkernel) || error && \
ok
echo "* Installing/Compiling kernel and modules if kernel/modules not present... "
#genkernel || error && \
ok
echo "* Installing hotplug..."
emerge >/dev/null -k hotplug || error && \
ok
echo "* Installing syslog-ng..."
(emerge >/dev/null -k app-admin/syslog-ng && rc-update add syslog-ng default) || error && \
ok
echo "* Installing dcron..."
(emerge >/dev/null -k sys-apps/dcron && rc-update add dcron default && crontab ./etc/crontab) || error && \
ok
echo -n "* Adding user $USER..."
useradd $USER -m -G users,wheel,portage -s /bin/bash || error && \
ok
echo -n "* Creating /etc/hostname... "
echo $MYHOSTNAME > ./etc/hostname || error && \
ok
echo -n "* Creating /etc/dnsdomainname... "
echo $MYDOMAIN > ./etc/dnsdomainname || error && \
ok
echo -n "* Adding entry to /etc/hosts... "
echo "$MYIP $MYHOSTNAME.$MYDOMAIN $MYHOSTNAME" >> ./etc/hosts || error && \
ok
echo -n "* Configuring network... "
(cat ./etc/conf.d/net | sed "s:iface_eth0=\"192.168.0.2:iface_eth0=\"$MYIP:" >./etc/conf.d/net.new && \
cat ./etc/conf.d/net.new | sed "s:#gateway=\"eth0/192.168.0.1\":gateway=\"eth0/$MYGATEWAY\":" >./etc/conf.d/net && \
rc-update add net.eth0 default ) || error \
ok
echo -n "* Configuring /etc/rc.conf... "
(cat ./etc/rc.conf | sed "/KEYMAP=\"us\"/{x;s/^/KEYMAP=\"$MYKEYMAP\"/;x;g;}" > ./etc/rc.conf.new && \
cat ./etc/rc.conf.new | sed "/CLOCK=\"UTC\"/{x;s/^/CLOCK=\"$MYCLOCK\"/;x;g;}" > ./etc/rc.conf && \
cat ./etc/rc.conf | sed "/EDITOR=\"\/bin\/nano\"/{x;s/^/EDITOR=\"\/bin\/$MYEDITOR\"/;x;g;}" > ./etc/rc.conf.new && \
mv -f ./etc/rc.conf.new ./etc/rc.conf) && \
ok
echo "* Installing grub... "
emerge >/dev/null -k grub || error && \
ok
echo "* Running etc-update... "
etc-update || errror && \
ok
echo -n "> Please supply password for root - "
passwd
echo "*** Finished."
echo "*** Please configure $CHROOT/etc/boot/grub/grub.conf and run grub manually ***"
echo "*** Add any network modules you might need to $CHROOT/etc/modules.autoload.d/kernel-2.4 ***"
echo "*** Reboot into the new system when finished doing the above :)"
}
if [ `whoami` != "root" ]; then
echo "Only root can run this script... "
exit;
fi
if [ -f /inside_chroot ]; then
inside_chroot
else
outside_chroot
fi
[-- Attachment #3: Type: text/plain, Size: 37 bytes --]
--
gentoo-dev@gentoo.org mailing list
^ permalink raw reply [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2003-09-14 22:24 99% [gentoo-dev] Simple batch install script Vano D
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox