source: drbl-hadoop-live/hadoop-live-hook

Last change on this file was 160, checked in by jazz, 14 years ago
  • modified hadoop-live-hook
    • install hadoop pipe as default
  • modified test-live-helper.sh
    • remove binary-hook since it is not used now
  • Property svn:executable set to *
File size: 10.2 KB
Line 
1#!/bin/bash
2# Author: Steven Shiau <steven _at_ nchc org tw>
3# License: GPL
4# Program to create DRBL/Clonezilla server live. You'd better to have 2 or more NICs in the machine, and they are configured so the created Clonezilla server live has preset DRBL environment.
5
6#
7DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/opt/drbl/}"
8
9# load drbl setting
10. $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
11# load config files
12. /live-hook-dir/ocs-live-hook.conf
13# load functions
14. /live-hook-dir/ocs-live-hook-functions
15
16# locale_to_keep_for_X is loaded from ocs-live-hook.conf.
17locale_to_keep="$locale_to_keep_for_X"
18
19#
20clean_udev_persistent_net_rules
21
22# create a dummy /etc/fstab in Live CD so that nis/yp won't complain
23touch /etc/fstab
24
25#
26download_grub_1_2_deb_for_later_use
27
28#
29install_debian_extra_modules
30
31# clean some locales
32set_localepurge
33localepurge
34
35# Generate the locales. We will use "nolocales" to avoid these to be wipped by live-initramfs.
36locales_gen
37
38# If kexec tools is installed, disable the service. We do not need that for Clonezilla
39disable_kexec
40
41# Disable the "tips and tricks" on the startup after login.
42disable_xfce_startup_tips_and_tricks
43
44# Exclude live mount point in /etc/init.d/umountfs to avoid error messages when rebooting or halting.
45exclude_umount_live_mnt_point_in_umountfs
46
47# append the module so that it will be loaded, then gparted can grow filesystem
48# Ref: http://gparted.sourceforge.net/features.php
49append_mod_in_etc_modules
50
51# set root passwd, I do not like root without passwd.
52set_root_passwd
53
54# Append the PATH in system.
55append_drbl_clonezilla_PATH_in_system
56
57# We might need more /lib/udev/*_id than that initramfs-tools copies. E.g. for Live CD, we need cdrom_id, which udev (>= version 146 won't copy).
58copy_all_dev_id_prog_from_udev_lib
59
60# Put the DRBL live script in rcS.d
61cp_drbl_live_startup_to_rc.d
62
63# If mlterm is found with xfce installed, set default x-terminal-emulator as mlterm. Since xterm is not as good as mlterm in Traditional Chinese font.
64if dpkg -L xfce4 &>/dev/null && dpkg -L mlterm &>/dev/null; then
65  echo "Set mlterm as default x-terminal-emulator."
66  update-alternatives --set x-terminal-emulator /usr/bin/mlterm
67  # change the fg/bg color
68  perl -pi -e "s/^.*fg_color=.*/fg_color=white/g" /etc/mlterm/main
69  perl -pi -e "s/^.*bg_color=.*/bg_color=black/g" /etc/mlterm/main
70fi
71
72# We have to remove thunar-volman to avoid the partition is automatically mounted after a partition table is created. It will make Clonezilla fail due to partition busy.
73if dpkg -L thunar-volman &>/dev/null; then
74  apt-get -y --purge remove thunar-volman
75fi
76
77# preset some network setting
78guess_uplink_port="$(LC_ALL=C route -n | awk '/^0.0.0.0/ {print $8}' | sort | head -n 1)"
79case "$alias_eth0_for_drbl_clients" in
80  yes)
81    ethernet_drbl="eth0:1"
82    ifconfig $ethernet_drbl $alias_eth0_IP_addr netmask 255.255.255.0
83    ;;
84esac
85
86# Clear those automatically installed.
87if [ -n "$(LC_ALL=C apt-get --help 2>/dev/null | grep -i autoremove)" ]; then
88  apt-get -y autoremove
89fi
90
91# We need loopback device, just in case.
92cat <<-NET_END > /etc/network/interfaces
93# This file describes the network interfaces available on your system
94# and how to activate them. For more information, see interfaces(5).
95
96# The loopback network interface
97auto lo
98iface lo inet loopback
99
100NET_END
101# Assign a default DNS
102# //NOTE// This won't work since live helper will remove /etc/resolv.conf.
103# Therefore here we comment this. To leave this in to make a note only.
104#assing_default_dns_server
105
106# Run drbl setup, we use DRBL SSI mode and clonezilla box mode
107if [ "$use_unfs" = "yes" ]; then
108  # Since unfs3 does not allow client to lock file, according to Pascal Schmidt <pascal.schmidt _at_ ewetel net>, we have to put "nolock" in client's /etc/fstab
109  perl -pi -e "s/^nfs_client_extra_opt=.*/nfs_client_extra_opt=nolock/g" $DRBL_SCRIPT_PATH/conf/drbl.conf
110fi
111
112# Change the VOL_LIMIT_DEFAULT as 2000 since we have no idea if user will mount FAT as $ocsroot or not.
113
114perl -pi -e 's/^VOL_LIMIT_DEFAULT=.*/VOL_LIMIT_DEFAULT="2000"  # Modified when creating DRBL live/g' $DRBL_SCRIPT_PATH/conf/drbl-ocs.conf
115
116# Get the installed kernel so that we can use drblsrv-offline directly.
117kernel_ver="$(unalias ls 2>/dev/null; ls /boot/vmlinuz-* | sort | tail -n 1)"
118kernel_ver="$(basename $kernel_ver | sed -e "s/vmlinuz-//g")"
119yes "" | drblsrv-offline -c -l en_US -s "$kernel_ver"
120
121# NOTE! All the setting about clients must be done before drblpush.
122# Run drblpush, now we use 1 for drbl client. The cient number is assigned in ocs-live-hook.conf and is applied to drbl-live.sh (it is run to start drbl service after the live cd is booted).
123yes "" | drblpush -l en_US -i -r 1 -z 1 -p 1 --not-add-start-drbl-srvi
124
125# post process
126# The /tftpboot/node_root/bin/hostname was renamed as hostname.orig by lh_chroot_hostname. Although later lh_chroot will deconfigure it, but we already copy them to /tftpboot/node_root/bin by drblpush. We have to move it back so that later drbl client can use the real hostname.
127mv -f $drbl_common_root/bin/hostname.orig $drbl_common_root/bin/hostname
128
129# stop all the services so that make-live can pack it.
130drbl-all-service stop
131
132# remove all the service in rc, we do not want all the services to automatically start at boot
133drbl-all-service del
134
135# we still have to add some modules in clients. We still have to do this although server's /etc/modules already has them, but drblpush will clean all to avoid some problem.
136for ih in $drblroot/*; do
137  for imod in $mod_loaded_at_startup; do
138    echo "$imod" >> $ih/etc/modules
139  done
140done
141
142# we clean the template node and tarballs: (1) save the space (2) if user uses different subnet for NIC, the template directory (Ex: /tftpboot/nodes/192.168.100.1) and tarball are useless. Since we will re-run drblpush in drbl-live.sh after drbl live boots. They will be created again.
143[ -d "$drblroot" -a -n "$drblroot" ] && rm -rf $drblroot/*
144[ -d "$drbl_common_root" -a -n "$drbl_common_root" ] && rm -rf $drbl_common_root/drbl_ssi/*.tgz
145
146# //NOTE// This is almost useless since squashfs will compress the file system, and the duplicated won't take too much space actully. Besides, without /tftpboot/node_root/{lib, usr}, DRBL will need more RAM (need by tmpfs) after running drblpush -i.
147# Remove /tftpboot/node_root/{lib, usr}, since when drblpush is run, they will be rebuild. Thanks to Orgad Shaneh for the inspiration. Ref: https://sourceforge.net/forum/forum.php?thread_id=3336278&forum_id=675794
148#[ -d "$drbl_common_root/lib" -a -n "$drbl_common_root" ] && rm -rf $drbl_common_root/lib
149#[ -d "$drbl_common_root/usr" -a -n "$drbl_common_root" ] && rm -rf $drbl_common_root/usr
150
151# Note! there is an issue about squashfs 3.1 + kernel nfs, we can use user space nfs instead:
152# http://lists.alioth.debian.org/pipermail/debian-live-devel/2006-September/000470.html
153# This also has a benefit, the mounted /home/partimage is ready to be seen by client.
154# Before --purge nfs-kernel-server, we have to backup /etc/exports
155if [ "$use_unfs" = "yes" ]; then
156  cp -f /etc/exports /etc/exports.unfs3
157  apt-get --yes --purge remove nfs-kernel-server
158  apt-get --yes install unfs3
159  mv -f /etc/exports.unfs3 /etc/exports
160fi
161
162# do some dirty clean... no idea why "/etc/init.d/nfs-kernel-server stop" and "/"/etc/init.d/nfs-common stop" won't be able to release this:
163# nfsd on /proc/fs/nfsd type nfsd (rw)
164umount nfsd
165
166# get unifont.bgf for bterm, this is used in drbl live standard version.
167# This must be after drblsrv is run, since after that, we have clonezilla (so drbl-ocs.conf exists)
168(
169  # now with clonezilla installed, we can load variable $DEBIAN_ISO_ETC_PATH_DEF
170  . $DRBL_SCRIPT_PATH/conf/drbl-ocs.conf
171  uni_font_url="$DEBIAN_ISO_ETC_PATH_DEF/fonts/$uni_font_file"
172  echo "Download unifont.bgf from $uni_font_url and put it in $DRBL_SCRIPT_PATH/lib/..."
173  mkdir -p $DRBL_SCRIPT_PATH/lib/
174  cd $DRBL_SCRIPT_PATH/lib/
175  wget $wget_opt $uni_font_url
176)
177
178# For better security. This has to be after "drblsrv -i" and "drblpush -i" are run.
179echo "For better security, do not turn on ssh service..."
180remove_service_in_system ssh
181
182# Turn of boinc client service
183remove_service_in_system boinc-client
184
185# Remove unnecessary service
186remove_service_in_system mdadm-raid
187
188# Put start script
189mkdir -p /etc/drbl/
190cp -ar $DRBL_SCRIPT_PATH/setup/files/ocs/drbl-live.d /etc/drbl/
191
192# put some desktop icons in the account $autologin_account.
193mkdir -p /home/$autologin_account/Desktop
194chown -R $autologin_account.$autologin_account /home/$autologin_account/Desktop
195cp -a $DRBL_SCRIPT_PATH/setup/files/misc/desktop-icons/drbl-live/*.desktop /home/$autologin_account/Desktop
196chown $autologin_account.$autologin_account /home/$autologin_account/Desktop/*.desktop
197
198# Now we use S97start-drbl-live to do more, instead of just kbd config.
199# Put a service to config keyboard
200# cat <<-KBD_END > /etc/init.d/kbd-conf
201# #!/bin/bash
202# dpkg-reconfigure console-data
203# KBD_END
204# chmod 755 /etc/init.d/kbd-conf
205# update-rc.d kbd-conf start 97 S .
206
207# Put a service to config X
208# Since X 7.3 or later from Debian lenny, "dpkg-reconfigure xserver-xorg" only configure keyboard, no more VGA driver and resolution. We use grandr to let user to change the resolution. The problem will be if it fails to enter vesa mode, grander won't be able to run.
209# Ref: http://forums.debian.net/viewtopic.php?t=26577
210#cp -a $drbl_setup_path/files/ocs/live-hook/Forcevideo-drbl-live /etc/init.d/
211#update-rc.d Forcevideo-drbl-live start 98 S .
212
213# Put a link for vol_id so that GParted can use it to read linux-swap labels
214if [ -e /lib/udev/vol_id ]; then
215  (cd /sbin; ln -fs /lib/udev/vol_id vol_id)
216fi
217
218# we need real /sbin/start-stop-daemon
219remove_cdebootstrap-helper-diverts
220
221# turn off alias IP address
222[ "$alias_eth0_for_drbl_clients" = "yes" ] && ifconfig eth0:1 down
223
224# install sun-java6-jdk
225cat << EOF | /usr/bin/debconf-set-selections
226sun-java6-bin   shared/accepted-sun-dlj-v1-1    select true
227sun-java6-jdk   shared/accepted-sun-dlj-v1-1    select true
228sun-java6-jre   shared/accepted-sun-dlj-v1-1    select true
229EOF
230apt-get -y install sun-java6-jdk
231
232# install cloudera hadoop package (CHD2)
233apt-get -y install hadoop-0.20 hadoop-0.20-pipes hadoop-0.20-conf-pseudo
234
235# ///Note/// This should be the last one after any apt-get.
236# clean unnecessary backup file to save space
237clean_unnecessary_backup_file_in_boot
238
239### THE END ###
240# DO NOT PUT ANY SCRIPT AFTHER THIS!!!
241# kill this program before creating squashfs filesystem.
242rm -rf /live-hook-dir
Note: See TracBrowser for help on using the repository browser.