aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDavid M. Syzdek <david@syzdek.net>2018-04-27 16:45:05 -0800
committerDavid M. Syzdek <david@syzdek.net>2018-04-27 16:45:05 -0800
commita43e0ad8d86fa116be5f58560f2be3d6854286b0 (patch)
tree995b4519e5e9260725f7e153c2f033bee3926eb2
parentd63acc79ea913963498d6b4dbac43cff4a5cc89a (diff)
downloadiperd-a43e0ad8d86fa116be5f58560f2be3d6854286b0.tar.gz
iperd-a43e0ad8d86fa116be5f58560f2be3d6854286b0.tar.bz2
iperd-a43e0ad8d86fa116be5f58560f2be3d6854286b0.tar.xz
iperd-a43e0ad8d86fa116be5f58560f2be3d6854286b0.zip
configure.sh: refactoring script
-rw-r--r--Makefile4
-rw-r--r--src/scripts/configure.sh151
2 files changed, 65 insertions, 90 deletions
diff --git a/Makefile b/Makefile
index 4159c79..df233eb 100644
--- a/Makefile
+++ b/Makefile
@@ -117,7 +117,7 @@ all:
117Makefile.local: 117Makefile.local:
118 @touch "$(@)" 118 @touch "$(@)"
119 119
120Makefile.config: $(SCRIPTDIR)/configure.sh 120Makefile.config: $(SCRIPTDIR)/configure.sh $(SCRIPTDIR)/genfiles.sh
121 bash ./$(SCRIPTDIR)/genfiles.sh all 121 bash ./$(SCRIPTDIR)/genfiles.sh all
122 @touch "$(@)" 122 @touch "$(@)"
123 123
@@ -200,7 +200,7 @@ download: syslinux $(DOWNLOAD_FILES)
200 200
201configure: 201configure:
202 @mkdir -p var/config 202 @mkdir -p var/config
203 bash ./$(SCRIPTDIR)/configure.sh configure 203 bash ./$(SCRIPTDIR)/configure.sh
204 204
205 205
206deps: 206deps:
diff --git a/src/scripts/configure.sh b/src/scripts/configure.sh
index dfaec7a..47b08d4 100644
--- a/src/scripts/configure.sh
+++ b/src/scripts/configure.sh
@@ -61,76 +61,6 @@ cleanup()
61} 61}
62 62
63 63
64configure()
65{
66 # enter main loop
67 while test true;do
68
69 # display main menu
70 exec 3>&1
71 RESULT="$(echo "" | xargs dialog \
72 --title " Main Menu " \
73 --backtitle "IP Engineering Rescue Disk Setup" \
74 --ok-label "Select" \
75 --extra-button \
76 --extra-label "Save" \
77 --cancel-label "Exit" \
78 --menu "Select item to configure:" \
79 20 70 13 \
80 "disk" "Change disk image options" \
81 "images" "Select individual boot images" \
82 "all" "Select all available images" \
83 "defaults" "Load defaults" \
84 "revert" "Revert changes" \
85 2>&1 1>&3)"
86 RC=$?
87 exec 3>&-
88
89 # inteprets selection
90 if test $RC -eq 124;then # (exit)
91 dialog \
92 --title " Exit Setup " \
93 --backtitle "IP Engineering Rescue Disk Setup" \
94 --defaultno \
95 --yesno "Exit without saving?" \
96 6 30
97 if test $? -eq 0;then
98 return 0
99 fi
100 elif test $RC -eq 126;then # (save)
101 configure_save
102 return 0
103 elif test $RC -eq 0 && test "x${RESULT}" == "xdisk";then
104 configure_disk
105 elif test $RC -eq 0 && test "x${RESULT}" == "ximages";then
106 configure_distros
107 elif test $RC -eq 0 && test "x${RESULT}" == "xall";then
108 configure_all
109 elif test $RC -eq 0 && test "x${RESULT}" == "xdefaults";then
110 CONFIG_PART_TYPE="${DEFAULT_PART_TYPE}"
111 CONFIG_PART_SIZE="${DEFAULT_PART_SIZE}"
112 CONFIG_IMG_SIZE="${DEFAULT_IMG_SIZE}"
113 CONFIG_ISO_TYPE="${DEFAULT_ISO_SIZE}"
114 cat /dev/null > ${CONFIG}.new
115 dialog \
116 --backtitle "IP Engineering Rescue Disk Setup" \
117 --no-tags \
118 --msgbox "Defaults loaded." \
119 6 30
120 elif test $RC -eq 0 && test "x${RESULT}" == "xrevert";then
121 prereqs
122 dialog \
123 --backtitle "IP Engineering Rescue Disk Setup" \
124 --no-tags \
125 --msgbox "Changes reverted." \
126 6 30
127 fi
128 done
129
130 return 0;
131}
132
133
134configure_all() 64configure_all()
135{ 65{
136 # enable all options 66 # enable all options
@@ -389,26 +319,71 @@ prereqs()
389#################### 319####################
390 320
391 321
392# prompt for images to install 322prereqs || exit 1
393case "${ACTION}" in
394 323
395 configure) 324# main loop
396 prereqs || exit 1 325while test true;do
397 configure || exit 1
398 exit 0
399 ;;
400
401
402 deps)
403 "${SCRIPTDIR}"/genfiles.sh ${REGEN_FILE}
404 exit 0
405 ;;
406 326
327 # display main menu
328 exec 3>&1
329 RESULT="$(echo "" | xargs dialog \
330 --title " Main Menu " \
331 --backtitle "IP Engineering Rescue Disk Setup" \
332 --ok-label "Select" \
333 --extra-button \
334 --extra-label "Save" \
335 --cancel-label "Exit" \
336 --menu "Select item to configure:" \
337 20 70 13 \
338 "disk" "Change disk image options" \
339 "images" "Select individual boot images" \
340 "all" "Select all available images" \
341 "defaults" "Load defaults" \
342 "revert" "Revert changes" \
343 2>&1 1>&3)"
344 RC=$?
345 exec 3>&-
346
347 # inteprets selection
348 if test $RC -eq 124;then # (exit)
349 dialog \
350 --title " Exit Setup " \
351 --backtitle "IP Engineering Rescue Disk Setup" \
352 --defaultno \
353 --yesno "Exit without saving?" \
354 6 30
355 if test $? -eq 0;then
356 exit 0
357 fi
358 elif test $RC -eq 126;then # (save)
359 configure_save
360 exit 0
361 elif test $RC -eq 0 && test "x${RESULT}" == "xdisk";then
362 configure_disk
363 elif test $RC -eq 0 && test "x${RESULT}" == "ximages";then
364 configure_distros
365 elif test $RC -eq 0 && test "x${RESULT}" == "xall";then
366 configure_all
367 elif test $RC -eq 0 && test "x${RESULT}" == "xdefaults";then
368 CONFIG_PART_TYPE="${DEFAULT_PART_TYPE}"
369 CONFIG_PART_SIZE="${DEFAULT_PART_SIZE}"
370 CONFIG_IMG_SIZE="${DEFAULT_IMG_SIZE}"
371 CONFIG_ISO_TYPE="${DEFAULT_ISO_SIZE}"
372 cat /dev/null > ${CONFIG}.new
373 dialog \
374 --backtitle "IP Engineering Rescue Disk Setup" \
375 --no-tags \
376 --msgbox "Defaults loaded." \
377 6 30
378 elif test $RC -eq 0 && test "x${RESULT}" == "xrevert";then
379 prereqs
380 dialog \
381 --backtitle "IP Engineering Rescue Disk Setup" \
382 --no-tags \
383 --msgbox "Changes reverted." \
384 6 30
385 fi
386done
407 387
408 *)
409 echo "Usage: ${PROG_NAME} [ configure | deps ]" 1>&2
410 exit 1
411 ;;
412esac
413 388
414# end of script 389# end of script