summaryrefslogtreecommitdiff
path: root/functions/defaults.sh
blob: e22ab9319d07223ec8809eedc18f8859f0094043 (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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
#!/bin/sh

# defaults.sh - handle default values
# Copyright (C) 2006-2007 Daniel Baumann <daniel@debian.org>
#
# live-helper comes with ABSOLUTELY NO WARRANTY; for details see COPYING.
# This is free software, and you are welcome to redistribute it
# under certain conditions; see COPYING for details.

set -e

Set_defaults ()
{
	## config/common

	# Setting mode
	if [ -z "${LH_MODE}" ]
	then
		LH_MODE="debian"
	fi

	# Setting package manager
	if [ -z "${LH_APT}" ]
	then
		LH_APT="aptitude"
	fi

	# Setting apt ftp proxy
	if [ -z "${LH_APT_FTPPROXY}" ] && [ -n "${ftp_proxy}" ]
	then
		LH_APT_FTPPROXY="${ftp_proxy}"
	else
		if [ -n "${LH_APT_FTPPROXY}" ] && [ "${LH_APT_FTPRPOXY}" != "${ftp_proxy}" ]
		then
			ftp_proxy="${LH_APT_FTPRPOXY}"
		fi
	fi

	# Setting apt http proxy
	if [ -z "${LH_APT_HTTPPROXY}" ] && [ -n "${http_proxy}" ]
	then
		LH_APT_HTTPPROXY="${http_proxy}"
	else
		if [ -n "${LH_APT_HTTPPROXY}" ] && [ "${LH_APT_HTTPRPOXY}" != "${http_proxy}" ]
		then
			http_proxy="${LH_APT_HTTPPROXY}"
		fi
	fi

	# Setting apt indices
	if [ -z "${LH_APT_GENERIC}" ]
	then
		LH_APT_GENERIC="enabled"
	fi

	# Setting apt pdiffs
	if [ -z "${LH_APT_PDIFFS}" ]
	then
		LH_APT_PDIFFS="enabled"
	fi

	# Setting apt recommends
	if [ -z "${LH_APT_RECOMMENDS}" ]
	then
		LH_APT_RECOMMENDS="enabled"
	fi

	# Setting apt secure
	if [ -z "${LH_APT_SECURE}" ]
	then
		LH_APT_SECURE="enabled"
	fi

	# Setting bootstrap program
	if [ -z "${LH_BOOTSTRAP}" ] || [ ! -x "${LH_BOOTSTRAP}" ]
	then
		case "${LH_MODE}" in
			debian)
				if [ -x "/usr/bin/cdebootstrap" ]
				then
					LH_BOOTSTRAP="cdebootstrap"
				elif [ -x "/usr/sbin/debootstrap" ]
				then
					LH_BOOTSTRAP="debootstrap"
				else
					echo "E: Can't process file /usr/bin/cdebootstrap or /usr/sbin/debootstrap (FIXME)"
					exit 1
				fi
			;;

			ubuntu)
				if [ -x "/usr/sbin/debootstrap" ]
				then
					if [ -f /usr/lib/debootstrap/scripts/feisty ]
					then
						LH_BOOTSTRAP="debootstrap"
					else
						echo "E: Your version of debootstrap does not support ubuntu."
						exit 1
					fi
				else
					echo "E: You need to install debootstrap from Ubuntu in order to bootstrap ubuntu."
					exit 1
				fi
				;;
		esac
	fi

	# Setting cache option
	if [ -z "${LH_CACHE}" ]
	then
		LH_CACHE="enabled"
	fi

	# Setting debconf frontend
	if [ -z "${LH_DEBCONF_FRONTEND}" ]
	then
		LH_DEBCONF_FRONTEND="noninteractive"
	fi

	if [ -z "${LH_DEBCONF_PRIORITY}" ]
	then
		LH_DEBCONF_PRIORITY="critical"
	fi

	# Setting genisoimage
	if [ -z "${LH_GENISOIMAGE}" ]
	then
		LH_GENISOIMAGE="genisoimage"
	fi

	# Setting losetup
	if [ -z "${LH_LOSETUP}" ] || [ ! -x "${LH_LOSETUP}" ]
	then
		# Check for loop-aes-utils divertion
		if [ -x /sbin/losetup.orig ]
		then
			LH_LOSETUP="losetup.orig"
		elif [ -x /sbin/losetup ]
		then
			LH_LOSETUP="losetup"
		else
			echo "E: Can't process file /sbin/losetup (FIXME)"
		fi
	fi

	# Setting root directory
	if [ -z "${LIVE_ROOT}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_ROOT="debian-live"
				;;

			ubuntu)
				LIVE_ROOT="ubuntu-live"
				;;
		esac
	fi

	# Setting live helper options
	if [ -z "${LH_BREAKPOINTS}" ]
	then
		LH_BREAKPOINTS="disabled"
	fi

	if [ -z "${LH_DEBUG}" ]
	then
		LH_DEBUG="disabled"
	fi

	if [ -z "${LH_FORCE}" ]
	then
		LH_FORCE="disabled"
	fi

	if [ -z "${LH_QUIET}" ]
	then
		LH_QUIET="disabled"
	fi

	if [ -z "${LH_VERBOSE}" ]
	then
		LH_VERBOSE="disabled"
	fi

	## config/bootstrap

	# Setting architecture value
	if [ -z "${LIVE_ARCHITECTURE}" ]
	then
		if [ -x "/usr/bin/dpkg" ]
		then
			LIVE_ARCHITECTURE="`dpkg --print-architecture`"
		else
			echo "E: Can't process file /usr/bin/dpkg (FIXME)"
		fi
	fi

	# Setting distribution value
	if [ -z "${LIVE_DISTRIBUTION}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_DISTRIBUTION="sid"
				;;

			ubuntu)
				LIVE_DISTRIBUTION="feisty"
				;;
		esac
	fi

	# Setting distribution configuration value
	# LIVE_BOOTSTRAP_CONFIG

	# Setting flavour value
	if [ -z "${LIVE_BOOTSTRAP_FLAVOUR}" ]
	then
			LIVE_BOOTSTRAP_FLAVOUR="standard"
	fi

	# Setting mirror to fetch packages from
	if [ -z "${LIVE_MIRROR_BUILD}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_MIRROR_BUILD="http://ftp.debian.org/debian/"
				;;

			ubuntu)
				LIVE_MIRROR_BUILD="http://archive.ubuntu.com/ubuntu/"
				;;
		esac
	fi

	# Setting security mirror to fetch packages from
	if [ -z "${LIVE_MIRROR_BUILD_SECURITY}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_MIRROR_BUILD_SECURITY="http://security.debian.org/"
				;;

			ubuntu)
				LIVE_MIRROR_BUILD_SECURITY="http://security.ubuntu.org/ubuntu/"
				;;
		esac
	fi

	# Setting mirror which ends up in the image
	if [ -z "${LIVE_MIRROR_IMAGE}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_MIRROR_IMAGE="http://ftp.debian.org/debian/"
				;;

			ubuntu)
				LIVE_MIRROR_IMAGE="http://archive.ubuntu.com/ubuntu/"
				;;
		esac
	fi

	# Setting security mirror which ends up in the image
	if [ -z "${LIVE_MIRROR_IMAGE_SECURITY}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_MIRROR_IMAGE_SECURITY="http://security.debian.org/"
				;;

			ubuntu)
				LIVE_MIRROR_IMAGE_SECURITY="http://security.ubuntu.com/ubuntu/"
				;;
		esac
	fi

	# Setting sections value
	if [ -z "${LIVE_SECTIONS}" ]
	then
		LIVE_SECTIONS="main"
	fi

	## config/chroot

	# Setting interactive shell/X11/Xnest
	if [ -z "${LIVE_INTERACTIVE}" ]
	then
		LIVE_INTERACTIVE="disabled"
	fi

	# Setting kernel flavour string
	if [ -z "${LIVE_KERNEL_FLAVOUR}" ]
	then
		case "${LIVE_ARCHITECTURE}" in
			alpha)
				LIVE_KERNEL_FLAVOUR="alpha-generic"
				;;

			amd64)
				case "${LH_MODE}" in
					debian)
						LIVE_KERNEL_FLAVOUR="amd64"
						;;

					ubuntu)
						LIVE_KERNEL_FLAVOUR="amd64-generic"
						;;
				esac
				;;

			arm)
				echo "E: You need to specify the linux kernel flavour manually on arm (FIXME)."
				exit 1
				;;

			hppa)
				LIVE_KERNEL_FLAVOUR="parisc"
				;;

			i386)
				case "${LH_MODE}" in
					debian)
						LIVE_KERNEL_FLAVOUR="486"
						;;

					ubuntu)
						LIVE_KERNEL_FLAVOUR="386"
						;;
				esac
				;;

			ia64)
				LIVE_KERNEL_FLAVOUR="itanium"
				;;

			m68k)
				LIVE_KERNEL_FLAVOUR="E: You need to specify the linux kernel flavour manually on m68k."
				exit 1
				;;

			powerpc)
				LIVE_KERNEL_FLAVOUR="powerpc"
				;;

			s390)
				LIVE_KERNEL_FLAVOUR="s390"
				;;

			sparc)
				case "${LH_MODE}" in
					debian)
						LIVE_KERNEL_FLAVOUR="sparc32"
						;;

					ubuntu)
						LIVE_KERNEL_FLAVOUR="sparc64"
						;;
				esac
				;;

			*)
				echo "E: Architecture notyet supported (FIXME)"
				;;
		esac
	fi

	# Set kernel packages
	if [ -z "${LIVE_KERNEL_PACKAGES}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_KERNEL_PACKAGES="linux-image-2.6 squashfs-modules-2.6 unionfs-modules-2.6"
				;;

			ubuntu)
				LIVE_KERNEL_PACKAGES="linux-image"
				;;
		esac

		if [ -n "${LIVE_ENCRYPTION}" ]
		then
			LIVE_KERNEL_PACKAGES="${LIVE_KERNEL_PACKAGES} loop-aes-modules-2.6"
		fi
	fi

	# Setting keyring packages
	# LIVE_KEYRING_PACKAGES

	# Setting language string
	# LIVE_LANGUAGE

	# Setting tasks
	# LIVE_TASKS

	# Setting packages string
	# LIVE_PACKAGES

	# Setting packages list string
	if [ -z "${LIVE_PACKAGES_LISTS}" ]
	then
		LIVE_PACKAGES_LISTS="standard"
	fi

	# Setting tasks string
	for LIST in ${LIVE_PACKAGES_LISTS}
	do
		case "${LIST}" in
			gnome-desktop)
				LIVE_PACKAGES_LISTS="`echo ${LIVE_PACKAGES_LISTS} | sed -e 's/gnome-desktop//'` standard-x11"
				LIVE_TASKS="`echo ${LIVE_TASKS} | sed -e 's/standard//' -e 's/laptop//' -e 's/gnome-desktop//' -e 's/desktop//'` standard laptop desktop gnome-desktop"
				;;

			kde-desktop)
				LIVE_PACKAGES_LISTS="`echo ${LIVE_PACKAGES_LISTS} | sed -e 's/kde-desktop//'` standard-x11"
				LIVE_TASKS="`echo ${LIVE_TASKS} | sed -e 's/standard//' -e 's/laptop//' -e 's/kde-desktop//' -e 's/desktop//'` standard laptop desktop kde-desktop"
				;;

			xfce-desktop)
				LIVE_PACKAGES_LISTS="`echo ${LIVE_PACKAGES_LISTS} | sed -e 's/xfce-desktop//'` standard-x11"
				LIVE_TASKS="`echo ${LIVE_TASKS} | sed -e 's/standard//' -e 's/laptop//' -e 's/xfce-desktop//' -e 's/desktop//'` standard laptop desktop xfce-desktop"
				;;
		esac
	done

	LIVE_PACKAGES_LISTS="`echo ${LIVE_PACKAGES_LISTS} | sed -e 's/  //g'`"
	LIVE_TASKS="`echo ${LIVE_TASKS} | sed -e 's/  //g'`"

	# Setting security updates option
	if [ -z "${LIVE_SECURITY}" ]
	then
		LIVE_SECURITY="enabled"
	fi

	# Setting symlink convertion option
	if [ -z "${LIVE_SYMLINKS}" ]
	then
		LIVE_SYMLINKS="disabled"
	fi

	# Setting sysvinit option
	if [ -z "${LIVE_SYSVINIT}" ]
	then
		LIVE_SYSVINIT="disabled"
	fi

	## config/image

	# Setting boot parameters
	# LIVE_BOOTAPPEND

	# Setting encryption
	# LIVE_ENCRYPTION

	# Setting username
	if [ -z "${LIVE_USERNAME}" ]
	then
		LIVE_USERNAME="user"
	fi

	# Setting hostname
	if [ -z "${LIVE_HOSTNAME}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_HOSTNAME="debian"
				;;

			ubuntu)
				LIVE_HOSTNAME="ubuntu"
				;;
		esac
	fi

	# Setting image type
	if [ -z "${LIVE_BINARY_IMAGE}" ]
	then
		LIVE_BINARY_IMAGE="iso"
	fi

	# Setting image type
	if [ -z "${LIVE_SOURCE_IMAGE}" ]
	then
		LIVE_SOURCE_IMAGE="generic"
	fi

	# Setting filesystem
	if [ -z "${LIVE_FILESYSTEM}" ]
	then
		LIVE_FILESYSTEM="squashfs"
	fi

	# Setting memtest86 option
	if [ -z "${LIVE_MEMTEST86}" ]
	then
		LIVE_MEMTEST86="enabled"
	fi

	# Setting iso volume
	if [ -z "${LIVE_ISO_VOLUME}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_ISO_VOLUME="Debian Live \`date +%Y%m%d\`"
				;;

			ubuntu)
				LIVE_ISO_VOLUME="Ubuntu Live \`date +%Y%m%d\`"
				;;
		esac
	fi

	# Setting netboot server address
	if [ -z "${LIVE_SERVER_ADDRESS}" ]
	then
		LIVE_SERVER_ADDRESS="192.168.1.1"
	fi

	# Setting netboot server path
	if [ -z "${LIVE_SERVER_PATH}" ]
	then
		case "${LH_MODE}" in
			debian)
				LIVE_SERVER_PATH="/srv/debian-live"
				;;

			ubuntu)
				LIVE_SERVER_PATH="/srv/ubuntu-live"
				;;
		esac
	fi

	# Setting source option
	if [ -z "${LIVE_SOURCE}" ]
	then
		LIVE_SOURCE="disabled"
	fi

	# Setting grub
	if [ -z "${LIVE_BOOTLOADER}" ]
	then
		LIVE_BOOTLOADER="syslinux"
	fi

	# Setting grub splash
	# LIVE_GRUB_SPLASH

	# Setting syslinux splash
	# LIVE_SYSLINUX_SPLASH

	# Setting includes
	if [ -z "${LIVE_INCLUDES}" ]
	then
		LIVE_INCLUDES="/usr/share/live-helper/includes"
	fi

	# Setting templates
	if [ -z "${LIVE_TEMPLATES}" ]
	then
		LIVE_TEMPLATES="/usr/share/live-helper/templates"
	fi
}