summaryrefslogtreecommitdiffstats
path: root/system-config/examples/live-config-foobar/components/9000-foobar
blob: 136943b941df30efa62a5478bc20c0cf74e6c207 (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
#!/bin/sh

## live-config-foobar(7) - Additional Configuration Components for live systems
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
## Copyright (C) 2015 John Doe <john@example.org>
##
## live-config-foobar 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

Cmdline ()
{
	# Boot parameters can be acted up either this way...
	if ! echo ${LIVE_CONFIG_CMDLINE} | grep -qs "example.foobar" && \
	   ! echo ${LIVE_CONFIG_CMDLINE} | grep -qs "foobar"
	then
		return
	fi

	# ...or if you want to specify certain options:
	for _PARAMETER in ${LIVE_CONFIG_CMDLINE}
	do
		case "${_PARAMETER}" in
			example.foobar=*|foobar=*)
				EXAMPLE_FOOBAR="${_PARAMETER#*foobar=}"
				;;
		esac
	done
}

Init ()
{
	# Checking if package is installed or already configured
	if [ ! -e /var/lib/dpkg/info/foobar.list ] || \
	   [ -e /var/lib/live/config/foobar ]
	then
		exit 0
	fi

	echo -n " foobar"
}

Config ()
{
	# Configuring foobar either this way...
	if [ -n "${EXAMPLE_FOOBAR}" ]
	then
		sleep 1
	fi

	# ...or if you want to specify certain options:
	case "${EXAMPLE_FOOBAR}" in
		foo)
			sleep 1
			;;
	esac

	# Creating state file
	touch /var/lib/live/config/foobar
}

Cmdline
Init
Config