Debian Codegraph @

sbin/drbl-netinstall

raw symbols SCIP
1 #!/bin/bash
2 # Author: Steven Shiau <steven _at_ clonezilla org>
3 # License: GPL
4 # Description: Download the netinstall kernel & initrd for DRBL client to install GNU/Linux via network.
5
6 DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}"
7
8 . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions
9 [ -e /etc/drbl/drbl-ocs.conf ] && . /etc/drbl/drbl-ocs.conf
10 [ -e $DRBL_SCRIPT_PATH/sbin/ocs-functions ] && . $DRBL_SCRIPT_PATH/sbin/ocs-functions
11
12 #
13 supported_dists="$(set | grep -i "_netinstall_ver" | awk -F"_" '{print $1}' | sort | uniq)"
14
15 # make it in a line, and use comma to separate them.
16 supported_dists="$(echo $supported_dists)"
17 supported_dists_with_comma="$(echo $supported_dists | sed -e "s/ /, /g")"
18 USAGE() {
19 echo "Download GNU/Linux netinstall kernel and initrd for DRBL client to install GNU/Linux."
20 echo "Usage: $0 [OPTION] DIST"
21 echo "OPTION:"
22 language_help_prompt_by_idx_no
23 echo "-b, --enable-bsd: Include BSD distributions in the 'all' lists. Use this with '-i all'"
24 echo "-d, --dir DIR Put the netinstall files in DIR instead of default dir $pxecfg_pd"
25 echo "-i, --install DIST: Load GNU/Linux DIST netinstall package into DRBL environment."
26 echo "-o, --overwrite: Overwrite existing images"
27 echo "-q, --quiet: Quiet mode"
28 echo "-s, --skip-rerun-gen: Skip the message about re-run generate-pxe-menu"
29 echo "-u, --uninstall DIST: Uninstall GNU/Linux DIST netinstall package."
30 echo "-v, --verbose: Verbose mode."
31 echo "-w, --run-wo-check-if-root Run $0 without checking if run as root"
32 echo "DIST is one of these: $supported_dists_with_comma"
33 echo "The settings are in drbl.conf."
34 echo "Ex: To load Debian netinstall packages, run '$0 -i debian'"
35 echo " To load Fedora netinstall packages, run '$0 -i fedora'"
36 echo " To load all supported GNU/Linux netinstall packages, run '$0 -i all'"
37 echo " To remove Fedora netinstall packages, run '$0 -u fedora'"
38 echo " To remove all GNU/Linux netinstall packages, run '$0 -u all'"
39 }
40 #
41 get_and_put_linux_img() {
42 local img_url="$1"
43 local dist="$2"
44 local iver="$3"
45 local iarch="$4"
46 local net_ker="$5"
47 local net_initrd="$6"
48 netinst_tmp="$(mktemp -d /tmp/netinst_tmp.XXXXXX)"
49 if [ ! -e "$TDIR/vmlinuz-netinstall-${dist}-${iver}-${iarch}" -o "$overwrite_img" = "yes" ]; then
50 [ "$verbose" = "on" ] && echo "Fetching $img_url/$net_ker..."
51 wget $wget_opt -P "$netinst_tmp" $img_url/$net_ker
52 if [ -e "$netinst_tmp/$net_ker" ]; then
53 mv -f $netinst_tmp/$net_ker $TDIR/vmlinuz-netinstall-${dist}-${iver}-${iarch}
54 else
55 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
56 echo "netinstall kernel $net_ker for $iarch $iver ${dist} not found!"
57 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
58 fi
59 else
60 echo "Existing $TDIR/vmlinuz-netinstall-${dist}-${iver}-${iarch} found!"
61 fi
62
63 if [ ! -e "$TDIR/initrd-netinstall-${dist}-${iver}-${iarch}.img" -o "$overwrite_img" = "yes" ]; then
64 [ "$verbose" = "on" ] && echo "Fetching $img_url/$net_initrd..."
65 wget $wget_opt -P "$netinst_tmp" $img_url/$net_initrd
66 if [ -e "$netinst_tmp/$net_initrd" ]; then
67 mv -f $netinst_tmp/$net_initrd $TDIR/initrd-netinstall-${dist}-${iver}-${iarch}.img
68 else
69 [ "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE
70 echo "netinstall initrd $net_initrd for $iarch $iver ${dist} not found!"
71 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
72 fi
73 else
74 echo "Existing $TDIR/initrd-netinstall-${dist}-${iver}-${iarch}.img found!"
75 fi
76 [ -d "$netinst_tmp" ] && rm -f $netinst_tmp/* && rmdir $netinst_tmp
77 } # end of get_and_put_linux_img
78
79 #
80 get_debian_netinstall() {
81 # output file format in /tftpboot/nbi_img/:
82 # vmlinuz-netinstall-${dist}-${ver}-${arch)
83 # initrd-netinstall-${dist}-${ver}-${i386}.img
84 #
85 for ver in $debian_netinstall_ver; do
86 for arch in $debian_netinstall_arch; do
87 if [ "$ver" = "sarge" -a "$arch" = "amd64" ]; then
88 echo -n "amd64 version of Sarge is not officially supported! Skip this. "
89 continue
90 fi
91 case "$ver" in
92 woody|sarge|etch)
93 # For version <= etch, only text mode available.
94 # URL e.g.:
95 # http://free.nchc.org.tw/debian/dists/etch/main/installer-i386/current/images/netboot/debian-installer/i386
96 # http://free.nchc.org.tw/debian/dists/etch/main/installer-amd64/current/images/netboot/debian-installer/amd64
97 url=$debian_url_site/$path_to_debian/$ver/main/installer-$arch/current/images/netboot/debian-installer/$arch
98 ;;
99 *)
100 # For version >= lenny, gtk mode used to be available
101 # URL e.g.:
102 # http://free.nchc.org.tw/debian/dists/lenny/main/installer-i386/current/images/netboot/gtk/debian-installer/i386/
103 #url=$debian_url_site/$path_to_debian/$ver/main/installer-$arch/current/images/netboot/gtk/debian-installer/$arch
104 url=$debian_url_site/$path_to_debian/$ver/main/installer-$arch/current/images/netboot/debian-installer/$arch
105 ;;
106 esac
107 get_and_put_linux_img $url Debian $ver $arch $debian_netinstall_kernel $debian_netinstall_initrd
108 done
109 done
110 } # end of get_debian_netinstall
111
112 #
113 get_ubuntu_netinstall() {
114 # output file format in /tftpboot/nbi_img/:
115 # vmlinuz-netinstall-${dist}-${ver}-${arch)
116 # initrd-netinstall-${dist}-${ver}-${i386}.img
117 #
118 for ver in $ubuntu_netinstall_ver; do
119 for arch in $ubuntu_netinstall_arch; do
120 # Starting from Jammy (22.04) and newer (e.g. Noble), netboot files are hosted under releases (ubuntu-cd or ubuntu-releases) rather than ubuntu/dists/.
121 # We dynamically probe the mirror to find the correct path (ubuntu-releases, ubuntu-cd, or direct).
122 url=""
123 for rel_path in ubuntu-releases ubuntu-cd ""; do
124 # We test both standard 'netboot/amd64/' (e.g., Noble) and 'netboot/ubuntu-installer/amd64/' (e.g., Jammy) layouts
125 for sub_path in "netboot/$arch" "netboot/ubuntu-installer/$arch"; do
126 if [ -n "$rel_path" ]; then
127 test_url="$ubuntu_url_site/$rel_path/$ver/$sub_path/linux"
128 else
129 test_url="$ubuntu_url_site/$ver/$sub_path/linux"
130 fi
131 if wget --spider --quiet "$test_url"; then
132 if [ -n "$rel_path" ]; then
133 url="$ubuntu_url_site/$rel_path/$ver/$sub_path"
134 else
135 url="$ubuntu_url_site/$ver/$sub_path"
136 fi
137 break 2
138 fi
139 done
140 done
141
142 if [ -z "$url" ]; then
143 # Default fallback to NCHC for modern (Noble) layout
144 url="$ubuntu_url_site/ubuntu-cd/$ver/netboot/$arch"
145 fi
146
147 # Probe for 'initrd' vs 'initrd.gz'
148 initrd_file="initrd"
149 if wget --spider --quiet "$url/initrd.gz"; then
150 initrd_file="initrd.gz"
151 fi
152
153 get_and_put_linux_img $url Ubuntu $ver $arch linux $initrd_file
154 done
155 done
156 } # end of get_ubuntu_netinstall
157
158 #
159 get_fedora_netinstall() {
160 # Example output file format in /tftpboot/nbi_img/:
161 # vmlinuz-netinstall-Fedora-6-i386, initrd-netinstall-Fedora-6-i386.img
162 # vmlinuz-netinstall-Fedora-6-x86_64, initrd-netinstall-Fedora-6-x86_64.img
163 # i.e.
164 # vmlinuz-netinstall-${dist}-${ver}-${arch)
165 # initrd-netinstall-${dist}-${ver}-${i386}.img
166 #
167 # url ex:
168 # http://free.nchc.org.tw/fedora/linux/core/6/i386/os/images/pxeboot/
169 # http://free.nchc.org.tw/fedora/linux/releases/7/Fedora/i386/os/images/pxeboot/
170 for ver in $fedora_netinstall_ver; do
171 for arch in $fedora_netinstall_arch; do
172 case $ver in
173 [1-6])
174 url=$fedora_url_site/$path_to_fedora/core/$ver/$arch/os/images/pxeboot
175 ;;
176 [7-9]|1[1-9]|20)
177 # For 7 to 20
178 url=$fedora_url_site/$path_to_fedora/releases/$ver/Fedora/$arch/os/images/pxeboot
179 ;;
180 *)
181 # For 21 or later... who knows about the future...
182 # E.g. http://free.nchc.org.tw/fedora/linux/releases/21/Server/i386/os/images/pxeboot/
183 url=$fedora_url_site/$path_to_fedora/releases/$ver/Server/$arch/os/images/pxeboot
184 ;;
185 esac
186 get_and_put_linux_img $url Fedora $ver $arch $fedora_netinstall_kernel $fedora_netinstall_initrd
187 done
188 done
189 } # end of get_fedora_netinstall
190
191 #
192 get_rocky_netinstall() {
193 # output file format in /tftpboot/nbi_img/:
194 # vmlinuz-netinstall-${dist}-${ver}-${arch)
195 # initrd-netinstall-${dist}-${ver}-${i386}.img
196 #
197 # url ex:
198 # http://free.nchc.org.tw/rocky/9/BaseOS/x86_64/os/images/pxeboot
199 # From Rocky Linux 8, only x86-64 exists.
200 for ver in $rocky_netinstall_ver; do
201 for arch in $rocky_netinstall_arch; do
202 [ "$arch" = "i386" ] && continue
203 url=$rocky_url_site/$path_to_rocky/$ver/BaseOS/$arch/os/images/pxeboot
204 get_and_put_linux_img $url RockyLinux $ver $arch $rocky_netinstall_kernel $rocky_netinstall_initrd
205 done
206 done
207 } # end of get_rocky_netinstall
208
209 #
210 get_redhat_netinstall() {
211 # output file format in /tftpboot/nbi_img/:
212 # vmlinuz-netinstall-${dist}-${ver}-${arch)
213 # initrd-netinstall-${dist}-${ver}-${i386}.img
214 #
215 # url ex:
216 # http://free.nchc.org.tw/redhat/linux/8.0/en/os/i386/images/pxeboot
217 # http://free.nchc.org.tw/redhat/linux/9/en/os/i386/images/pxeboot
218 for ver in $redhat_netinstall_ver; do
219 for arch in $redhat_netinstall_arch; do
220 url=$redhat_url_site/$path_to_redhat/$ver/en/os/$arch/images/pxeboot
221 get_and_put_linux_img $url RedHat $ver $arch $redhat_netinstall_kernel $redhat_netinstall_initrd
222 done
223 done
224 } # end of get_redhat_netinstall
225
226 #
227 get_mageia_netinstall() {
228 # output file format in /tftpboot/nbi_img/:
229 # vmlinuz-netinstall-${dist}-${ver}-${arch)
230 # initrd-netinstall-${dist}-${ver}-${i386}.img
231 #
232 # URL ex:
233 # Updated on Apr/03/2014
234 # http://free.nchc.org.tw/mageia/distrib/cauldron/i586/isolinux/i386/
235 # http://free.nchc.org.tw/mageia/distrib/cauldron/x86_64/isolinux/x86_64/
236 local arch_subdir
237 for ver in $mageia_netinstall_ver; do
238 for arch in $mageia_netinstall_arch; do
239 case "$arch" in
240 i586) arch_subdir="i386";;
241 x86_64) arch_subdir="x86_64";;
242 esac
243 url=$mageia_url_site/$path_to_mageia/$ver/$arch/isolinux/$arch_subdir
244 get_and_put_linux_img $url Mageia $ver $arch $mageia_netinstall_kernel $mageia_netinstall_initrd
245 done
246 done
247 } # end of get_mageia_netinstall
248
249 #
250 get_opensuse_netinstall() {
251 # vmlinuz-netinstall-${dist}-${ver}-${arch)
252 # initrd-netinstall-${dist}-${ver}-${i386}.img
253 #
254 # url ex:
255 # http://free.nchc.org.tw/opensuse/distribution/SL-10.1/inst-source/boot/i386/loader
256 # http://free.nchc.org.tw/opensuse/distribution/10.2/repo/oss/boot/i386/loader
257 for ver in $opensuse_netinstall_ver; do
258 for arch in $opensuse_netinstall_arch; do
259 case $ver in
260 10.1)
261 url=$opensuse_url_site/$path_to_opensuse/SL-10.1/inst-source/boot/$arch/loader
262 ;;
263 1[123].*)
264 # For 10.2 or later... who knows about the future
265 url=$opensuse_url_site/$path_to_opensuse/$ver/repo/oss/boot/$arch/loader
266 ;;
267 *)
268 # For Leap 42.1 or later... who knows about the future
269 url=$opensuse_url_site/$path_to_opensuse/leap/$ver/repo/oss/boot/$arch/loader
270 ;;
271 esac
272 get_and_put_linux_img $url openSUSE $ver $arch $opensuse_netinstall_kernel $opensuse_netinstall_initrd
273 done
274 done
275 } # end of get_opensuse_netinstall
276 #
277 get_freebsd_netinstall() {
278 # 1. Download FreeBSD 7.0 boot ISO:
279 # wget ftp://ftp.twaren.net/BSD/FreeBSD/releases/i386/ISO-IMAGES/7.0/7.0-RELEASE-i386-bootonly.iso
280 # 2. mount -o loop 7.0-RELEASE-i386-bootonly.iso /mnt
281 # 3. mkdir /pxeroot/
282 # 4. cp -a /mnt/boot /pxeroot/
283 # cp /mnt/boot/pxeboot /tftpboot/nbi_img/FreeBSD-7.0-pxeboot.0
284 # Add the following in /pxeroot/boot/loader.conf:
285 # vfs.root.mountfrom="ufs:/dev/md0c"
286 # which means that the later booting process will use a ramdisk as root instead of using NFS.
287 # 5. append the following in /tftpboot/nbi_img/pxelinux.cfg/default
288 # ---------
289 # label FreeBSD 7.0 netinstall
290 # # MENU DEFAULT
291 # # MENU HIDE
292 # MENU LABEL FreeBSD 7.0 netinstall
293 # # MENU PASSWD
294 # kernel FreeBSD-7.0-pxeboot.0
295 # ---------
296 # 6. Append one line by edit /etc/exports:
297 # ---------
298 # /pxeroot/ 192.168.120.2(ro,sync,async,no_root_squash,subtree_check)
299 # ---------
300 # then restart nfs service (Ex. /etc/init.d/nfs-kernel-server restart)
301 # Ref: http://www.hack.org/mc/freebsd-x60.html; http://www.fefe.de/netboot/how-to-netboot-installer.html
302 # For FreeBSD 8.0, ref: http://mark-oshea.blogspot.com/2009/11/installing-freebsd-8-using-pxe-and-nfs.html
303
304 # output file format in /tftpboot/nbi_img/:
305 # FreeBSD-7.0-i386-pxeboot.0
306 #
307 # url ex:
308 # ftp://ftp.twaren.net/BSD/FreeBSD/releases/i386/ISO-IMAGES/6.3/6.3-RELEASE-i386-bootonly.iso
309 # ftp://ftp.twaren.net/BSD/FreeBSD/releases/i386/ISO-IMAGES/7.0/7.0-RELEASE-i386-bootonly.iso
310 local iso_url ver arch netinst_tmp
311 netinst_tmp="$(mktemp -d /tmp/netinst_tmp.XXXXXX)"
312 iso_mnt_tmp="$(mktemp -d /tmp/iso_mnt_tmp.XXXXXX)"
313 for ver in $freebsd_netinstall_ver; do
314 for arch in $freebsd_netinstall_arch; do
315 iso_url="$freebsd_url_site/$path_to_freebsd/releases/$arch/ISO-IMAGES/$ver/$ver-RELEASE-${arch}-bootonly.iso"
316 if [ ! -e "$TDIR/FreeBSD-${ver}-${arch}-pxeboot.0" -o "$overwrite_img" = "yes" ]; then
317 [ "$verbose" = "on" ] && echo "Fetching $iso_url..."
318 wget $wget_opt -P "$netinst_tmp" $iso_url
319 if [ -e "$netinst_tmp/$ver-RELEASE-${arch}-bootonly.iso" ]; then
320 mount -o loop $netinst_tmp/$ver-RELEASE-${arch}-bootonly.iso $iso_mnt_tmp
321 echo "Creating /pxeroot/ for FreeBSD network install..."
322 mkdir -p /pxeroot/
323 echo "Copying dir boot from iso to /pxeroot..."
324 cp -a $iso_mnt_tmp/boot /pxeroot/
325 echo "Copying pxeboot from iso to $TDIR..."
326 cp -af $iso_mnt_tmp/boot/pxeboot $TDIR/FreeBSD-${ver}-${arch}-pxeboot.0
327 umount $iso_mnt_tmp
328 # files in iso is read-only
329 chmod u+w /pxeroot/boot/loader.conf
330 echo "Append ramdisk setting in /pxeroot/boot/loader.conf..."
331 # For FreeBSD 7.x, use: "vfs.root.mountfrom="ufs:/dev/md0c"
332 # For FreeBSD 8.0, use: "vfs.root.mountfrom="ufs:/dev/md0"
333 case "$ver" in
334 7.*)
335 cat <<-LOAD_END >> /pxeroot/boot/loader.conf
336 vfs.root.mountfrom="ufs:/dev/md0c"
337 LOAD_END
338 ;;
339 *)
340 cat <<-LOAD_END >> /pxeroot/boot/loader.conf
341 vfs.root.mountfrom="ufs:/dev/md0"
342 LOAD_END
343 ;;
344 esac
345 fi
346 # pxelinux memu will be created by generate-pxe-menu, so we do not proces that here.
347 # For FreeBSD, we have to setup NFS for /pxeroot. I hate this...
348 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
349 echo "///NOTE/// You have to append the following to /etc/exports:"
350 echo "/pxeroot/ *(ro,all_squash,no_subtree_check)"
351 echo "Then restart NFS service."
352 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
353 else
354 echo "Existing $TDIR/FreeBSD-${ver}-${arch}-pxeboot.0 found!"
355 fi
356 done
357 done
358 [ -d "$netinst_tmp" ] && rm -f $netinst_tmp/* && rmdir $netinst_tmp
359 [ -d "$iso_mnt_tmp" ] && rm -f $iso_mnt_tmp/* && rmdir $iso_mnt_tmp
360 } # end of get_freebsd_netinstall
361 #
362 get_openbsd_netinstall() {
363 # output file format in /tftpboot/nbi_img/:
364 # OpenBSD-4.2-i386-pxeboot.0
365 #
366 # Two files need to be download: pxeboot and bsd.rd
367 # ///NOTE/// To use netinstall in openbsd, the root file is bsd.rd, not bsd, and we have to rename bsd.rd as bsd.
368 # url ex:
369 # ftp://ftp.twaren.net/BSD/OpenBSD/4.2/i386/pxeboot
370 # ftp://ftp.twaren.net/BSD/OpenBSD/4.2/i386/bsd.rd
371 # Ref: http://www.hack.org/mc/freebsd-x60.html; http://www.fefe.de/netboot/how-to-netboot-installer.html
372 local url ver arch netinst_tmp
373 netinst_tmp="$(mktemp -d /tmp/netinst_tmp.XXXXXX)"
374 iso_mnt_tmp="$(mktemp -d /tmp/iso_mnt_tmp.XXXXXX)"
375 for ver in $openbsd_netinstall_ver; do
376 for arch in $openbsd_netinstall_arch; do
377 if [ ! -e "$TDIR/OpenBSD-${ver}-${arch}-pxeboot.0" -o "$overwrite_img" = "yes" ]; then
378 url="$openbsd_url_site/$path_to_openbsd/$ver/$arch/"
379 [ "$verbose" = "on" ] && echo "Fetching $url/pxeboot..."
380 wget $wget_opt -P "$netinst_tmp" $url/pxeboot
381 if [ -e "$netinst_tmp/pxeboot" ]; then
382 echo "Copying pxeboot as $TDIR/OpenBSD-${ver}-${arch}-pxeboot.0..."
383 cp -af $netinst_tmp/pxeboot $TDIR/OpenBSD-${ver}-${arch}-pxeboot.0
384 fi
385 [ "$verbose" = "on" ] && echo "Fetching $url/bsd..."
386 wget $wget_opt -P "$netinst_tmp" $url/bsd.rd
387 if [ -e "$netinst_tmp/bsd.rd" ]; then
388 echo "Copying bsd.rd as $TDIR/bsd..."
389 cp -af $netinst_tmp/bsd.rd $TDIR/bsd
390 fi
391 # pxelinux memu will be created by generate-pxe-menu, so we do not proces that here.
392 else
393 echo "Existing $TDIR/OpenBSD-${ver}-${arch}-pxeboot.0 found!"
394 fi
395 done
396 done
397 [ -d "$netinst_tmp" ] && rm -f $netinst_tmp/* && rmdir $netinst_tmp
398 [ -d "$iso_mnt_tmp" ] && rm -f $iso_mnt_tmp/* && rmdir $iso_mnt_tmp
399 } # end of get_openbsd_netinstall
400
401 #
402 install_GL_netinstall() {
403 # download them and put in the system...
404 # //NOTE// The GL_INST will contain bsd if drbl.conf containing any netinstall of bsd, since we get GL_INST by:
405 # . /etc/drbl/drbl.conf
406 # supported_dists="$(set |grep -i _netinstall_ | awk -F"_" '{print $1}' | sort | uniq)"
407 if [ "$GL_INST" = "all" ]; then
408 # Therefore we have to remove those BSD lists if setup_bsd_netinst is no
409 if [ "$setup_bsd_netinst" = "no" ]; then
410 GL_INST="$(echo $supported_dists | sed -e "s/[[:alnum:]]*bsd[[:space:]]//g" | sort)"
411 else
412 [ "$GL_INST" = "all" ] && GL_INST="$supported_dists"
413 fi
414 fi
415 echo "The following action will download a lot of network install packages, including these distributions: $GL_INST. This might take a long time..."
416 echo 'If you want to assign the url, check "netinstall image settings" in drbl.conf.'
417 for i in $GL_INST; do
418 echo "Downloading $i netinstall packages... "
419 eval get_${i}_netinstall
420 done
421 }
422
423 #
424 uninstall_GL_netinstall() {
425 [ "$GL_TO_BE_REMOVED" = "all" ] && GL_TO_BE_REMOVED="$supported_dists"
426 for i in $GL_TO_BE_REMOVED; do
427 # Type 1: Linux
428 find $TDIR/ -iname "*netinstall*$i*" -exec rm -fv {} \;
429 # Type 2: BSD
430 find $TDIR/ -iname "*$i*-pxeboot.0" -exec rm -fv {} \;
431 done
432 # UGLY!!! Remove the nfs exported dir came with freebsd
433 if [ -n "$(echo $GL_TO_BE_REMOVED | grep -i "freebsd")" ]; then
434 if [ -d "/pxeroot/" ]; then
435 echo "Removing /pxeroot..."
436 rm -rf /pxeroot/
437 fi
438 elif [ -n "$(echo $GL_TO_BE_REMOVED | grep -i "openbsd")" ]; then
439 rm -fv $TDIR/bsd
440 fi
441 }
442
443 #############
444 ### MAIN ###
445 #############
446
447 #
448 GL_INST=""
449 show_rerun_generate_pxe_menu="yes"
450 overwrite_img="no"
451 verbose="on"
452 verbose_opt="-v"
453 check_if_root_flag="yes"
454
455 # Parse command-line options
456 while [ $# -gt 0 ]; do
457 case "$1" in
458 -l|--language)
459 shift
460 if [ -z "$(echo $1 |grep ^-.)" ]; then
461 # skip the -xx option, in case
462 specified_lang="$1"
463 [ -z "$specified_lang" ] && USAGE && exit 1
464 shift
465 fi
466 ;;
467 -i|--install)
468 shift; mode="install"
469 if [ -z "$(echo $1 |grep ^-.)" ]; then
470 # skip the -xx option, in case
471 GL_INST="$1"
472 [ -z "$GL_INST" ] && USAGE && exit 1
473 shift
474 fi
475 ;;
476 -o|--overwrite)
477 shift
478 overwrite_img="yes" ;;
479 -b|--enable-bsd)
480 shift
481 setup_bsd_netinst="yes" ;;
482 -d|--dir)
483 shift;
484 if [ -z "$(echo $1 |grep ^-.)" ]; then
485 # skip the -xx option, in case
486 TDIR="$1"
487 [ -z "$TDIR" ] && USAGE && exit 1
488 shift
489 fi
490 ;;
491 -s|--skip-rerun-gen)
492 shift
493 show_rerun_generate_pxe_menu="no" ;;
494 -u|--uninstall)
495 shift; mode="uninstall"
496 if [ -z "$(echo $1 |grep ^-.)" ]; then
497 # skip the -xx option, in case
498 GL_TO_BE_REMOVED="$1"
499 [ -z "$GL_TO_BE_REMOVED" ] && USAGE && exit 1
500 shift
501 fi
502 ;;
503 -q|--quiet)
504 verbose="off"
505 verbose_opt=""
506 shift ;;
507 -v|--verbose)
508 verbose="on"
509 verbose_opt="-v"
510 shift ;;
511 -w|--run-wo-check-if-root)
512 check_if_root_flag="no"
513 shift ;;
514 *) USAGE && exit 1 ;;
515 esac
516 done
517
518 # mode is essential
519 [ -z "$mode" ] && USAGE && exit 1
520
521 #
522 [ "$check_if_root_flag" = "yes" ] && check_if_root
523
524 # Load the language file
525 ask_and_load_lang_set $specified_lang
526
527 [ -z "$TDIR" ] && TDIR="$pxecfg_pd"
528 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
529 echo "The netinstall files will be in dir \"$TDIR\"."
530 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
531
532 [ ! -d "$TDIR" ] && mkdir -p $TDIR
533
534 # run it
535 case "$mode" in
536 install) install_GL_netinstall;;
537 uninstall) uninstall_GL_netinstall;;
538 esac
539
540 #
541 if [ "$show_rerun_generate_pxe_menu" = "yes" ] ; then
542 echo "$msg_delimiter_star_line"
543 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
544 echo "$msg_run_generage_pxe_menu_after_drbl_netinstall"
545 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
546 echo -n "[Y/n] "
547 read run_genpxemenu_ans
548 case "$run_genpxemenu_ans" in
549 n|N|[nN][oO])
550 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
551 echo "$msg_run_generate_pxe_menu_and_dcs_to_show_netboot_menu"
552 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
553 ;;
554 *)
555 echo "$msg_ok_let_do_it"
556 generate-pxe-menu
557 gen-grub-efi-nb-menu
558 [ "$BOOTUP" = "color" ] && $SETCOLOR_WARNING
559 echo "$msg_run_dcs_to_show_netboot_menu"
560 [ "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL
561 ;;
562 esac
563 fi