summaryrefslogtreecommitdiffstats
path: root/contrib/cloner/base.cfg
blob: d4b1ee6ba3d1fc2d581be8ba41a1658a2b9c600c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# this is a livecd config developed by Andrew Brown <ambrown4@ncsu.edu> for saving
# and loading drive images to NFS locations, all based on kernel arguments.  This is
# for use with livecd creator.

lang en_US.UTF-8
keyboard us
timezone US/Eastern
auth --useshadow --enablemd5
selinux --disabled
firewall --disabled
rootpw --iscrypted \$1\$mF86/UHC\$WvcIcX2t6crBz2onWxyac.
services --disable sshd

# TODO: how to replace i386 with $basearch

# TODO: apparently calling it fedora-dev instead of a-dev makes things
# not work. Perhaps it has something to do with the default repos in
# /etc/yum.repos.d not getting properly disabled?

repo --name=todos --baseurl=http://download.fedora.redhat.com/pub/fedora/linux/releases/9/Everything/i386/os/
repo --name=updatez --baseurl=http://download.fedora.redhat.com/pub/fedora/linux/updates/9/i386/

text
bootloader --location=mbr
install
zerombr

part / --fstype ext3 --size=1024 --grow --ondisk=/dev/sda --asprimary
part swap --size=1027 --ondisk=/dev/sda --asprimary

%packages
@base
#@core
@hardware-support
file
syslinux
kernel
bash
util-linux
#koan
avahi-tools
#aspell-*
-m17n-db-*
-man-pages-*
# gimp help is huge
-gimp-help
# lose the compat stuff
-compat*
# space sucks
-gnome-user-docs
-specspo
-esc
-samba-client
-a2ps
-vino
-redhat-lsb
-sox
# smartcards won't really work on the livecd.  and we _need_ space
-coolkey
-ccid
# duplicate functionality
-tomboy
-pinfo
-wget
# scanning takes quite a bit of space :/
-xsane
-xsane-gimp
# while hplip requires pyqt, it has to go
-hplip
#-*debuginfo # error
kernel
bash
koan
policycoreutils
grub
eject
tree

%post

cat > /etc/rc.d/init.d/fedora-live << EOF
#!/bin/bash
#
# live: Init script for live image
#
# chkconfig: 345 99 99

# description: Init script for live image.

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

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

touch /.liveimg-configured

echo "RUN_FIRSTBOOT=NO" > /etc/sysconfig/firstboot

useradd -c "Fedora Live" fedora
passwd -d fedora > /dev/null
echo "fedora   ALL=(ALL)   ALL" >> /etc/sudoers

# don't start cron/at as they tend to spawn things which are
# disk intensive that are painful on a live image
/sbin/chkconfig crond off
/sbin/chkconfig atd off
/sbin/chkconfig anacron off
/sbin/chkconfig readahead_early off
/sbin/chkconfig readahead_later off

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

# PUT CUSOTMIZATIONS HERE
mkdir -p /mnt/nfs

cat << EOFpython > /tmp/imaging.py
import subprocess
import sys
import os
try:
   # iglob is new in 2.5, iterator version of glob
   from glob import iglob as glob
except ImportError:
   from glob import glob

def call(cmd, fail=True):
   print "+",cmd
   ret = subprocess.call(cmd, shell=True)
   if fail and ret:
      sys.exit("Halting script, %r returned %s" % (cmd, ret))
   return ret

print "Beginning imaging script"

args = open("/proc/cmdline",'r').read().split()
nfspath = ""
imagename = ""
drivelist = [] 
action = ""
for a in args:
   if a.startswith("nfs="):
      nfspath = a.split("=",1)[1]
   if a.startswith("image="):
      imagename = a.split("=",1)[1]
   if a.startswith("drive="):
      drivelist.append(a.split("=",1)[1])
   if a == "load":
      action = "load"
   if a == "save":
      action = "save"

if not (nfspath and imagename and drivelist and action):
   sys.exit("Not all arguments given")

fullpath = os.path.join("/mnt/nfs", imagename)

print "Mounting nfs dir %s" % nfspath
ret = call("mount %s /mnt/nfs" % nfspath)
if ret:
   sys.exit("Couldn't mount")

# Make the directory where we'll save everything
call("mkdir -p %s" % fullpath)

if action == "save":
   print "Deleting any existing entries"
   call("rm -f -- %s" % os.path.join(fullpath, "*"))

   for drivenum, drive in enumerate(drivelist):
      # Save off mbr and the data between mbr and the first partition
      # in case grub stuck a stage 1.5 bootloader there.
      print "Saving mbr..."
      mbrpath = os.path.join(fullpath, "%s.mbr" % drivenum)
      sfdiskpath = os.path.join(fullpath, "%s.sfdisk" % drivenum)
      call("dd if=%s of=%s bs=512 count=63" % (drive, mbrpath))

      # Save off extended partition information
      print "Saving extended partition info..."
      call("sfdisk %s -d > %s" % (drive, sfdiskpath))

      for partition in os.popen("sfdisk -l %s" % drive, 'r').readlines():
         if not partition.startswith(drive):
            continue

         # ex: /dev/sda1
         partdevice = partition.split()[0]

         # ex: 1
         partnum = partdevice[len(drive):]

         # ex: Linux, Extended, Win95...
         parttype = partition.split()[-1]

         # Decide what to do depending on parttype...
         if parttype in ("Empty", "Extended"):
            continue

         # for now, everything is dd
         print "Saving %s" % partdevice
         partimagepath = os.path.join(fullpath, "%s.%s" % (drivenum, partnum))
         call("dd if=%s of=%s conv=sync,noerror" % (partdevice, partimagepath))

   print "Finished saving.  Rebooting"
   #call("/sbin/shutdown -r now")
   print "(would normally reboot here)"

elif action == "load":
   for drivenum, drive in enumerate(drivelist):
      print "Restoring partition info for %s" % drive

      mbrpath = os.path.join(fullpath, "%s.mbr" % drivenum)
      sfdiskpath = os.path.join(fullpath, "%s.sfdisk" % drivenum)

      call("dd if=%s of=%s" % (mbrpath, drive))
      call("sfdisk %s < %s" % (drive, sfdiskpath))

      call("sfdisk %s -R" % drive)
      for partpath in glob(os.path.join(fullpath, "%s.*" % drivenum)):
         # partpath is full path to partition file on nfs mount
         # ex: /export/blade1/0.1

         # partfile ex: 0.1
         partfile = os.path.split(partpath)[-1]

         # partnum ex: 1
         partnum = partfile.split(".")[-1]
         if partnum in ("mbr", "fdisk") or not partnum.isdigit():
            continue
         
         partition = drive + partnum
         print "Restoring %s" % partition

         # Don't exit if dd "fails", dd returns 1 here because device runs
         # out of room even if it fits perfectly apparently

         call("dd if=%s of=%s" % (partpath, partition))

   print "Finished loading image.  Rebooting"
   #call("/sbin/shutdown -r now")
   print "(would reboot here normally)"

else:
   print "NO ACTION SPECIFIED"

print "Exiting imaging script"
EOFpython

python /tmp/imaging.py &

EOF

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

# Turn off more unneeded stuff
/sbin/chkconfig bluetooth off
/sbin/chkconfig sendmail off

# save a little bit of space at least...
rm -f /boot/initrd*

# Turn off virtual console on tty1
sed -i "s|/sbin/mingetty tty1|/bin/sleep 9999|" /etc/event.d/tty1

%end