forked from hastho/pigeos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpigeos-config
executable file
·624 lines (590 loc) · 19.7 KB
/
pigeos-config
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
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
#!/bin/bash
# This script allows the user to configure Pi/GEOS in an easy manner
#
# While in the UI only values in the pigeos user config file are altered.
# When the user saves the configuration it will applied by caling pigoes-setup
# or when pigeos-loder determinates the paramters for DOSBox.
#
# see also: pigeos-loader, pigeos-setup
DEBUG=0
CONFIG=$HOME/.pigeos
SN=$(cat /sys/firmware/devicetree/base/serial-number | sed 's/\x0//')
DIAL=$(which whiptail || which dialog)
source ${CONFIG}
BTITLE="Pi/GEOS SETUP configuration tool $PIGEOS_VER (Pi S/N:$SN)"
declare -A FONT=(\
[tiny]=/usr/share/consolefonts/Uni2-TerminusBoldVGA14.psf.gz \
[small]=/usr/share/consolefonts/Uni2-TerminusBold20x10.psf.gz \
[medium]=/usr/share/consolefonts/Uni2-TerminusBold24x12.psf.gz \
[large]=/usr/share/consolefonts/Uni2-TerminusBold32x16.psf.gz \
)
## Configuration functions ################################
conf_get() { echo ${CONFIG}.new; }
conf_new() { cp -p ${CONFIG} ${CONFIG}.new; }
conf_save() {
mv ${CONFIG}.new ${CONFIG}
pigeos-splash update
pigeos-setup configure \
| $DIAL --backtitle "$BTITLE" --title "Information" \
--gauge "$main_save_msg" 8 50 0
}
conf_abort() { rm ${CONFIG}.new; }
conf_reset() {
if [ dial_yesno $main_reset_msg ]; then
echo ". /usr/local/etc/pigeos.conf" \
> ${CONFIG}.new
egrep -v 'DOSBOX_BIN|CONTINUE_SETUP|PIGEOS_VER|PIGEOS_RPO|.*[\\\)]$|^#.*' \
/usr/local/etc/pigeos.conf \
>>${CONFIG}.new
fi
}
## UI functions ###########################################
dial_info() {
$DIAL --backtitle "$BTITLE" --title "Information" \
--infobox "$1" $((${#1} / 46 + 6)) 50
}
dial_msg() {
$DIAL --backtitle "$BTITLE" --title "Information" \
--msgbox "$1" $((${#1} / 46 + 9)) 50
}
dial_err() {
$DIAL --backtitle "$BTITLE" --title "Error" \
--msgbox "$1" $((${#1} / 46 + 9)) 50
}
dial_yesno() {
$DIAL --backtitle "$BTITLE" --title "Confirmation" \
--yesno "$1" $((${#1} / 46 + 9)) 50
}
dial_input() {
local sel=$($DIAL --backtitle "$BTTILE" --title "${1}" \
--inputbox "$(echo -e \\n$2)" 9 50 "$3" \
3>&1 1>&2 2>&3)
[[ -n $sel ]] && echo $sel || return 1
}
dial_menu() {
local title=$1; shift
local text=$1; shift
local items=("$@")
local itemc=$((${#items[@]}/2))
if [ $itemc -gt 12 ]; then
itemc=12
fi
local sel=$($DIAL --backtitle "$BTITLE" --title "${title}" \
--ok-button ${ok_button} --cancel-button ${cancel_button} \
--menu "$(echo -e \\n${text})" 20 76 $itemc "${items[@]}" \
3>&1 1>&2 2>&3)
[[ $? -eq 0 ]] && echo $sel || return 1
}
## Helper functions #############################################
file_download() {
wget --progress=dot "$1" -O "$2" 2>&1 \
| sed -un 's/.* \([0-9]\+\)% .*/\1/p' \
| $DIAL --backtitle "$BTITLE" --gauge "Downloading: $1" 8 50 0
}
file_archive() {
local arc="$1"; shift
# strip the path from the files to archive
local pth=$(dirname $1)
local src=("$(basename $1)")
while shift; do
[ -f "$1" ] && src+=("$(basename $1)")
done
# compute number of allocated blocks to handle sparse files
local size=$(stat -c%b ${src[@]} \
| awk 'BEGIN{sum=0}{sum=sum+$1*512}END{print sum}')
(tar cSf - -C $pth ${src[@]} | pv -n -s${size} | gzip >${arc}) 2>&1 \
| $DIAL --backtitle "$BTITLE" --gauge "Archiving: ${arc}" 8 50 0
}
file_extract() {
local arc="$1"
local dst="$2"
if [ -f $arc -a -d $dst ]; then
tar xzSf $arc -C $dst 2>/dev/null 1>&2
fi
}
## Main menu #####################################################
main_menu() {
local selection
while :; do
source $(conf_get); source $MENU_TEXT
selection=$(dial_menu "${main_title}" "${main_text}" "${main_options[@]}")
case $selection in
Basic) basic_menu ;;
Advanced) advanced_menu ;;
System) system_menu ;;
Default) conf_reset ;;
Hard*) imgmgmt_menu ;;
Write) return 0 ;;
Shutdown) dial_yesno "$main_shutdown_msg" && return 1 ;;
*) dial_yesno "$main_abort_msg" && return 255
esac
done
}
## Basic Menu #####################################################
basic_menu() {
local selection
while :; do
source $(conf_get); source $MENU_TEXT
selection=$(dial_menu "${basic_title}" "${basic_text}" "${basic_options[@]}")
case $selection in
Date*) true ;;
Hard*C*) imgsel_menu hdc ;;
Hard*D*) imgsel_menu hdd ;;
Floppy*A*) imgsel_menu fda ;;
Floppy*B*) imgsel_menu fdb ;;
Keyboard*) keybrd_menu ;;
Sound*) sound_menu ;;
*) break
esac
done
}
imgsel_menu() {
local selection
local imgsel_drv=${1}
local imgsel_list=("NONE" "no image selected")
local imgsel_dir=$HOME/${imgsel_drv:0:2}d_images/
# build the list of available disk images
for f in ${imgsel_dir}/*.inf; do
# if no files are there f = '*', so it has to be validated
if [ -f $f ]; then
imgsel_list+=("$(basename $f .inf)" "$(head -1 $f)")
fi
done
# ask the user to choose one image
selection=$(dial_menu "${imgsel_title}" "${imgsel_text}" "${imgsel_list[@]}")
if [ "x$selection" = "x" ]]; then
false # image selection aborted
elif [ "$selection" = "NONE" ]; then
sed -i "s#${imgsel_drv^^}_IMAGE=.*#${imgsel_drv^^}_IMAGE=NONE#" $(conf_get)
elif grep -q ".D._IMAGE=${imgsel_dir}${selection}.img" $(conf_get); then
dial_err "$imgsel_mounted"
else
# load multi line image desc into a single variable
local imgsel_inf=""
while read line
do imgsel_inf="${imgsel_inf}${line}\n"; done \
<${imgsel_dir}/${selection}.inf
local imgsel_inflc=$(echo -e "$imgsel_inf" | wc -l)
# make text scrollable if it is more the 10 lines
if [ $imgsel_inflc -le 10 ]; then
$DIAL --backtitle "$BTITLE" --title "Image Information" \
--yesno "${imgsel_inf}\n\n${imgsel_conf}" $(($imgsel_inflc + 10)) 76
else
$DIAL --backtitle "$BTITLE" --title "Image Information" \
--yesno --scrolltext "${imgsel_inf}\n\n${imgsel_conf}" 20 76
fi
if [ $? -eq 0 ]; then
sed -i "s#${imgsel_drv^^}_IMAGE=.*#${imgsel_drv^^}_IMAGE=${imgsel_dir}${selection}.img#" $(conf_get)
fi
fi
}
keybrd_menu() {
local selection
source $(conf_get); source $MENU_TEXT
selection=$(dial_menu "${keybsel_title}" "${keybsel_text}" "${keybsel_options[@]}")
if [[ -n $selection ]]; then
# language settings where not present in early versions
grep -q KEYB $(conf_get) || echo "KEYB=us" >>$(conf_get)
# set selected lang.
sed -i "s#KEYB=.*#KEYB=$selection#" $(conf_get)
fi
}
sound_menu() {
local selection=${VOL_LEVEL:=80}
local idx
source $(conf_get); source $MENU_TEXT
while true; do
selection=$($DIAL --backtitle "$BTTILE" --title "PCM Volume" \
--ok-button 'Test' \
--inputbox "$volumectl_range" 9 50 "$selection" \
3>&1 1>&2 2>&3)
if [[ $? -ne 0 ]]; then break; fi
if [[ "$selection" =~ ^[0-9]+$ ]]; then
# play a test sound
dial_info "$volumetst_info"
# clip given value to the allowed range
if [[ $selection -lt 0 ]]; then
selection=0
elif [[ $selection -gt 100 ]]; then
selection=100
fi
idx=$(( $RANDOM % ${#volumetst_text[@]} ))
amixer -q -M sset PCM "${selection}%"
espeak -s 160 -v $volumetst_lang "${volumetst_text[$idx]}" 1>/dev/null 2>&1
if dial_yesno "$volumetst_conf"
then
grep -q "VOL_LEVEL" $(conf_get) \
&& sed -i "s#VOL_LEVEL=.*#VOL_LEVEL=$selection#" $(conf_get) \
|| echo "VOL_LEVEL=$selection" >>$(conf_get)
break
else
# set current vulome level back to the original value
amixer -q -M sset PCM "${VOL_LEVEL:=80}%"
fi
fi
done
}
## Advanced Menu ################################
advanced_menu() {
local selection
while :; do
source $(conf_get); source $MENU_TEXT
selection=$(dial_menu "${advanced_title}" "${advanced_text}" "${advanced_options[@]}")
case "$selection" in
CUPS*) service_activation_menu "CUPS_SLOAD" "${selection}" ;;
DOSBox*) prnsel_menu ;;
Duplex*) dupsel_menu ;;
Job*) dupwait_menu ;;
Remote*) service_activation_menu "CUPS_ADMIN" "${selection}" ;;
MIDI*) service_activation_menu "MIDI_SLOAD" "${selection}" ;;
ResilioSync*) rslsync_menu "RSLSYNC_SLOAD" "${selection}" ;;
Acces*Key*) rslsync_key_edit ;;
Internet*) service_activation_menu "RSLSYNC_WAN" "${selection}" ;;
Auto-Import*) service_activation_menu "IMG2GEOS_SLOAD" "${selection}" ;;
FeedProxy*) service_activation_menu "FEEDPROXY_SLOAD" "${selection}" ;;
*) break
esac
done
}
prnsel_menu() {
local selection
local prnsel_list=("AUTO" "autodetect" "PDF" "PDF Export")
# build the list of available printers
for p in $(lpstat -a | cut -d ' ' -f 1); do
[[ -n $p ]] && prnsel_list+=("$p" "${p//_/ }")
done
# ask the user to choose a printer
selection=$(dial_menu "${prnsel_title}" "${prnsel_text}" "${prnsel_list[@]}")
if [[ -n $selection ]]; then
grep -q CUPS_DBPRN $(conf_get) \
&& sed -i "s#CUPS_DBPRN=.*#CUPS_DBPRN=${selection}#" $(conf_get) \
|| echo "CUPS_DBPRN=${selection}" >> $(conf_get)
fi
}
dupsel_menu() {
local selection
selection=$(dial_menu "${dupsel_title}" "${dupsel_text}" "${dupsel_options[@]}")
if [[ -n $selection ]]; then
grep -q CUPS_DUPMODE $(conf_get) \
&& sed -i "s#CUPS_DUPMODE=.*#CUPS_DUPMODE=${selection}#" $(conf_get) \
|| echo "CUPS_DUPMODE=${selection}" >> $(conf_get)
fi
}
dupwait_menu() {
local wtime
while :; do
wtime=$(dial_input "${dupwait_title}" "${dupwait_text}" ${CUPS_DUPWAIT})
if [[ -z $wtime ]]; then
break
elif [[ "$wtime" != "$(echo $wtime | tr -cd '[:digit:]')" ]]; then
dial_yesno "Invalid value: $wtime Retry?" && continue || break
fi
grep -q CUPS_DUPWAIT $(conf_get) \
&& sed -i "s#CUPS_DUPWAIT=.*#CUPS_DUPWAIT=${wtime}#" $(conf_get) \
|| echo "CUPS_DUPWAIT=${wtime}" >> $(conf_get)
break
done
}
rslsync_menu() {
local selection
# when disableing config and files will be removed -> warn the user
grep -q "RSLSYNC_SLOAD=1" $(conf_get) \
&& dial_msg "$advanced_sync_deactivate"
service_activation_menu "RSLSYNC_SLOAD" "ResilioSync"
}
rslsync_key_edit() {
local selection
source $(conf_get)
# the sync key can only set once but not changed later
if [[ -z $RSLSYNC_KEY ]]; then
selection=$(dial_input "Input" "${advanced_sync_key_edit}" "$RSLSYNC_KEY")
if [[ -n $selection ]]; then
grep -q "RSLSYNC_KEY" $(conf_get) \
&& sed -i "s#RSLSYNC_KEY=.*#RSLSYNC_KEY=${selection}#" $(conf_get) \
|| echo "RSLSYNC_KEY=${selection}" >> $(conf_get)
fi
else
dial_msg "$advanced_sync_key_warn"
fi
}
service_activation_menu() {
local service="$1"
local sername="${2:-$1}"
local selection
dial_yesno "$sername $advanced_serv_activate"; selection=$?
if [[ $selection -ne 255 ]]; then
grep -q "$service" $(conf_get) \
&& sed -i "s#${service}=.*#${service}=$(($selection==0?1:0))#" $(conf_get) \
|| echo "${service}=$(($selection==0?1:0))" >> $(conf_get)
fi
}
## System menu ##################################
system_menu() { sudo raspi-config; }
## ImageMgmt Menu ###############################
imgmgmt_menu() {
local selection
while :; do
source $(conf_get); source $MENU_TEXT
selection=$(dial_menu "${imgmgmt_title}" "${imgmgmt_text}" "${imgmgmt_options[@]}")
case $selection in
Create*) imgmgmt_create ;;
Delete*) imgmgmt_delete ;;
Download*) imgmgmt_download ;;
Edit*) imgmgmt_edit ;;
Export*) imgmgmt_export ;;
Import*) imgmgmt_import ;;
Rename*) imgmgmt_rename ;;
*) break
esac
done
}
imgmgmt_create() {
local isize
local iname
local idesc
# ask for image name, size and a short description
while :; do
isize=$(dial_input "Image size" "$imgmgmt_image_size" 512)
iname=$(dial_input "Image name" "$imgmgmt_image_filename" "$iname")
idesc=$(dial_input "Image description" "$imgmgmt_image_descrition" "")
# check none zero values and characters not allowed in file names
if [ "x$isize" = "x" -o "x$iname" = "x" ]; then
dial_yesno "$imgmgmt_not_null" && continue || break
elif [[ "$isize" != "$(echo $isize | tr -cd '[:digit:]')" ]]; then
dial_yesno "Invalid value: $isize Retry?" && continue || break
elif [[ "$iname" != "$(echo $iname | tr -cd '[:alnum:]_-')" ]]; then
dial_yesno "Invalid value: $iname Retry?" && continue || break
fi
# call external image utility to create sparse file image
pigeos-image create "$iname" "$isize" "$idesc" 2>/dev/null 1>&1
if [ $? -eq 0 ]; then
dial_msg "$imgmgmt_create_ok $HOME/hdd_images/$iname"; break
else
dial_yesno "$imgmgmt_create_fail $HOME/hdd_images/$iname" && continue || break
fi
done
}
imgmgmt_delete() {
local selection
local imgsel_list=()
local imgsel_dir=$HOME/hdd_images/
# build the list of available disk images
for f in ${imgsel_dir}/*.inf
do imgsel_list+=("$(basename $f .inf)" "$(head -1 $f)"); done
# ask the user to choose one image
selection=$(dial_menu "${imgsel_title}" "${imgsel_text}" "${imgsel_list[@]}")
if [[ -n $selection ]]; then
if grep -q ".D._IMAGE=${imgsel_dir}${selection}.img" $(conf_get); then
dial_err "${imgmgmt_del_mounted}"
else
dial_yesno "${imgmgmt_del_confirm}" && rm ${imgsel_dir}/${selection}.i??
fi
fi
}
imgmgmt_rename() {
local iname
local selection
local imgsel_list=()
local imgsel_dir=$HOME/hdd_images/
# build the list of available disk images
for f in ${imgsel_dir}/*.inf
do imgsel_list+=("$(basename $f .inf)" "$(head -1 $f)"); done
# ask the user to choose one image
selection=$(dial_menu "${imgsel_title}" "${imgsel_text}" "${imgsel_list[@]}")
if [[ -n $selection ]]; then
if grep -q ".D._IMAGE=${imgsel_dir}${selection}.img" $(conf_get); then
dial_err "${imgmgmt_mod_mounted}"
else
iname=$(dial_input "Image name" "$imgmgmt_image_filename" "$selection")
if [[ -n $iname ]]; then
pigeos-image rename "$selection" "$iname" 2>/dev/null 1>&1
fi
fi
fi
}
imgmgmt_edit() {
local selection
local imgsel_list=()
local imgsel_dir=$HOME/hdd_images/
# build the list of available disk images
for f in ${imgsel_dir}/*.inf
do imgsel_list+=("$(basename $f .inf)" "$(head -1 $f)"); done
# ask the user to choose one image
selection=$(dial_menu "${imgsel_title}" "${imgsel_text}" "${imgsel_list[@]}")
if [[ -n $selection ]]; then
jed +3 ${imgsel_dir}/${selection}.inf
fi
}
imgmgmt_download() {
local selection
local url="$PIGEOS_RPO"
local regex='^(https?|ftp)://[-A-Za-z0-9\+&@#/%?=~_|!:,.;]*[-A-Za-z0-9\+&@#/%=~_|]$'
local irepo=()
local line
if [[ $url =~ $regex ]]; then
while read line; do
irepo+=("$line")
done <<<"$(curl -s "$url" 2>null | jq -r '.img_list|.[]|.name, .url' 2>null)"
if [[ $((${#irepo[@]}/2)) -eq 0 ]]; then
dial_err "Unable to retrieve repo data! Check you internet connection." && return 255
fi
else
dial_err "Image Repo: $imgmgmt_invalid_url Reinstall Pi/GEOS." && return 255
fi
local ilist=()
local imidx=$((${#irepo[@]}/2 -1))
for i in $(seq 0 $imidx); do
j=$((i*2))
ilist+=("$i" "${irepo[$j]}")
done
ilist+=("$((++i))" "Custom")
selection=$(dial_menu "Image Download" "Select an image to download" "${ilist[@]}")
if [[ "$selection" == "$i" ]]; then
# last option selected -> ask for a custom URL
url=$(dial_input "Dounwload" \
"$imgmgmt_download" \
"https://dl.dropbox.com/s/4v6gm5z0ynyft4k/ensdemo402.tgz")
elif [[ -n $selection ]]; then
j=$((selection*2+1))
url="${irepo[$j]}"
fi
if [[ $url =~ $regex ]]; then
file_download "$url" /tmp/imgmgmt_new_image.tgz
tar xzSf /tmp/imgmgmt_new_image.tgz -C ~/hdd_images
if [ $? -eq 0 ]; then
#dial_msg "$imgmgmt_unpack_suc"
rm /tmp/imgmgmt_new_image.tgz
else
dial_err "$imgmgmt_unpack_err"
fi
else
dial_err "$imgmgmt_invalid_url"
fi
}
imgmgmt_export() {
local selection
local imgsel_list=()
local imgsel_dir=$HOME/hdd_images/
# check for a mount usb disk
mount | grep -q '/media/usb0'
if [ $? -ne 0 ]; then
dial_err "$imgmgmt_usb_not_present"
return 1
fi
# build the list of available disk images
for f in ${imgsel_dir}/*.inf
do imgsel_list+=("$(basename $f .inf)" "$(head -1 $f)"); done
# ask the user to choose one image
selection=$(dial_menu "${imgsel_title}" "${imgsel_text}" "${imgsel_list[@]}")
if [[ -n $selection ]]; then
file_archive /media/usb/${selection}.tgz ${imgsel_dir}/${selection}.i??
fi
}
imgmgmt_import() {
local selection
local imgsel_list=()
local imgsel_dir=$HOME/hdd_images/
# check for a mount usb disk
mount | grep -q '/media/usb0'
if [ $? -ne 0 ]; then
dial_err "$imgmgmt_usb_not_present"
return 1
fi
# build the list of available disk images
local imgsel_count=$(ls /media/usb/*.tgz 2>/dev/null | wc -l)
if [ $imgsel_count -eq 0 ]; then
dial_err "$imgmgmt_no_arc_found"
return 2
fi
# init counters for gauge
local cnt=$((100 % $imgsel_count))
local stp=$((100 / $imgsel_count))
for f in /media/usb/*.tgz ; do
imgsel_list+=("$(basename $f .tgz)"\
"$(tar xzf $f --wildcards '*.inf' --to-command 'head -1')")
cnt=$(($cnt + $stp))
echo $cnt | $DIAL --backtitle "$BTITLE" --gauge "Scanning archives" 8 50 0
done
# ask the user to choose one image
selection=$(dial_menu "${imgsel_title}" "${imgsel_text}" "${imgsel_list[@]}")
if [[ -n $selection ]]; then
file_extract /media/usb/${selection}.tgz $imgsel_dir
dial_msg "$imgmgmt_unpack_suc"
fi
}
config_wizard() {
local imgsel_dir=$HOME/hdd_images/
source $(conf_get); source $MENU_TEXT
# this wizrad will only be executed, if no disk assigment has been made so far
[ `grep -e '[FH]D[ABCD]_IMAGE=NONE' $(conf_get) | wc -l` -eq 4 ] || return 1
dial_yesno "$wizard_intro" || return 2
# select keyboard language
keybrd_menu && source $(conf_get)
case KEYB in
gr) LANG=de_DE.UTF-8;;
*) LANG=en_US.UTF-8;;
esac
# switch to new language
if [ -r /usr/local/share/pigeos/pigeos-config.$LANG ]; then
MENU_TEXT=/usr/local/share/pigeos/pigeos-config.$LANG
fi
# check for working internet connection
local retry_count=0
while [ $retry_count -le 10 ]; do
echo $(($retry_count * 10)) | $DIAL --backtitle "$BTITLE" \
--gauge "$wizard_net_wait" 8 50 0
curl "$PIGEOS_RPO" >/dev/null 2>&1 && break
sleep 5
retry_count=$(($retry_count + 1))
done
if [ $retry_count -gt 10 ]; then
dial_err "$wizard_net_error"
file_extract /usr/local/share/pigeos/ensbudle.tgz $imgsel_dir
else
# try to download an image and assign it to drive C:
imgmgmt_download
fi
local imgsel_dir=$HOME/hdd_images
for f in ${imgsel_dir}/*.img; do
# if no files are there f = '*', so it has to be validated
if [ -f $f ]; then
sed -i "s#HDC_IMAGE=.*#HDC_IMAGE=${f}#" $(conf_get)
fi
done
dial_msg "$wizard_finished"
}
### Main ###########################################################################
# load menue language
if [ -r ./pigeos-config.$LANG ]; then
MENU_TEXT=./pigeos-config.$LANG
elif [ -r /usr/local/share/pigeos/pigeos-config.$LANG ]; then
MENU_TEXT=/usr/local/share/pigeos/pigeos-config.$LANG
else
# default to english, if nothing else matches
MENU_TEXT=/usr/local/share/pigeos/pigeos-config.en_US.UTF-8
fi
# switch console font to get a aprox. 25x80 char text screen resolution like in DOS
SCREEN_RESOLUTION=$(fbset -a | grep '^mode.*' \
| sed 's/^mode\s\"\([0-9]*x[0-9]*\)\"$/\1/')
case $SCREEN_RESOLUTION in
640x*) setfont ${FONT[tiny]};;
800x*) setfont ${FONT[small]};;
1024x*) setfont ${FONT[medium]};;
*) setfont ${FONT[large]};;
esac
# changes made by the config tool are applied to a new file
conf_new
# launch menue
config_wizard || main_menu; res=$?
if [ $res -eq 0 ]; then
# save changes
conf_save
# and reboot if not in debug mode
[[ $DEBUG -eq 0 ]] && reboot || exit 0
elif [ $res -eq 1 ]; then
conf_abort && sudo halt -p
else
# remove interim config file and return to the pigeos-loader loop
[[ $DEBUG -eq 0 ]] && conf_abort || exit 255
fi
exit 0