c526b9a13ac2623184a8293753176250816abc53
[live-boot-grml.git] / scripts / boot / arguments.sh
1 #!/bin/sh
2
3 #set -e
4
5 Arguments ()
6 {
7         PRESEEDS=""
8         LOCATIONS=""
9
10         for ARGUMENT in $(cat /proc/cmdline)
11         do
12                 case "${ARGUMENT}" in
13                         read-only)
14                                 READ_ONLY="true"
15                                 ;;
16
17                         skipconfig)
18                                 NOACCESSIBILITY="Yes"
19                                 NOFASTBOOT="Yes"
20                                 NOFSTAB="Yes"
21                                 NONETWORKING="Yes"
22
23                                 export NOACCESSIBILITY NOFASTBOOT NOFSTAB NONETWORKING
24                                 ;;
25
26                         access=*)
27                                 ACCESS="${ARGUMENT#access=}"
28                                 export ACCESS
29                                 ;;
30
31                         console=*)
32                                 DEFCONSOLE="${ARGUMENT#*=}"
33                                 export DEFCONSOLE
34                                 ;;
35
36                         BOOTIF=*)
37                                 BOOTIF="${x#BOOTIF=}"
38                                 ;;
39
40                         debug)
41                                 DEBUG="Yes"
42                                 export DEBUG
43
44                                 set -x
45                                 ;;
46
47                         dhcp)
48                                 # Force dhcp even while netbooting
49                                 # Use for debugging in case somebody works on fixing dhclient
50                                 DHCP="Force";
51                                 export DHCP
52                                 ;;
53
54                         nodhcp)
55                                 unset DHCP
56                                 ;;
57
58                         ethdevice=*)
59                                 DEVICE="${ARGUMENT#ethdevice=}"
60                                 ETHDEVICE="${DEVICE}"
61                                 export DEVICE ETHDEVICE
62                                 ;;
63
64                         ethdevice-timeout=*)
65                                 ETHDEV_TIMEOUT="${ARGUMENT#ethdevice-timeout=}"
66                                 export ETHDEV_TIMEOUT
67                                 ;;
68
69                         fetch=*)
70                                 FETCH="${ARGUMENT#fetch=}"
71                                 export FETCH
72                                 ;;
73
74                         findiso=*)
75                                 FINDISO="${ARGUMENT#findiso=}"
76                                 export FINDISO
77                                 ;;
78
79                         forcepersistencefsck)
80                                 FORCEPERSISTENCEFSCK="Yes"
81                                 export FORCEPERSISTENCEFSCK
82                                 ;;
83
84                         ftpfs=*)
85                                 FTPFS="${ARGUMENT#ftpfs=}"
86                                 export FTPFS
87                                 ;;
88
89                         httpfs=*)
90                                 HTTPFS="${ARGUMENT#httpfs=}"
91                                 export HTTPFS
92                                 ;;
93
94                         iscsi=*)
95                                 ISCSI="${ARGUMENT#iscsi=}"
96                                 #ip:port - separated by ;
97                                 ISCSI_PORTAL="${ISCSI%;*}"
98                                 if echo "${ISCSI_PORTAL}" | grep -q , ; then
99                                         ISCSI_SERVER="${ISCSI_PORTAL%,*}"
100                                         ISCSI_PORT="${ISCSI_PORTAL#*,}"
101                                 fi
102                                 #target name
103                                 ISCSI_TARGET="${ISCSI#*;}"
104                                 export ISCSI ISCSI_PORTAL ISCSI_TARGET ISCSI_SERVER ISCSI_PORT
105                                 ;;
106
107                         isofrom=*|fromiso=*)
108                                 FROMISO="${ARGUMENT#*=}"
109                                 export FROMISO
110                                 ;;
111
112                         ignore_uuid)
113                                 IGNORE_UUID="Yes"
114                                 export IGNORE_UUID
115                                 ;;
116
117                         integrity-check)
118                                 INTEGRITY_CHECK="Yes"
119                                 export INTEGRITY_CHECK
120                                 ;;
121
122                         ip=*)
123                                 STATICIP="${ARGUMENT#ip=}"
124
125                                 if [ -z "${STATICIP}" ]
126                                 then
127                                         STATICIP="frommedia"
128                                 fi
129
130                                 export STATICIP
131                                 ;;
132
133                         live-getty)
134                                 LIVE_GETTY="1"
135                                 export LIVE_GETTY
136                                 ;;
137
138                         live-media=*|bootfrom=*)
139                                 LIVE_MEDIA="${ARGUMENT#*=}"
140                                 export LIVE_MEDIA
141                                 ;;
142
143                         live-media-encryption=*|encryption=*)
144                                 LIVE_MEDIA_ENCRYPTION="${ARGUMENT#*=}"
145                                 export LIVE_MEDIA_ENCRYPTION
146                                 ;;
147
148                         live-media-offset=*)
149                                 LIVE_MEDIA_OFFSET="${ARGUMENT#live-media-offset=}"
150                                 export LIVE_MEDIA_OFFSET
151                                 ;;
152
153                         live-media-path=*)
154                                 LIVE_MEDIA_PATH="${ARGUMENT#live-media-path=}"
155                                 export LIVE_MEDIA_PATH
156                                 ;;
157
158                         live-media-timeout=*)
159                                 LIVE_MEDIA_TIMEOUT="${ARGUMENT#live-media-timeout=}"
160                                 export LIVE_MEDIA_TIMEOUT
161                                 ;;
162
163                         module=*)
164                                 MODULE="${ARGUMENT#module=}"
165                                 export MODULE
166                                 ;;
167
168                         netboot=*)
169                                 NETBOOT="${ARGUMENT#netboot=}"
170                                 export NETBOOT
171                                 ;;
172
173                         nfsopts=*)
174                                 NFSOPTS="${ARGUMENT#nfsopts=}"
175                                 export NFSOPTS
176                                 ;;
177
178                         nfsoverlay=*)
179                                 NFS_COW="${ARGUMENT#nfsoverlay=}"
180                                 export NFS_COW
181                                 ;;
182
183                         noaccessibility)
184                                 NOACCESSIBILITY="Yes"
185                                 export NOACCESSIBILITY
186                                 ;;
187
188                         nofastboot)
189                                 NOFASTBOOT="Yes"
190                                 export NOFASTBOOT
191                                 ;;
192
193                         nofstab)
194                                 NOFSTAB="Yes"
195                                 export NOFSTAB
196                                 ;;
197
198                         nonetworking)
199                                 NONETWORKING="Yes"
200                                 export NONETWORKING
201                                 ;;
202
203                         ramdisk-size=*)
204                                 ramdisk_size="${ARGUMENT#ramdisk-size=}"
205                                 ;;
206
207                         swapon)
208                                 SWAPON="Yes"
209                                 export SWAPON
210                                 ;;
211
212                         persistence)
213                                 PERSISTENCE="Yes"
214                                 export PERSISTENCE
215                                 ;;
216
217                         persistence-encryption=*)
218                                 PERSISTENCE_ENCRYPTION="${ARGUMENT#*=}"
219                                 export PERSISTENCE_ENCRYPTION
220                                 ;;
221
222                         persistence-media=*)
223                                 PERSISTENCE_MEDIA="${ARGUMENT#*=}"
224                                 export PERSISTENCE_MEDIA
225                                 ;;
226                         persistence-method=*)
227                                 PERSISTENCE_METHOD="${ARGUMENT#*=}"
228                                 export PERSISTENCE_METHOD
229                                 ;;
230
231                         persistence-path=*)
232                                 PERSISTENCE_PATH="${ARGUMENT#persistence-path=}"
233                                 export PERSISTENCE_PATH
234                                 ;;
235                         persistence-read-only)
236                                 PERSISTENCE_READONLY="Yes"
237                                 export PERSISTENCE_READONLY
238                                 ;;
239
240                         persistence-storage=*)
241                                 PERSISTENCE_STORAGE="${ARGUMENT#persistence-storage=}"
242                                 export PERSISTENCE_STORAGE
243                                 ;;
244
245                         persistence-subtext=*)
246                                 old_root_overlay_label="${old_root_overlay_label}-${ARGUMENT#persistence-subtext=}"
247                                 old_home_overlay_label="${old_home_overlay_label}-${ARGUMENT#persistence-subtext=}"
248                                 custom_overlay_label="${custom_overlay_label}-${ARGUMENT#persistence-subtext=}"
249                                 root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistence-subtext=}"
250                                 old_root_snapshot_label="${root_snapshot_label}-${ARGUMENT#persistence-subtext=}"
251                                 home_snapshot_label="${home_snapshot_label}-${ARGUMENT#persistence-subtext=}"
252                                 ;;
253
254                         nopersistence)
255                                 NOPERSISTENCE="Yes"
256                                 export NOPERSISTENCE
257                                 ;;
258
259                         noprompt)
260                                 NOPROMPT="Yes"
261                                 export NOPROMPT
262                                 ;;
263
264                         noprompt=*)
265                                 NOPROMPT="${ARGUMENT#noprompt=}"
266                                 export NOPROMPT
267                                 ;;
268
269                         quickusbmodules)
270                                 QUICKUSBMODULES="Yes"
271                                 export QUICKUSBMODULES
272                                 ;;
273
274                         preseed/file=*|file=*)
275                                 LOCATIONS="${ARGUMENT#*=} ${LOCATIONS}"
276                                 export LOCATIONS
277                                 ;;
278
279                         nopreseed)
280                                 NOPRESEED="Yes"
281                                 export NOPRESEED
282                                 ;;
283
284                         */*=*)
285                                 question="${ARGUMENT%%=*}"
286                                 value="${ARGUMENT#*=}"
287                                 PRESEEDS="${PRESEEDS}\"${question}=${value}\" "
288                                 export PRESEEDS
289                                 ;;
290
291                         showmounts)
292                                 SHOWMOUNTS="Yes"
293                                 export SHOWMOUNTS
294                                 ;;
295
296                         silent)
297                                 SILENT="Yes"
298                                 export SILENT
299                                 ;;
300
301                         todisk=*)
302                                 TODISK="${ARGUMENT#todisk=}"
303                                 export TODISK
304                                 ;;
305
306                         toram)
307                                 TORAM="Yes"
308                                 export TORAM
309                                 ;;
310
311                         toram=*)
312                                 TORAM="Yes"
313                                 MODULETORAM="${ARGUMENT#toram=}"
314                                 export TORAM MODULETORAM
315                                 ;;
316
317                         exposedroot)
318                                 EXPOSED_ROOT="Yes"
319                                 export EXPOSED_ROOT
320                                 ;;
321
322                         plainroot)
323                                 PLAIN_ROOT="Yes"
324                                 export PLAIN_ROOT
325                                 ;;
326
327                         skipunion)
328                                 SKIP_UNION_MOUNTS="Yes"
329                                 export SKIP_UNION_MOUNTS
330                                 ;;
331
332                         root=*)
333                                 ROOT="${ARGUMENT#root=}"
334                                 export ROOT
335                                 ;;
336
337                         union=*)
338                                 UNIONTYPE="${ARGUMENT#union=}"
339                                 export UNIONTYPE
340                                 ;;
341                 esac
342         done
343
344         # sort of compatibility with netboot.h from linux docs
345         if [ -z "${NETBOOT}" ]
346         then
347                 if [ "${ROOT}" = "/dev/nfs" ]
348                 then
349                         NETBOOT="nfs"
350                         export NETBOOT
351                 elif [ "${ROOT}" = "/dev/cifs" ]
352                 then
353                         NETBOOT="cifs"
354                         export NETBOOT
355                 fi
356         fi
357
358         if [ -z "${MODULE}" ]
359         then
360                 MODULE="filesystem"
361                 export MODULE
362         fi
363
364         if [ -z "${UNIONTYPE}" ]
365         then
366                 UNIONTYPE="aufs"
367                 export UNIONTYPE
368         fi
369
370         if [ -z "${PERSISTENCE_ENCRYPTION}" ]
371         then
372                 PERSISTENCE_ENCRYPTION="none"
373                 export PERSISTENCE_ENCRYPTION
374         elif is_in_comma_sep_list luks ${PERSISTENCE_ENCRYPTION}
375         then
376                 if ! modprobe dm-crypt
377                 then
378                         log_warning_msg "Unable to load module dm-crypt"
379                         PERSISTENCE_ENCRYPTION=$(echo ${PERSISTENCE_ENCRYPTION} | sed -e 's/\<luks,\|,\?luks$//g')
380                         export PERSISTENCE_ENCRYPTION
381                 fi
382
383                 if [ ! -x /lib/cryptsetup/askpass ] || [ ! -x /sbin/cryptsetup ]
384                 then
385                         log_warning_msg "cryptsetup in unavailable"
386                         PERSISTENCE_ENCRYPTION=$(echo ${PERSISTENCE_ENCRYPTION} | sed -e 's/\<luks,\|,\?luks$//g')
387                         export PERSISTENCE_ENCRYPTION
388                 fi
389         fi
390
391         if [ -z "${PERSISTENCE_METHOD}" ]
392         then
393                 PERSISTENCE_METHOD="snapshot,overlay"
394                 export PERSISTENCE_METHOD
395         fi
396
397         if [ -z "${PERSISTENCE_STORAGE}" ]
398         then
399                 PERSISTENCE_STORAGE="filesystem,file"
400                 export PERSISTENCE_STORAGE
401         fi
402 }