summaryrefslogtreecommitdiffstats
path: root/system-config/frontend/live-config-update
blob: 392cdba564c4324bf2ba11ab1502fc9300b4a4a5 (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
#!/bin/sh

## live-config(7) - System Configuration Components
## Copyright (C) 2006-2015 Daniel Baumann <mail@daniel-baumann.ch>
##
## This program 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

_DIRECTORY="${1:-/}"

if [ ! -e "${_DIRECTORY}" ]
then
	echo "E: cannot access ${_DIRECTORY}: No such directory."
	exit 1
fi

_DISTRIBUTION="${2:-$(lsb_release -is | tr [A-Z] [a-z] | sed -e 's| |-|g')}"
_RELEASE="${3:-$(lsb_release -cs | tr [A-Z] [a-z])}"

if ( [ -z "${_DISTRIBUTION}" ] || [ -z "${_RELEASE}" ] ) && [ ! -x "$(which lsb_release 2>/dev/null)" ]
then
	echo "E: lsb_release: command not found."
	echo "I: lsb_release can be obtained from:"
	echo "I:   http://www.linux-foundation.org/en/LSB"
	echo "I: On Debian based systems, lsb_release can be installed with:"
	echo "I:   sudo apt-get install lsb-release"
	exit 1
fi

case "${_DISTRIBUTION}" in
	debian)
		NOCOMPONENT="apport"

		LIVE_HOSTNAME="debian"
		LIVE_USERNAME="user"
		LIVE_USER_FULLNAME="Debian Live user"
		LIVE_USER_DEFAULT_GROUPS="audio cdrom dip floppy video plugdev netdev powerdev scanner bluetooth debian-tor"

		PROC_OPTIONS="onodev,noexec,nosuid"
		;;

	progress-linux)
		NOCOMPONENT="apport"

		LIVE_HOSTNAME="system"
		LIVE_USERNAME="user"
		LIVE_USER_FULLNAME="User"
		LIVE_USER_DEFAULT_GROUPS="audio cdrom dip floppy video plugdev netdev powerdev scanner bluetooth debian-tor sudo"

		PROC_OPTIONS="onodev,noexec,nosuid,hidepid=2"
		;;
esac

echo "Removing unused components for ${_DISTRIBUTION} (${_RELEASE})..."

for NOCOMPONENT in ${NOCOMPONENT}
do
	if ls "${_DIRECTORY}"/lib/live/config/*-"${NOCOMPONENT}" > /dev/null 2>&1
	then
		rm -f "${_DIRECTORY}"/lib/live/config/*-"${NOCOMPONENT}"
	fi
done

echo  "Setting specific defaults for ${_DISTRIBUTION} (${_RELEASE})..."

sed -i  -e "s|^LIVE_HOSTNAME=.*$|LIVE_HOSTNAME=\"${LIVE_HOSTNAME}\"|" \
	-e "s|^LIVE_USERNAME=.*$|LIVE_USERNAME=\"${LIVE_USERNAME}\"|" \
	-e "s|^LIVE_USER_FULLNAME=.*$|LIVE_USER_FULLNAME=\"${LIVE_USER_FULLNAME}\"|" \
	-e "s|^PROC_OPTIONS=.*$|PROC_OPTIONS=\"${PROC_OPTIONS}\"|" \
"${_DIRECTORY}/bin/live-config"