Releasing debian version 2.0~a4-1.
[live-config.git] / scripts / config.sh
1 #!/bin/sh
2
3 set -e
4
5 # Defaults
6 LIVE_HOSTNAME="debian"
7 LIVE_USERNAME="user"
8 LIVE_USER_FULLNAME="Debian Live user"
9
10 Cmdline ()
11 {
12 for _PARAMETER in $(cat /proc/cmdline)
13 do
14 case "${_PARAMETER}" in
15 live-config)
16 # Run all scripts
17 _SCRIPTS="$(ls /lib/live/config/*)"
18 ;;
19
20 live-config=*)
21 # Only run requested scripts
22 LIVE_CONFIGS="${_PARAMETER#live-config=}"
23 ;;
24
25 live-noconfig)
26 # Don't run any script
27 _SCRIPTS=""
28 ;;
29
30 live-noconfig=*)
31 # Don't run requested scripts
32 _SCRIPTS="$(ls /lib/live/config/*)"
33 LIVE_NOCONFIGS="${_PARAMETER#live-noconfig=}"
34 ;;
35
36 # 001-hostname
37 live-config.hostname=*)
38 LIVE_HOSTNAME="${_PARAMETER#live-config.hostname=}"
39 ;;
40
41 # 002-user-setup
42 live-config.username=*)
43 LIVE_USERNAME="${_PARAMETER#live-config.username=}"
44 ;;
45
46 live-config.user-fullname=*)
47 LIVE_USER_FULLNAME="${_PARAMETER#live-config.user-fullname=}"
48 ;;
49
50 # 004-locales
51 live-config.locales=*)
52 LIVE_LOCALES="${_PARAMETER#live-config.locales=}"
53 ;;
54
55 # 005-tzdata
56 live-config.timezone=*)
57 LIVE_TIMEZONE="${_PARAMETER#live-config.timezone=}"
58 ;;
59
60 live-config.utc=*)
61 LIVE_UTC="${_PARAMETER#live-config.utc=}"
62 ;;
63
64 # 999-hook
65 live-config.hook=*)
66 LIVE_HOOK="${_PARAMETER#live-config.hook=}"
67 ;;
68
69 # Shortcuts
70 live-config.noroot)
71 # Disable root access, no matter what mechanism
72 _SCRIPTS="${_SCRIPTS:-$(ls /lib/live/config/*)}"
73 LIVE_NOCONFIGS="${LIVE_NOCONFIGS},sudo,policykit"
74 ;;
75
76 live-config.noxlogin)
77 # Disables graphical autologin, no matter what
78 # mechanism
79 _SCRIPTS="${_SCRIPTS:-$(ls /lib/live/config/*)}"
80 LIVE_NOCONFIGS="${LIVE_NOCONFIGS},gdm,gdm3,kdm,lxdm,nodm"
81 ;;
82 esac
83 done
84
85 # Include requested scripts
86 if [ -n "${LIVE_CONFIGS}" ]
87 then
88 for LIVE_CONFIG in $(echo ${LIVE_CONFIGS} | sed -e 's|,| |g')
89 do
90 _SCRIPTS="${_SCRIPTS} $(ls /lib/live/config/???-${LIVE_CONFIG})"
91 done
92 fi
93
94 # Exclude requested scripts
95 if [ -n "${LIVE_NOCONFIGS}" ]
96 then
97 for LIVE_NOCONFIG in $(echo ${LIVE_NOCONFIGS} | sed -e 's|,| |g')
98 do
99 _SCRIPTS="$(echo ${_SCRIPTS} | sed -e "s|$(ls /lib/live/config/???-${LIVE_NOCONFIG})||")"
100 done
101 fi
102 }
103
104 Trap ()
105 {
106 _RETURN="${?}"
107
108 case "${_RETURN}" in
109 0)
110
111 ;;
112
113 *)
114 echo ":ERROR"
115 ;;
116 esac
117
118 return ${_RETURN}
119 }
120
121 Main ()
122 {
123 if ! grep -qs "boot=live" /proc/cmdline
124 then
125 exit 0
126 fi
127
128 echo -n "live-config:"
129 trap 'Trap' EXIT HUP INT QUIT TERM
130
131 # Reading configuration file from filesystem
132 if [ -e /etc/live/config.conf ]
133 then
134 . /etc/live/config.conf
135 fi
136
137 if ls /etc/live/config.conf.d/* > /dev/null 2>&1
138 then
139 for _FILE in /etc/live/config.conf.d/*
140 do
141 . ${_FILE}
142 done
143 fi
144
145 # Reading configuration file from live-media
146 if [ -e /live/image/live/config.conf ]
147 then
148 . /live/image/live/config.conf
149 fi
150
151 if ls /live/image/live/config.conf.d/* > /dev/null 2>&1
152 then
153 for FILE in /live/image/live/config.conf.d/*
154 do
155 . ${_FILE}
156 done
157 fi
158
159 # Reading kernel command line
160 Cmdline
161
162 # Configuring system
163 for _SCRIPT in ${_SCRIPTS}
164 do
165 . ${_SCRIPT}
166 done
167
168 echo "."
169 }
170
171 Main