├── README.md ├── doc ├── kali-initrd.txt └── nonpae-README └── src ├── libbash.sh └── pxelinuxiso.sh /README.md: -------------------------------------------------------------------------------- 1 | pxe-linux-iso 2 | ============= 3 | 4 | PXE Boot Linux Distribution Easy 5 | 6 | 7 | This project helps the user to boot/install the Linux distributions more easy from ISO files. 8 | 9 | Supported Linux distribution CD/DVDs 10 | ------------------------------------ 11 | * CentOS/Fedora 12 | * Debian/Ubuntu 13 | * Arch Linux 14 | * Gentoo 15 | * openSUSE 16 | * Mageia 17 | * Manjaro 18 | * Elementary OS 19 | * BlackArch 20 | * Kali/BackTrack 21 | * Mint Linux 22 | * clonezilla 23 | * LXLE 24 | * tinycore 25 | * puppy 26 | * doudoulinux 27 | 28 | Supported Linux platforms 29 | ------------------------- 30 | 31 | This software can run on following systems: 32 | 33 | * CentOS/Fedora 34 | * Debian/Ubuntu 35 | * Arch Linux 36 | 37 | Features 38 | -------- 39 | * One single command line to setup a PXE entry to boot from CD/DVD 40 | * Can be run on multiple Linux systems 41 | * Support CD/DVDs of Fedora/CentOS/Debian/Ubuntu/Arch/Kali/Mint/... 42 | 43 | Prerequisites 44 | ------------- 45 | 46 | * Installed NFS server. This script will append lines to file /etc/exports; 47 | * Installed TFTP server. This script will append lines to file 48 | /var/lib/tftpboot/pxelinux.cfg/default; 49 | * To mount ISO files as loop device, a line will also be appended to /etc/fstab; 50 | * Installed syslinux; 51 | * To support HTTP installation, you may need to get the HTTP server installed and 52 | link the directory tftpboot as sub-dir of the URL. For example, the tftpboot can 53 | be accessed by http://localhost/tfptboot/ 54 | 55 | Installation 56 | ------------ 57 | Download the source files from GIT repo 58 | 59 | git clone https://github.com/yhfudev/pxe-linux-iso.git 60 | 61 | Initialize directories 62 | ---------------------- 63 | 64 | This script use following tree structure to manage the ISO files: 65 | 66 | /var/lib/tftpboot/ 67 | |-- downloads # the downloaded CD/DVD ISO files and patches 68 | |-- images-desktop # mount points for Linux desktop distributions 69 | |-- images-server # mount points for Linux server distributions 70 | |-- images-net # mount points for netinstall 71 | |-- kickstarts # kickstart scripts 72 | 73 | The following files also be initialized with default headers: 74 | 75 | /var/lib/tftpboot/pxelinux.cfg/default 76 | /var/lib/tftpboot/pxelinux.cfg/boot.txt 77 | 78 | Examples 79 | -------- 80 | * Help! 81 | ```bash 82 | ./pxelinuxiso.sh --help 83 | ``` 84 | 85 | * Initialize directories 86 | ```bash 87 | sudo ./pxelinuxiso.sh --init 88 | ``` 89 | * Add entries to the PXE server 90 | 91 | -- Add Ubuntu mini 92 | ```bash 93 | sudo ./pxelinuxiso.sh --nfsip 192.168.1.1 'http://mirror.anl.gov/pub/ubuntu/dists/quantal/main/installer-amd64/current/images/netboot/mini.iso' 94 | ``` 95 | -- Add Kali 96 | ```bash 97 | sudo ./pxelinuxiso.sh --nfsip 192.168.1.1 --title 'Kali' 'http://archive-5.kali.org/kali-images/kali-linux-1.0.4-amd64.iso' 98 | ``` 99 | -------------------------------------------------------------------------------- /doc/kali-initrd.txt: -------------------------------------------------------------------------------- 1 | 2 | How to create initrd.img patches for Kali 3 | 4 | Yunhui 5 | 6 | The Kali version 1.0.4 can't boot from NFS environment, 7 | because of lacking NFS kernel modules in the initrd.img file. 8 | This post (ref: https://wiki.hashdump.org/index.php/PXE::Kali) 9 | described how to fix it. 10 | 11 | Here's the simple steps I used to create patches from Kali Live CD. 12 | 13 | 1. Start Kali Live CD in one PC or VM, we refer the PC as 'LIVE'; 14 | 2. Create a working folder in your PXE server, we refer the PC as 'PXE'; 15 | Untar the filelive/initrd.img: 16 | 17 | FN_KALI="/media/cloudnfs/tftpboot/kali-linux-1.0.4-amd64.iso" 18 | #FN_KALI="/media/cloudnfs/tftpboot/kali-linux-1.0.4-i386.iso" 19 | DN_CDMNT="/media/kalilive/" 20 | 21 | mkdir -p "${DN_CDMNT}" 22 | umount "${DN_CDMNT}" 23 | mount -o loop,utf8 "${FN_KALI}" "${DN_CDMNT}" 24 | 25 | cd 26 | rm -rf temp 27 | mkdir temp 28 | cd temp 29 | zcat "${DN_CDMNT}/live/initrd.img" | cpio -i 30 | ls 31 | 32 | 3. Get kernel modules from 'LIVE', and send back to your 'PXE' server; 33 | 34 | DN_SYS_KMOD="/lib/modules/$(uname -r)/" 35 | export DN_KMOD="$(uname -r)" 36 | 37 | cd 38 | mkdir -p "${DN_KMOD}/kernel/fs" 39 | mkdir -p "${DN_KMOD}/kernel/net" 40 | 41 | # copy the module dependencies 42 | cp ${DN_SYS_KMOD}/* "${DN_KMOD}" 43 | 44 | cp -r ${DN_SYS_KMOD}/kernel/fs/fscache "${DN_KMOD}/kernel/fs" 45 | cp -r ${DN_SYS_KMOD}/kernel/fs/nfs "${DN_KMOD}/kernel/fs" 46 | cp -r ${DN_SYS_KMOD}/kernel/fs/nfs_common "${DN_KMOD}/kernel/fs" 47 | cp -r ${DN_SYS_KMOD}/kernel/fs/lockd "${DN_KMOD}/kernel/fs" 48 | cp -r ${DN_SYS_KMOD}/kernel/net/dns_resolver "${DN_KMOD}/kernel/net" 49 | cp -r ${DN_SYS_KMOD}/kernel/net/sunrpc "${DN_KMOD}/kernel/net" 50 | 51 | tar -cf libs-$(uname -r).tar "${DN_KMOD}" 52 | 53 | scp libs-$(uname -r).tar user@pxeserver:. 54 | 55 | 4. Save the files to your folder in 'PXE': 56 | 57 | #export DN_KMOD="$(uname -r)" 58 | export DN_KMOD="3.7-trunk-amd64" 59 | #export DN_KMOD="3.7-trunk-686-pae" 60 | 61 | cd 62 | cd temp 63 | cd lib/modules 64 | tar -xf ~/libs-${DN_KMOD}.tar 65 | cd ../.. 66 | find . | cpio --create --format='newc' > initrd.img 67 | gzip initrd.img 68 | mv initrd.img.gz ../initrd-kali-1.0.4-${DN_KMOD}.img 69 | 70 | 5. You may use the new patched initrd.img now. 71 | -------------------------------------------------------------------------------- /doc/nonpae-README: -------------------------------------------------------------------------------- 1 | http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/files 2 | 3 | So 28. Apr 01:13:30 CEST 2013 4 | info@thomas-reith.de 5 | 6 | Regarding the disappointing decision, that Ubuntu 12.10 and above doesn't 7 | provide non PAE Kernels for the i386 architecture, anymore, I've compiled 8 | a custom kernel based on the latest official Ubuntu kernel source package, 9 | with PAE (HIGHMEM) disabled. 10 | 11 | The kernel has been tested and compiled on ThinkPad T42, but should run 12 | on other Intel non PAE systems, too. 13 | 14 | regards 15 | 16 | webtom 17 | 18 | ATTENTION: 3.8.x kernels have NOT been tested on Ubuntu 12.10, 19 | upgrade to Ubuntu 13.04 first. 20 | 21 | Build Steps: 22 | 23 | 1.1 apt-get source linux-[current version]-generic 24 | (example: apt-get source linux-image-3.5.0-19-generic) 25 | 26 | if there are linux-* files from previous builds in your directory, 27 | simply remove them or save time doing the following steps: 28 | tar xvzf linux_3.x.0.orig.tar.gz (which should be there) 29 | rm -rf linux-3.x.0; mv linux-3.x linux-3.x.0 30 | gzip -d < linux_[version].diff.gz | patch -p0 31 | 32 | 1.2 get make-ubuntu-kernel-de.sh from 33 | https://code.launchpad.net/make-ubuntu-kernel 34 | into ~/bin 35 | 36 | 1.3 comment out 37 | linux-[version]/debian/control-scripts/preinst 38 | line 93 - 100 39 | ... 40 | #$arch = `uname -i`; 41 | #if ($arch =~ m/86/) { 42 | # system ("grep -q ' pae ' /proc/cpuinfo"); 43 | # if ($?) { 44 | # print STDERR "This kernel does not support a non-PAE CPU.\n"; 45 | # exit 1; 46 | # } 47 | #} 48 | ... 49 | 50 | 1.4 chmod -R 755 linux-[version]/debian/scripts 51 | chmod 755 linux-[version]/debian/rules 52 | 53 | 1.5 change directory into linux-[version] 54 | call sudo ~/bin/make-ubuntu-kernel-de.sh wt-non-pae 55 | ... 56 | kernel menuconfig: Processor type and features 57 | High Memory Support = (off) 58 | PAE (Physical Address Extension) Support = [ ] (false) 59 | ... 60 | wait... 61 | 62 | 1.6 or simply download and install the prebuild packages with 63 | dpkg -i linux-image-[version]-wt-non-pae_[version]_i386.deb 64 | dpkg -i linux-headers-[version]_all.deb 65 | dpkg -i linux-headers-[version]-wt-non-pae_[version]_i386.deb 66 | from 67 | http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/files 68 | 69 | 1.7 reboot and enjoy :-) 70 | 71 | 72 | 2.1 Fresh Ubuntu Installation from stick 73 | 74 | 2.2 Ubuntu Desktop 12.10: vmlinuz-3.5.0-17-wt-non-pae_3.5.0-17.28_i386 75 | initrd-3.5.0-17-wt-non-pae_3.5.0-17.28_i386.lz 76 | Ubuntu Desktop 13.02: vmlinuz-3.8.0-19-wt-non-pae_3.8.0-19.29_i386 77 | initrd-3.8.0-19-wt-non-pae_3.8.0-19.29_i386.lz 78 | 79 | 2.3 create an usb stick with "usb-creator-gtk" 80 | 81 | 2.4 remount the stick 82 | 83 | 2.5 replace /media/[stick]/casper/vmlinuz with vmlinuz-[version] 84 | what is it? it's the kernel from linux-image-[version] 85 | 86 | 2.6 replace /media/[stick]/casper/initrd.lz with initrd-[version] 87 | what is it? it's the ubuntu initrd.lz enhanced with lib/modules/[version]-wt-non-pae/ 88 | (Developer Info: don't forget using option '-H newc' with cpio (it took me hours) 89 | 90 | 2.7 copy linux-headers-[version].deb to /media/[stick]/ 91 | 92 | 2.8 copy linux-image-[version].deb to /media/[stick]/ 93 | 94 | 2.9 boot from stick and complete the Ubuntu installation 95 | 96 | 2.10 before the system reboots press ALT+CTRL+F1 to switch to the console 97 | ATTENTION: This step is important to get the modules installed. 98 | Without these modules, your system won't boot correctly! 99 | 100 | 2.11 change directory to /cdrom, which is your stick 101 | 102 | 2.12 run "dpkg --root=/target -i linux-image-[version].deb" 103 | ignore the warnings, all you need at this time are 104 | /target/lib/modules/[version]-wt-non-pae/ 105 | 106 | 2.13 run "dpkg --root=/target -i linux-headers-[version].deb" 107 | 108 | 2.14 run "dkpg --root=/target -i linux-headers-[version]_all.deb 109 | 110 | 2.15 reboot 111 | 112 | 2.16 install most recent linux-image and linux-headers; there should be no warnings, now 113 | 114 | 2.16 enjoy :-) 115 | -------------------------------------------------------------------------------- /src/libbash.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # -*- tab-width: 4; encoding: utf-8 -*- 3 | # 4 | ##################################################################### 5 | ## @file 6 | ## @brief bash library 7 | ## some useful bash script functions: 8 | ## ssh 9 | ## IPv4 address handle 10 | ## install functions for RedHat/CentOS/Ubuntu/Arch 11 | ## @author Yunhui Fu 12 | ## @copyright GPL v3.0 or later 13 | ## @version 1 14 | ## 15 | ##################################################################### 16 | #DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'` 17 | DN_EXEC="$(dirname "$0")" 18 | if [ ! "${DN_EXEC}" = "" ]; then 19 | DN_EXEC="${DN_EXEC}/" 20 | else 21 | DN_EXEC="./" 22 | fi 23 | 24 | # detect if the ~/bin is included in environment variable $PATH 25 | #echo $PATH | grep "~/bin" 26 | #if [ ! "$?" = "0" ]; then 27 | # #echo 'PATH=~/bin/:$PATH' >> ~/.bashrc 28 | # export PATH=~/bin:/sbin/:/usr/sbin/:$PATH 29 | #fi 30 | 31 | ##################################################################### 32 | # the format of the segment file name, it seems 19 is the max value for gawk. 33 | PRIuSZ="%019d" 34 | 35 | ##################################################################### 36 | # be careful the danger execution, such as rm -rf ... 37 | # use DANGER_EXEC=echo to skip all of such executions. 38 | DANGER_EXEC="echo [DryRunDanger]" 39 | 40 | FN_STDERR="/dev/stderr" 41 | OUT_ERR=">> ${FN_STDERR}" 42 | if [ ! -f "$FN_STDERR" ]; then 43 | OUT_ERR="" 44 | FN_STDERR="/dev/null" 45 | fi 46 | 47 | # the temporary directory 48 | DN_TMP=/tmp/ 49 | # check the temporary directory size 50 | LIST_DN=$(df | grep -v "1K-blocks" | gawk '{prefix=$6; sz=$2; if (sz<100000) {invalid[prefix]=1;} else {invalid[prefix]=0;} }END{for (prefix in invalid){if ("/" == substr(prefix,length(prefix),1)) dir=prefix "tmp"; else dir=prefix "/tmp"; if ((invalid[prefix]!="1") && (invalid[dir]!="1")) print dir; } }') 51 | for DN_TMP in $LIST_DN; do 52 | mkdir -p "${DN_TMP}" 53 | touch "${DN_TMP}/temptest" 54 | RET=$? 55 | if [ "$RET" = "0" ]; then 56 | rm -f "${DN_TMP}/temptest" 57 | break; 58 | fi 59 | rm -f "${DN_TMP}/temptest" 60 | done 61 | 62 | if [ "${FN_LOG}" = "" ]; then 63 | FN_LOG=mrtrace.log 64 | #FN_LOG="/dev/stderr" 65 | fi 66 | 67 | if [ "${FN_LOG}" = "" ]; then 68 | FN_LOG="/dev/stderr" 69 | fi 70 | 71 | ## @fn mr_trace() 72 | ## @brief print a trace message 73 | ## @param msg the message 74 | ## 75 | ## pass a message to log file, and also to stdout 76 | mr_trace() { 77 | echo "$(date +"%Y-%m-%d %H:%M:%S.%N" | cut -c1-23) [self=${BASHPID},$(basename "$0")] $@" | tee -a ${FN_LOG} 1>&2 78 | } 79 | 80 | ## @fn mr_exec_do() 81 | ## @brief execute a command line 82 | ## @param cmd the command line 83 | ## 84 | ## execute a command line, and also log the line 85 | mr_exec_do() { 86 | mr_trace "$@" 87 | eval "$@" 88 | } 89 | 90 | ## @fn mr_exec_skip() 91 | ## @brief skip a command line 92 | ## @param cmd the command line 93 | ## 94 | ## skip a command line, and also log the line 95 | mr_exec_skip() { 96 | mr_trace "DEBUG (skip) $@" 97 | } 98 | 99 | myexec_ignore () { 100 | mr_trace "[DBG] (skip) $*" 101 | A= 102 | while [ ! "$1" = "" ]; do 103 | A="$A \"$1\"" 104 | shift 105 | done 106 | #mr_trace "[DBG] (skip) $A" 107 | } 108 | myexec_trace () { 109 | mr_trace "[DBG] $*" 110 | A= 111 | while [ ! "$1" = "" ]; do 112 | A="$A \"$1\"" 113 | shift 114 | done 115 | #mr_trace "[DBG] $A" 116 | eval $A 117 | } 118 | 119 | DO_EXEC=mr_exec_do 120 | #DO_EXEC= 121 | if [ "$FLG_SIMULATE" = "1" ]; then 122 | DO_EXEC=mr_exec_skip 123 | fi 124 | 125 | ## @fn fatal_error() 126 | ## @brief log a fatal error 127 | ## @param msg the message 128 | ## 129 | fatal_error() { 130 | PARAM_MSG="$1" 131 | mr_trace "Fatal error: ${PARAM_MSG}" 1>&2 132 | #exit 1 133 | } 134 | 135 | ##################################################################### 136 | extract_file () { 137 | ARG_FN=$1 138 | shift 139 | 140 | mr_trace "[DBG] Extract compressed file: '${ARG_FN}'" 141 | 142 | if [ -f "${ARG_FN}" ]; then 143 | DN_CUR=`pwd` 144 | DN_DIC=`echo "${ARG_FN}" | awk -F/ '{if (NF <= 1) name=""; else name=$1; for (i=2; i < NF; i ++) name=name "/" $i } END {print name}'` 145 | FN_CUR=`echo "${ARG_FN}" | awk -F/ '{name=$NF; } END {print name}'` 146 | FN_BASE=`echo "${FN_CUR}" | awk -F. '{name=$1; for (i=2; i < NF; i ++) name=name "." $i } END {print name}'` 147 | if [ "${DN_DIC}" = "" ]; then 148 | DN_DIC="${DN_CUR}" 149 | fi 150 | 151 | mr_trace "DN_CUR=$DN_CUR; DN_DIC=$DN_DIC; FN_CUR=$FN_CUR; FN_BASE=$FN_BASE"; #exit 0 152 | 153 | case "${FN_CUR}" in 154 | *.tar.Z) 155 | echo "extract (tar) ${DN_DIC}/${FN_CUR} ..." 156 | cd "${DN_DIC}" 157 | #compress -dc file.tar.Z | tar xvf - 158 | tar -xvZf "${FN_CUR}" 159 | cd "${DN_CUR}" 160 | ;; 161 | *.tar.gz) 162 | echo "extract (tar) ${DN_DIC}/${FN_CUR} ..." 163 | cd "${DN_DIC}" 164 | tar -xzf "${FN_CUR}" 165 | cd "${DN_CUR}" 166 | ;; 167 | *.tar.bz2) 168 | echo "extract (tar) ${DN_DIC}/${FN_CUR} ..." 169 | cd "${DN_DIC}" 170 | tar -xjf "${FN_CUR}" 171 | cd "${DN_CUR}" 172 | ;; 173 | *.tar.xz) 174 | echo "extract (tar) ${DN_DIC}/${FN_CUR} ..." 175 | cd "${DN_DIC}" 176 | xzcat "${FN_CUR}" | tar -x 177 | cd "${DN_CUR}" 178 | ;; 179 | *.cpio.gz) 180 | echo "extract (cpio) ${DN_DIC}/${FN_CUR} ..." 181 | cd "${DN_DIC}" 182 | gzip -dc "${FN_CUR}" | cpio -div 183 | cd "${DN_CUR}" 184 | ;; 185 | *.gz) 186 | echo "extract (gunzip) ${DN_DIC}/${FN_CUR} ..." 187 | cd "${DN_DIC}" 188 | gunzip -d -c "${FN_CUR}" > "${FN_BASE}.tmptmp" 189 | mv "${FN_BASE}.tmptmp" "${FN_BASE}" 190 | cd "${DN_CUR}" 191 | ;; 192 | *.bz2) 193 | echo "extract (bunzip2) ${DN_DIC}/${FN_CUR} ..." 194 | cd "${DN_DIC}" 195 | bunzip2 -d -c "${FN_CUR}" > "${FN_BASE}.tmptmp" 196 | mv "${FN_BASE}.tmptmp" "${FN_BASE}" 197 | cd "${DN_CUR}" 198 | ;; 199 | *.rpm) 200 | echo "extract (rpm) ${DN_DIC}/${FN_CUR} ..." 201 | cd "${DN_DIC}" 202 | rpm2cpio "${FN_CUR}" | cpio -div 203 | cd "${DN_CUR}" 204 | ;; 205 | *.rar) 206 | echo "extract (unrar) ${DN_DIC}/${FN_CUR} ..." 207 | cd "${DN_DIC}" 208 | unrar x "${FN_CUR}" 209 | cd "${DN_CUR}" 210 | ;; 211 | *.zip) 212 | echo "extract (unzip) ${DN_DIC}/${FN_CUR} ..." 213 | cd "${DN_DIC}" 214 | unzip "${FN_CUR}" 215 | cd "${DN_CUR}" 216 | ;; 217 | *.deb) 218 | # ar xv "${FN_CUR}" && tar -xf data.tar.gz 219 | echo "extract (dpkg) ${DN_DIC}/${FN_CUR} ..." 220 | cd "${DN_DIC}" 221 | dpkg -x "${FN_CUR}" . 222 | cd "${DN_CUR}" 223 | ;; 224 | *.dz) 225 | echo "extract (dictzip) ${DN_DIC}/${FN_CUR} ..." 226 | cd "${DN_DIC}" 227 | dictzip -d -c "${FN_CUR}" > "${FN_BASE}.tmptmp" 228 | mv "${FN_BASE}.tmptmp" "${FN_BASE}" 229 | cd "${DN_CUR}" 230 | ;; 231 | *.Z) 232 | echo "extract (uncompress) ${DN_DIC}/${FN_CUR} ..." 233 | cd "${DN_DIC}" 234 | gunzip -d -c "${FN_CUR}" > "${FN_BASE}.tmptmp" 235 | mv "${FN_BASE}.tmptmp" "${FN_BASE}" 236 | cd "${DN_CUR}" 237 | ;; 238 | *.a) 239 | echo "extract (tar) ${DN_DIC}/${FN_CUR} ..." 240 | cd "${DN_DIC}" 241 | tar -xv "${FN_BASE}" 242 | cd "${DN_CUR}" 243 | ;; 244 | *.tgz) 245 | echo "extract (tar) ${DN_DIC}/${FN_CUR} ..." 246 | cd "${DN_DIC}" 247 | tar -xzf "${FN_CUR}" 248 | cd "${DN_CUR}" 249 | ;; 250 | *.tbz) 251 | echo "extract (tar) ${DN_DIC}/${FN_CUR} ..." 252 | cd "${DN_DIC}" 253 | tar -xjf "${FN_CUR}" 254 | cd "${DN_CUR}" 255 | ;; 256 | *.cgz) 257 | echo "extract (cpio) ${DN_DIC}/${FN_CUR} ..." 258 | cd "${DN_DIC}" 259 | gzip -dc "${FN_CUR}" | cpio -div 260 | cd "${DN_CUR}" 261 | ;; 262 | *.cpio) 263 | echo "extract (cpio) ${DN_DIC}/${FN_CUR} ..." 264 | cd "${DN_DIC}" 265 | cpio -div "${FN_CUR}" 266 | cd "${DN_CUR}" 267 | ;; 268 | *) 269 | #echo "skip ${DN_DIC}/${FN_CUR} ..." 270 | ;; 271 | esac 272 | else 273 | echo "Not found file: ${DN_DIC}/${FN_CUR}" 274 | return 1 275 | fi 276 | return 0; 277 | } 278 | 279 | ##################################################################### 280 | EXEC_SSH="$(which ssh) -oBatchMode=yes -CX" 281 | EXEC_SCP="$(which scp)" 282 | EXEC_AWK="$(which gawk)" 283 | EXEC_SED="$(which sed)" 284 | 285 | EXEC_SUDO="$(which sudo)" 286 | if [ ! -x "${EXEC_SUDO}" ]; then 287 | EXEC_SUDO="" 288 | fi 289 | if [ "$USER" = "root" ]; then 290 | EXEC_SUDO= 291 | fi 292 | 293 | ##################################################################### 294 | # System distribution detection 295 | EXEC_APTGET="${EXEC_SUDO} $(which apt-get)" 296 | 297 | OSTYPE=unknown 298 | OSDIST=unknown 299 | OSVERSION=unknown 300 | OSNAME=unknown 301 | 302 | ##################################################################### 303 | ## @fn detect_os_type() 304 | ## @brief detect the OS type 305 | ## 306 | ## detect the OS type, such as RedHat, Debian, Ubuntu, Arch, OpenWrt etc. 307 | detect_os_type() { 308 | test -e /etc/debian_version && OSDIST="Debian" && OSTYPE="Debian" 309 | grep Ubuntu /etc/lsb-release &> /dev/null && OSDIST="Ubuntu" && OSTYPE="Debian" 310 | test -e /etc/redhat-release && OSTYPE="RedHat" 311 | test -e /etc/fedora-release && OSTYPE="RedHat" 312 | which pacman 2>&1 > /dev/null && OSTYPE="Arch" 313 | which opkg 2>&1 > /dev/null && OSTYPE="OpenWrt" 314 | which emerge 2>&1 && OSTYPE="Gentoo" 315 | which zypper 2>&1 && OSTYPE="SUSE" 316 | which rug 2>&1 && OSTYPE="Novell" 317 | #which smart 2>&1 && OSTYPE="Smart" # http://labix.org/smart 318 | 319 | OSDIST= 320 | OSVERSION= 321 | OSNAME= 322 | 323 | case "$OSTYPE" in 324 | Debian) 325 | if ! which lsb_release &> /dev/null; then 326 | $EXEC_APTGET install -y lsb-release 327 | fi 328 | ;; 329 | 330 | RedHat) 331 | EXEC_APTGET="${EXEC_SUDO} `which yum`" 332 | #yum whatprovides */lsb_release 333 | if ! which lsb_release &> /dev/null; then 334 | $EXEC_APTGET --skip-broken install -y redhat-lsb-core 335 | fi 336 | ;; 337 | 338 | Arch) 339 | EXEC_APTGET="`which pacman`" 340 | if [ -f "/etc/os-release" ]; then 341 | OSDIST=$(cat /etc/os-release | grep ^ID= | awk -F= '{print $2}') 342 | OSVERSION=1 343 | OSNAME=arch 344 | fi 345 | ;; 346 | 347 | OpenWrt) 348 | EXEC_APTGET="`which opkg`" 349 | if [ -f "/etc/os-release" ]; then 350 | OSDIST=$(cat /etc/os-release | grep ^ID= | awk -F= '{print $2}') 351 | OSVERSION=1 352 | #OSDIST=$(cat /etc/os-release | grep ^NAME= | awk -F= '{print $2}') 353 | OSDIST= 354 | if [ x${OSDIST} = x ]; then 355 | OSNAME=openwrt 356 | fi 357 | fi 358 | if [ ! -f "/tmp/opkg-lists/reboot_base" ]; then 359 | $DO_EXEC $EXEC_APTGET update 360 | fi 361 | ;; 362 | *) 363 | mr_trace "[ERR] Not supported OS: $OSTYPE" 364 | exit 0 365 | ;; 366 | esac 367 | 368 | if which lsb_release &> /dev/null; then 369 | OSDIST=$(lsb_release -is) 370 | OSVERSION=$(lsb_release -rs) 371 | OSNAME=$(lsb_release -cs) 372 | fi 373 | if [ "${OSDIST}" = "" ]; then 374 | mr_trace "Error: Not found lsb_release!" 375 | fi 376 | mr_trace "[INFO] Detected $OSTYPE system: $OSDIST $OSVERSION $OSNAME" 377 | export OSTYPE 378 | export OSDIST 379 | export OSVERSION 380 | export OSNAME 381 | } 382 | 383 | ##################################################################### 384 | ## @fn hput() 385 | ## @brief put a value to hash table 386 | ## @param key the key 387 | ## @param value the value 388 | ## 389 | ## put a value to hash table 390 | hput() { 391 | local KEY=`echo "$1" | tr '[:punct:][:blank:]-' '_'` 392 | eval export hash"$KEY"='$2' 393 | } 394 | 395 | ## @fn hget() 396 | ## @brief get a value from hash table 397 | ## @param key the key 398 | ## 399 | ## get a value from hash table 400 | hget() { 401 | local KEY=`echo "$1" | tr '[:punct:][:blank:]-' '_'` 402 | eval echo '${hash'"$KEY"'#hash}' 403 | } 404 | 405 | ## @fn hiter() 406 | ## @brief list all of values in the hash table 407 | ## 408 | hiter() { 409 | for h in $(eval echo '${!'$1'*}') ; do 410 | local key=${h#$1*} 411 | echo "$key=`hget $key`" 412 | done 413 | } 414 | 415 | ## @fn ospkgset() 416 | ## @brief set package name mapping 417 | ## @param key the key package name (Debian) 418 | ## @param vredhat the map package name for RedHat 419 | ## @param varch the map package name for Arch 420 | ## 421 | ## set package name mapping for debian,redhat,arch 422 | ospkgset() { 423 | local PARAM_KEY=$1 424 | shift 425 | local PARAM_REDHAT=$1 426 | shift 427 | local PARAM_ARCH=$1 428 | shift 429 | local PARAM_OPENWRT=$1 430 | shift 431 | hput "pkg_RedHat_$PARAM_KEY" "$PARAM_REDHAT" 432 | hput "pkg_Arch_$PARAM_KEY" "$PARAM_ARCH" 433 | hput "pkg_OpenWrt_$PARAM_KEY" "$PARAM_OPENWRT" 434 | } 435 | 436 | ## @fn ospkgget() 437 | ## @brief get package name mapping 438 | ## @param os the OS name. RedHat or Arch 439 | ## @param key the key package name (Debian) 440 | ## 441 | ## get package name mapping for debian,redhat,arch 442 | ospkgget() { 443 | local PARAM_OS=$1 444 | shift 445 | local PARAM_KEY=$1 446 | shift 447 | if [ "$PARAM_OS" = "Debian" ]; then 448 | echo "${PARAM_KEY}" 449 | return 450 | fi 451 | hget "pkg_${PARAM_OS}_${PARAM_KEY}" 452 | } 453 | 454 | # Debian/Ubuntu, RedHat/Fedora/CentOS, Arch, OpenWrt 455 | ospkgset apt-get yum pacman opkg 456 | ospkgset apt-file yum pkgfile opkg 457 | ospkgset u-boot-tools uboot-tools uboot-tools uboot-envtools 458 | ospkgset mtd-utils mtd-utils mtd-utils mtd-utils 459 | ospkgset initramfs-tools initramfs-tools mkinitcpio 460 | ospkgset build-essential 'Development Tools' base-devel "" 461 | ospkgset devscripts rpmdevtools abs 462 | ospkgset lsb-release redhat-lsb-core redhat-lsb-core "" 463 | ospkgset openssh-client openssh-clients openssh-clients openssh-client 464 | ospkgset parted parted parted parted 465 | ospkgset subversion svn svn subversion-client 466 | ospkgset git-all git git git 467 | ospkgset dhcp3-server dhcp dhcp dnsmasq 468 | ospkgset dhcp3-client dhcp dhcpcd dnsmasq 469 | ospkgset tftpd-hpa tftp-server tftp-hpa dnsmasq 470 | ospkgset syslinux syslinux syslinux syslinux 471 | ospkgset pxelinux syslinux syslinux syslinux 472 | ospkgset nfs-kernel-server nfs-utils nfs-utils nfs-kernel-server 473 | ospkgset nfs-common nfs-utils nfs-utils nfs-utils 474 | ospkgset bind9 bind bind bind-server 475 | ospkgset portmap portmap "" portmap 476 | ospkgset libncurses-dev ncurses-devel ncurses libncurses-dev 477 | ospkgset kpartx kpartx multipath-tools 478 | ospkgset lib32stdc++6 libstdc++.i686 lib32-libstdc++5 479 | # libstdc++.so.6 480 | ospkgset lib32z1 zlib.i686 lib32-zlib 481 | ospkgset libjpeg62-turbo-dev libjpeg62-turbo libjpeg-turbo 482 | 483 | ospkgset u-boot-tools uboot-tools uboot-tools 484 | ospkgset bsdtar bsdtar libarchive 485 | 486 | ospkgset uuid-runtime util-linux util-linux 487 | 488 | 489 | ospkgset wiringpi wiringpi wiringpi-git 490 | 491 | 492 | # fixme: fedora: pixz? 493 | ospkgset pixz xz pixz 494 | 495 | # fix me: fedora has no equilant to qemu-user-static! qemu-arm-static 496 | ospkgset qemu-user-static qemu-user qemu-user-static-exp 497 | #ospkgset qemu qemu qemu # gentoo: app-emulation/qemu 498 | 499 | # fedora, qemu provides qemu.binfmt, and the kernel already contains binfmt support 500 | ospkgset binfmt-support qemu binfmt-support 501 | 502 | ospkgset apache2 httpd apache apache 503 | #ospkgset apache2-mpm-prefork 504 | #ospkgset apache2-utils 505 | ospkgset libapache2-mod-php5 php-apache php-apache php7-fpm 506 | ospkgset php5-common php php-apache php7 507 | #ospkgset php5-cli php php php7-cli 508 | #ospkgset php5-mcrypt "" "" php7-mod-mcrypt 509 | #ospkgset php5-mysql php-mysql "" php7-mod-mysqli 510 | #ospkgset php5-pgsql "" "" 511 | ospkgset php5-sqlite php-sqlite php-sqlite php7-mod-sqlite3 512 | #ospkgset php5-dev "" "" "" 513 | #ospkgset php5-curl "" "" "" 514 | #ospkgset php5-idn "" "" "" 515 | ospkgset php5-imagick php-imagick php-imagick "" 516 | #ospkgset php5-imap "" "" "" 517 | #ospkgset php5-memcache "" "" "" 518 | #ospkgset php5-ps "" "" "" 519 | #ospkgset php5-pspell "" "" "" 520 | #ospkgset php5-recode "" "" "" 521 | #ospkgset php5-tidy "" "" "" 522 | #ospkgset php5-xmlrpc "" "" "" 523 | #ospkgset php5-xsl "" "" "" 524 | #ospkgset php5-json "" "" "" 525 | #ospkgset php5-gd php-gd "" "" 526 | #ospkgset php5-snmp php-snmp "" "" 527 | #ospkgset php-versioncontrol-svn "" "" "" 528 | #ospkgset php-pear php-pear "" "" 529 | ospkgset snmp net-snmp-utils net-snmp snmpd 530 | ospkgset graphviz graphviz graphviz "" 531 | ospkgset php5-mcrypt php-mcrypt php-mcrypt php7-mod-mcrypt 532 | ospkgset mysql-server mysql-server mariadb mysql-server 533 | ospkgset mysql-client mysql mariadb-clients mysql-server 534 | #ospkgset mysql-perl ? perl-dbd-mysql 535 | #ospkgset rrdtool rrdtool "" rrdtool1 536 | #ospkgset fping fping fping fping 537 | ospkgset imagemagick ImageMagick imagemagick "" 538 | ospkgset whois jwhois whois "" 539 | ospkgset mtr-tiny mtr mtr mtr 540 | ospkgset nmap nmap nmap nmap 541 | ospkgset ipmitool ipmitool ipmitool ipmitool 542 | ospkgset python-mysqldb MySQL-python mysql-python python-mysql 543 | 544 | # mount loop, openwrt 545 | # block-mount komd-loop kmod-fs-isofs 546 | ospkgset gpsd gpsd gpsd 547 | ospkgset gpsd-clients gpsd-clients gpsd 548 | 549 | ## @fn patch_centos_gawk() 550 | ## @brief compile gawk with switch support 551 | ## @param os the OS name. RedHat or Arch 552 | ## @param key the key package name (Debian) 553 | ## 554 | ## compile gawk with switch support and install it to system. 555 | ## WARNING: the CentOS boot program depend the awk, and if the system upgrade the gawk again, 556 | ## new installed gawk will not support 557 | patch_centos_gawk() { 558 | $DO_EXEC yum -y install rpmdevtools readline-devel #libsigsegv-devel 559 | $DO_EXEC yum -y install gcc byacc 560 | $DO_EXEC rpmdev-setuptree 561 | 562 | #FILELIST="gawk.spec gawk-3.1.8.tar.bz2 gawk-3.1.8-double-free-wstptr.patch gawk-3.1.8-syntax.patch" 563 | #URL="http://archive.fedoraproject.org/pub/archive/fedora/linux/updates/14/SRPMS/gawk-3.1.8-3.fc14.src.rpm" 564 | FILELIST="gawk.spec gawk-4.0.1.tar.gz" 565 | URL="http://archive.fedoraproject.org/pub/archive/fedora/linux/updates/17/SRPMS/gawk-4.0.1-1.fc17.src.rpm" 566 | cd ~/rpmbuild/SOURCES/; rm -f ${FILELIST}; cd - > /dev/null; rm -f ${FILELIST} 567 | $DO_EXEC wget -c "${URL}" -O ~/rpmbuild/SRPMS/$(basename "${URL}") 568 | $DO_EXEC rpm2cpio ~/rpmbuild/SRPMS/$(basename "${URL}") | cpio -div 569 | $DO_EXEC mv ${FILELIST} ~/rpmbuild/SOURCES/ 570 | $DO_EXEC sed -i 's@configure @configure --enable-switch --disable-libsigsegv @g' ~/rpmbuild/SOURCES/$(echo "${FILELIST}" | awk '{print $1}') 571 | $DO_EXEC sed -i 's@--with-libsigsegv-prefix=[^ ]*@@g' ~/rpmbuild/SOURCES/$(echo "${FILELIST}" | awk '{print $1}') 572 | $DO_EXEC sed -i 's@Conflicts: filesystem@#Conflicts: filesystem@g' ~/rpmbuild/SOURCES/$(echo "${FILELIST}" | awk '{print $1}') 573 | 574 | # we don't install gawk to system's directory 575 | # instead, we install the new gawk in ~/bin 576 | #$DO_EXEC rpmbuild -bb --clean ~/rpmbuild/SOURCES/$(echo "${FILELIST}" | awk '{print $1}') 577 | ##$DO_EXEC ${EXEC_SUDO} rpm -U --force ~/rpmbuild/RPMS/$(uname -i)/gawk-4.0.1-1.el6.$(uname -i).rpm 578 | #$DO_EXEC ${EXEC_SUDO} rpm -U --force ~/rpmbuild/RPMS/$(uname -p)/gawk-4.0.1-1.el6.$(uname -p).rpm 579 | #$DO_EXEC ln -s $(which gawk) /bin/gawk 580 | #$DO_EXEC ln -s $(which gawk) /bin/awk 581 | $DO_EXEC rpmbuild -bb ~/rpmbuild/SOURCES/$(echo "${FILELIST}" | awk '{print $1}') 582 | $DO_EXEC mkdir -p ~/bin/ 583 | $DO_EXEC cp ~/rpmbuild/BUILD/gawk-4.0.1/gawk ~/bin/ 584 | $DO_EXEC ln -s ~/bin/gawk ~/bin/awk 585 | $DO_EXEC rm -rf ~/rpmbuild/BUILD/gawk-4.0.1/ 586 | } 587 | 588 | DN_INSTALLED_SYSLINUX="${DN_TMP}/syslinux-6.03/myinstall/" 589 | 590 | ## @fn download_extract_2tmp_syslinux() 591 | ## @brief download syslinux files 592 | ## 593 | ## download the syslinux files for non-x86 platforms 594 | download_extract_2tmp_syslinux () { 595 | mr_trace "[DBG] download and extract syslinux for i686/x86_64 platform ..." 596 | 597 | $DO_EXEC mkdir -p "${DN_TMP}" 598 | $DO_EXEC cd "${DN_TMP}" 599 | URL_REAL="https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-6.03.tar.gz" 600 | FN_SYSLI=$(basename "${URL_REAL}") 601 | 602 | $DO_EXEC wget --no-check-certificate "${URL_REAL}" 603 | 604 | if [ -f "${FN_SYSLI}" ]; then 605 | $DO_EXEC extract_file "${FN_SYSLI}" 606 | DN_SRC="${DN_TMP}/syslinux-6.03/" 607 | DN_INSTALL=${DN_SRC}/myinstall/ 608 | $DO_EXEC mkdir -p "${DN_INSTALL}" 609 | $DO_EXEC cp "${DN_SRC}/bios/core/pxelinux.0" "${DN_INSTALLED_SYSLINUX}" 610 | $DO_EXEC cp "${DN_SRC}/bios/memdisk/memdisk" "${DN_INSTALLED_SYSLINUX}" 611 | $DO_EXEC cp "${DN_SRC}/bios/com32/elflink/ldlinux/ldlinux.c32" "${DN_INSTALLED_SYSLINUX}" 612 | $DO_EXEC cp "${DN_SRC}/bios/com32/menu/vesamenu.c32" "${DN_INSTALLED_SYSLINUX}" 613 | $DO_EXEC cp "${DN_SRC}/bios/com32/lib/libcom32.c32" "${DN_INSTALLED_SYSLINUX}" 614 | $DO_EXEC cp "${DN_SRC}/bios/com32/libutil/libutil.c32" "${DN_INSTALLED_SYSLINUX}" 615 | 616 | $DO_EXEC cp "${DN_SRC}/bios/com32/menu/menu.c32" "${DN_INSTALLED_SYSLINUX}" 617 | $DO_EXEC cp "${DN_SRC}/bios/com32/mboot/mboot.c32" "${DN_INSTALLED_SYSLINUX}" 618 | $DO_EXEC cp "${DN_SRC}/bios/com32/chain/chain.c32" "${DN_INSTALLED_SYSLINUX}" 619 | 620 | else 621 | mr_trace "[ERR] not found file ${FN_SYSLI}" 622 | fi 623 | $DO_EXEC cd - 624 | } 625 | 626 | # download Arch Linux package syslinux 627 | download_extract_2tmp_syslinux_from_arch () { 628 | mr_trace "[DBG] download and extract syslinux for i686/x86_64 platform ..." 629 | 630 | $DO_EXEC mkdir -p "${DN_TMP}" 631 | $DO_EXEC cd "${DN_TMP}" 632 | 633 | DATE1=$(date +%Y-%m-%d) 634 | $DO_EXEC rm -f index.html* 635 | URL_ORIG="https://www.archlinux.org/packages/core/i686/syslinux/download/" 636 | URL_REAL=$(wget --no-check-certificate ${URL_ORIG} 2>&1 | grep pkg | grep $DATE1 | awk '{print $3}') 637 | FN_SYSLI=$(basename "${URL_REAL}") 638 | if [ ! -f "${FN_SYSLI}" ]; then 639 | if [ ! -f index.html ]; then 640 | mr_trace "[ERR] not found downloaded file from ${URL_ORIG}(${URL_REAL})" 641 | else 642 | mr_trace "[DBG] rename index.html to ${FN_SYSLI}" 643 | $DO_EXEC mv index.html "${FN_SYSLI}" 644 | fi 645 | fi 646 | if [ -f "${FN_SYSLI}" ]; then 647 | $DO_EXEC extract_file "${FN_SYSLI}" 648 | else 649 | mr_trace "[ERR] not found file ${FN_SYSLI}" 650 | fi 651 | 652 | $DO_EXEC cd - 653 | } 654 | 655 | ## @fn yum_groupinfo() 656 | ## @brief a wrap for "yum groupinfo" to return correct value 657 | ## @param name the package names 658 | yum_groupinfo() { 659 | PARAM_PKG=$1 660 | yum groupinfo "${PARAM_PKG}" 2>&1 | grep -i "Warning: " | grep -i "not exist." > /dev/null 661 | if [ "$?" = "0" ]; then 662 | #return 1 663 | mkdir /a/b/c/d/e/f/ 664 | else 665 | #return 0 666 | mkdir -p /tmp 667 | fi 668 | } 669 | 670 | ## @fn yum_groupcheck() 671 | ## @brief check if a group installed 672 | ## @param name the package names 673 | yum_groupcheck() { 674 | PARAM_PKG=$1 675 | yum_groupinfo "${PARAM_PKG}" 676 | if [ ! "$?" = "0" ]; then 677 | mkdir /a/b/c/d/e/f/ 678 | else 679 | yes no | yum groupupdate "${PARAM_PKG}" 2>&1 | grep -i "Dependent packages" > /dev/null 680 | if [ "$?" = "0" ]; then 681 | #return 1 682 | mkdir /a/b/c/d/e/f/ 683 | else 684 | #return 0 685 | mkdir -p /tmp 686 | fi 687 | fi 688 | } 689 | 690 | opkg_list() { 691 | opkg list $1 | grep $1 692 | } 693 | 694 | ## @fn check_available_package() 695 | ## @brief check if the packages exist 696 | ## @param name the package names 697 | check_available_package() { 698 | local PARAM_NAME=$* 699 | #local INSTALLER=`ospkgget $OSTYPE apt-get` 700 | local EXEC_CHKPKG="dpkg -s" 701 | local EXEC_CHKGRP="dpkg -s" 702 | case "$OSTYPE" in 703 | RedHat) 704 | EXEC_CHKPKG="yum info" 705 | EXEC_CHKGRP="yum info" 706 | ;; 707 | 708 | Arch) 709 | EXEC_CHKPKG="pacman -Si" 710 | EXEC_CHKGRP="pacman -Sg" 711 | ;; 712 | Gentoo) 713 | EXEC_CHKPKG="emerge -S" 714 | EXEC_CHKGRP="emerge -S" 715 | ;; 716 | OpenWrt) 717 | EXEC_CHKPKG=opkg_list 718 | EXEC_CHKGRP=opkg_list 719 | ;; 720 | *) 721 | mr_trace "[ERR] Not supported OS: $OSTYPE" 722 | exit 0 723 | ;; 724 | esac 725 | #mr_trace "enter arch for pkgs: ${PARAM_NAME}" 726 | for i in $PARAM_NAME ; do 727 | #mr_trace "enter loop arch for pkg: ${i}" 728 | PKG=$(ospkgget $OSTYPE $i) 729 | if [ "${PKG}" = "" ]; then 730 | PKG="$i" 731 | fi 732 | mr_trace "check available pkg: ${PKG}" 733 | ${EXEC_CHKPKG} "${PKG}" > /dev/null 734 | if [ ! "$?" = "0" ]; then 735 | ${EXEC_CHKGRP} "${PKG}" > /dev/null 736 | if [ ! "$?" = "0" ]; then 737 | echo "fail" 738 | mr_trace "check available pkg: ${PKG} return fail!" 739 | return 740 | fi 741 | fi 742 | done 743 | mr_trace "check available pkg: ${PARAM_NAME} return ok!" 744 | echo "ok" 745 | } 746 | 747 | opkg_listinstalled() { 748 | opkg list-installed $1 | grep $1 749 | } 750 | 751 | ## @fn check_installed_package() 752 | ## @brief check if the packages installed 753 | ## @param name the package names 754 | check_installed_package() { 755 | local PARAM_NAME=$* 756 | #local INSTALLER=`ospkgget $OSTYPE apt-get` 757 | local EXEC_CHKPKG="dpkg -s" 758 | local EXEC_CHKGRP="dpkg -s" 759 | case "$OSTYPE" in 760 | RedHat) 761 | EXEC_CHKPKG="rpm -qi" 762 | EXEC_CHKGRP="yum_groupcheck" 763 | ;; 764 | 765 | Arch) 766 | EXEC_CHKPKG="pacman -Qi" 767 | EXEC_CHKGRP="pacman -Qg" 768 | ;; 769 | Gentoo) 770 | EXEC_CHKPKG="emerge -pv" # and emerge -S 771 | EXEC_CHKGRP="emerge -pv" # and emerge -S 772 | ;; 773 | OpenWrt) 774 | EXEC_CHKPKG=opkg_listinstalled 775 | EXEC_CHKGRP=opkg_listinstalled 776 | ;; 777 | *) 778 | mr_trace "[ERR] Not supported OS: $OSTYPE" 779 | exit 0 780 | ;; 781 | esac 782 | #mr_trace "enter arch for pkgs: ${PARAM_NAME}" 783 | for i in $PARAM_NAME ; do 784 | #mr_trace "enter loop arch for pkg: ${i}" 785 | PKG0=$(echo "$i" | awk -F\> '{print $1}') 786 | PKG=$(ospkgget $OSTYPE $PKG0) 787 | if [ "${PKG}" = "" ]; then 788 | PKG="${PKG0}" 789 | fi 790 | mr_trace "check installed pkg: ${PKG}" 791 | ${EXEC_CHKPKG} "${PKG}" > /dev/null 792 | if [ ! "$?" = "0" ]; then 793 | ${EXEC_CHKGRP} "${PKG}" > /dev/null 794 | if [ ! "$?" = "0" ]; then 795 | echo "fail" 796 | mr_trace "check installed pkg: ${PKG} return fail!" 797 | return 798 | fi 799 | fi 800 | done 801 | mr_trace "check installed pkg: ${PARAM_NAME} return ok!" 802 | echo "ok" 803 | #set +x 804 | } 805 | 806 | ## @fn install_package() 807 | ## @brief install software packages 808 | ## @param name the package names 809 | ## 810 | ## using the package name of Debian, and convert to the name of the underlying distribution. 811 | ## the package gawk or syslinux will be handled in a different way 812 | install_package() { 813 | local PARAM_NAME=$* 814 | local INSTALLER=`ospkgget $OSTYPE apt-get` 815 | 816 | mr_trace ospkgget $OSTYPE apt-get 817 | mr_trace "INSTALLER=${INSTALLER}" 818 | 819 | local PKGLST= 820 | local FLG_GAWK_RH=0 821 | for i in $PARAM_NAME ; do 822 | local PKG=$(ospkgget $OSTYPE $i) 823 | if [ "${PKG}" = "" ]; then 824 | PKG="$i" 825 | fi 826 | mr_trace "try to install package: $PKG($i)" 827 | if [ "$i" = "gawk" ]; then 828 | if [ "$OSTYPE" = "RedHat" ]; then 829 | mr_trace "[DBG] patch gawk to support 'switch'" 830 | echo | awk '{a = 1; switch(a) { case 0: break; } }' > /dev/null 831 | if [ $? = 1 ]; then 832 | FLG_GAWK_RH=1 833 | PKG="rpmdevtools libsigsegv-devel readline-devel" 834 | fi 835 | fi 836 | fi 837 | 838 | mr_trace "[DBG] OSTYPE = $OSTYPE" 839 | if [ "$OSTYPE" = "Arch" ]; then 840 | if [ "$i" = "portmap" ]; then 841 | mr_trace "[DBG] Ignore $i" 842 | PKG="" 843 | fi 844 | fi 845 | if [ "$i" = "syslinux" ]; then 846 | MACH=$(uname -m) 847 | case "$MACH" in 848 | x86_64|i386|i686) 849 | mr_trace "[DBG] use standard method" 850 | ;; 851 | 852 | *) 853 | mr_trace "[DBG] $MACH yet another installation of $i" 854 | mr_trace "[DBG] Download package for $MACH" 855 | download_extract_2tmp_syslinux 856 | ;; 857 | esac 858 | fi 859 | PKGLST="${PKGLST} ${PKG}" 860 | done 861 | 862 | local INST_OPTS="" 863 | case "$OSTYPE" in 864 | Debian) 865 | INST_OPTS="install -y --force-yes" 866 | ;; 867 | 868 | RedHat) 869 | INST_OPTS="install -y" 870 | ;; 871 | 872 | Arch) 873 | INST_OPTS="-S" 874 | # install loop module 875 | lsmod | grep loop > /dev/null 876 | if [ "$?" != "0" ]; then 877 | modprobe loop > /dev/null 878 | 879 | grep -Hrn loop /etc/modules-load.d/ 880 | if [ "$?" != "0" ]; then 881 | echo "loop" > /etc/modules-load.d/tftpboot.conf 882 | fi 883 | fi 884 | ;; 885 | OpenWrt) 886 | INST_OPTS="install" 887 | ;; 888 | 889 | *) 890 | mr_trace "[ERR] Not supported OS: $OSTYPE" 891 | exit 0 892 | ;; 893 | esac 894 | 895 | mr_trace ${EXEC_SUDO} ${INSTALLER} ${INST_OPTS} ${PKGLST} 896 | $DO_EXEC ${EXEC_SUDO} ${INSTALLER} ${INST_OPTS} ${PKGLST} 897 | if [ "${FLG_GAWK_RH}" = "1" ]; then 898 | patch_centos_gawk 899 | fi 900 | } 901 | 902 | install_package_skip_installed() { 903 | local PARAM_NAME=$* 904 | 905 | local RET=0 906 | for PKG1x5 in $PARAM_NAME ; do 907 | RET=$(check_installed_package ${PKG1x5}) 908 | if [ ! "$RET" = "ok" ]; then 909 | install_package ${PKG1x5} 910 | fi 911 | done 912 | } 913 | 914 | ## @fn install_arch_yaourt() 915 | ## @brief install yaourt for Arch Linux 916 | install_arch_yaourt() { 917 | wget https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz 918 | 919 | pacman -Qi package-query >> /dev/null 920 | if [ ! "$?" = "0" ]; then 921 | wget https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz 922 | tar -xf package-query.tar.gz \ 923 | && cd package-query \ 924 | && makepkg -Asf \ 925 | && ${EXEC_SUDO} pacman -U ./package-query-*.xz \ 926 | && cd .. 927 | fi 928 | 929 | tar -xf yaourt.tar.gz \ 930 | && cd yaourt \ 931 | && makepkg -Asf \ 932 | && ${EXEC_SUDO} pacman -U ./yaourt-*.xz \ 933 | && cd .. 934 | } 935 | 936 | ## @fn install_package_alt() 937 | ## @brief install alternative packages 938 | ## @param name the package names 939 | install_package_alt() { 940 | local PARAM_NAME=$* 941 | local INSTALLER=`ospkgget $OSTYPE apt-get` 942 | 943 | local INST_OPTS="" 944 | case "$OSTYPE" in 945 | Debian) 946 | INST_OPTS="install -y --force-yes" 947 | ;; 948 | 949 | RedHat) 950 | INST_OPTS="groupinstall -y" 951 | ;; 952 | 953 | Arch) 954 | if [ ! -x "$(which yaourt)" ]; then 955 | install_arch_yaourt >> "${FN_LOG}" 956 | fi 957 | if [ ! -x "$(which yaourt)" ]; then 958 | echo "Error in get yaourt!" >> "${FN_LOG}" 959 | exit 1 960 | fi 961 | INSTALLER="yaourt" 962 | INST_OPTS="" 963 | ;; 964 | *) 965 | echo "[ERR] Not supported OS: $OSTYPE" >> "${FN_LOG}" 966 | exit 0 967 | ;; 968 | esac 969 | for i in $PARAM_NAME ; do 970 | PKG=$(ospkgget $OSTYPE $i) 971 | if [ "${PKG}" = "" ]; then 972 | PKG="$i" 973 | fi 974 | echo "try to install 3rd packages: ${PKG}" >> "${FN_LOG}" 975 | ${EXEC_SUDO} $INSTALLER ${INST_OPTS} "${PKG}" >> "${FN_LOG}" 976 | if [ ! "$?" = "0" ]; then 977 | echo "fail" 978 | return 979 | fi 980 | done 981 | echo "ok" 982 | } 983 | 984 | ## @fn check_install_package() 985 | ## @brief check if command is not exist, then install the package 986 | ## @param bin the binary name 987 | ## @param pkg the package name 988 | check_install_package() { 989 | local PARAM_BIN=$1 990 | shift 991 | local PARAM_PKG=$1 992 | shift 993 | if [ ! -x "${PARAM_BIN}" ]; then 994 | install_package "${PARAM_PKG}" 995 | fi 996 | } 997 | 998 | detect_os_type 1>&2 999 | 1000 | #for h in ${!hash*}; do indirect=$hash$h; echo ${!indirect}; done 1001 | #hiter hash 1002 | #install_package apt-get subversion 1003 | #exit 0 1004 | 1005 | ###################################################################### 1006 | EXEC_SSH="$(which ssh)" 1007 | if [ ! -x "${EXEC_SSH}" ]; then 1008 | mr_trace "[DBG] Try to install ssh." 1009 | install_package openssh-client 1010 | fi 1011 | 1012 | EXEC_SSH="$(which ssh)" 1013 | if [ ! -x "${EXEC_SSH}" ]; then 1014 | mr_trace "[ERR] Not exist ssh!" 1015 | exit 1 1016 | fi 1017 | EXEC_SSH="$(which ssh) -oBatchMode=yes -CX" 1018 | 1019 | EXEC_XZ="$(which xz)" 1020 | if [ ! -x "${EXEC_XZ}" ]; then 1021 | mr_trace "[DBG] Try to install xz." 1022 | install_package xz 1023 | fi 1024 | EXEC_XZ="$(which xz)" 1025 | if [ ! -x "${EXEC_XZ}" ]; then 1026 | mr_trace "[ERR] Not exist xz!" 1027 | exit 1 1028 | fi 1029 | 1030 | EXEC_AWK="$(which gawk)" 1031 | if [ ! -x "${EXEC_AWK}" ]; then 1032 | mr_trace "[DBG] Try to install gawk." 1033 | install_package gawk 1034 | fi 1035 | 1036 | EXEC_AWK="$(which gawk)" 1037 | if [ ! -x "${EXEC_AWK}" ]; then 1038 | mr_trace "[ERR] Not exist awk!" 1039 | exit 1 1040 | fi 1041 | 1042 | ###################################################################### 1043 | # ssh 1044 | 1045 | ## @fn ssh_check_id_file() 1046 | ## @brief generate the cert of localhost 1047 | ssh_check_id_file() { 1048 | if [ ! -f ~/.ssh/id_rsa.pub ]; then 1049 | mr_trace "[DBG] generate id ..." 1050 | mkdir -p ~/.ssh/ 1051 | ssh-keygen 1052 | fi 1053 | } 1054 | 1055 | ## @fn ssh_ensure_connection() 1056 | ## @brief ensure the local id_rsa.pub copied to remote host to setup the SSH connection without key 1057 | ssh_ensure_connection() { 1058 | local PARAM_SSHURL="${1}" 1059 | mr_trace "[DBG] test host: ${PARAM_SSHURL}" 1060 | $EXEC_SSH "${PARAM_SSHURL}" "ls > /dev/null" 1061 | if [ ! "$?" = "0" ]; then 1062 | mr_trace "[DBG] copy id to ${PARAM_SSHURL} ..." 1063 | ssh-copy-id -i ~/.ssh/id_rsa.pub "${PARAM_SSHURL}" 1064 | else 1065 | mr_trace "[DBG] pass id : ${PARAM_SSHURL}." 1066 | fi 1067 | if [ "$?" = "0" ]; then 1068 | $EXEC_SSH "${PARAM_SSHURL}" "yum -y install xauth libcanberra-gtk2 dejavu-lgc-sans-fonts" 1069 | fi 1070 | } 1071 | 1072 | ###################################################################### 1073 | # Math Lib: 1074 | 1075 | # 最大公约数 (Greatest Common Divisor, GCD) 1076 | # 最小公倍数 (Least Common Multiple, LCM) 1077 | 1078 | ## @fn gcd() 1079 | ## @brief Greatest Common Divisor, GCD 1080 | ## @param num1 number 1 1081 | ## @param num2 number 2 1082 | ## 1083 | ## example: 1084 | ## gcd 6 15 1085 | ## 30 1086 | gcd() { 1087 | local PARAM_NUM1=$1 1088 | shift 1089 | local PARAM_NUM2=$1 1090 | shift 1091 | 1092 | local NUM1=$PARAM_NUM1 1093 | local NUM2=$PARAM_NUM2 1094 | if [ $(echo | awk -v A=$NUM1 -v B=$NUM2 '{ if (A>24)).$(($1>>16&255)).$(($1>>8&255)).$(($1&255)) 1131 | } 1132 | 1133 | # convert the string to IPv4 configurations 1134 | # Example: 1135 | # IPv4_convert "192.168.1.15/17" 1136 | #echo "netIP=$OUTPUT_IPV4_IP" 1137 | #echo "netMASK=$OUTPUT_IPV4_MASK" 1138 | #echo "netBCST=$OUTPUT_IPV4_BROADCAST" 1139 | #echo "network=$OUTPUT_IPV4_NETWORK" 1140 | #echo "first ip=${OUTPUT_IPV4_FIRSTIP}" 1141 | #echo "DHCP_UNKNOW=${OUTPUT_IPV4_DHCP_UNKNOW_RANGE}" 1142 | #echo "DHCP_KNOW=${OUTPUT_IPV4_DHCP_KNOW_RANGE}" 1143 | IPv4_convert() { 1144 | local PARAM_IP="$1" 1145 | shift 1146 | 1147 | netIP=$(echo $PARAM_IP | awk -F/ '{print $1}') 1148 | intIP=$(IPv4_check_ok $netIP) || die "Submitted IP: '$netIP' is not an IPv4 address." 1149 | 1150 | LEN=$(echo $PARAM_IP | awk -F/ '{print $2}') 1151 | intMASK0=$(( ( (1<<$LEN) - 1 ) << ( 32 - $LEN ) )) 1152 | #echo "intMASK0=$intMASK0" 1153 | netMASK=$( IPv4_from_int $intMASK0 ) 1154 | intMASK=$(IPv4_check_ok $netMASK) || die "Submitted Mask: '$netMASK' not IPv4." 1155 | if [ ! "$intMASK0" = "$intMASK" ]; then 1156 | die "Mask convert error: 0-'$intMASK0'; 1-'$intMASK'" 1157 | fi 1158 | 1159 | intBCST=$(( intIP | intMASK ^ ( (1<<32) - 1 ) )) 1160 | intBASE=$(( intIP & intMASK )) 1161 | netBCST=$( IPv4_from_int $(( intIP | intMASK ^ ( (1<<32) - 1 ) )) ) 1162 | netBASE=$( IPv4_from_int $(( intIP & intMASK )) ) 1163 | 1164 | OUTPUT_IPV4_IP="$netIP" 1165 | OUTPUT_IPV4_MASK="$netMASK" 1166 | OUTPUT_IPV4_BROADCAST="$netBCST" 1167 | OUTPUT_IPV4_NETWORK="$netBASE" 1168 | OUTPUT_IPV4_FIRSTIP=$( IPv4_from_int $(( intBASE + 1 )) ) 1169 | 1170 | RESERV_RATIO="4/5" 1171 | #mr_trace "LEN = $LEN" 1172 | #mr_trace "RESERV_RATIO = $RESERV_RATIO" 1173 | SZ=$(( ( 1 << ( 32 - $LEN ) ) - 2 )) 1174 | #mr_trace "SZ-0 = $SZ" 1175 | SZ2=$(( ( $SZ - $SZ * $RESERV_RATIO ) * 3 / 4 )) 1176 | #mr_trace "SZ2-0 = $SZ2" 1177 | [ $SZ2 -lt 100 ] || SZ2=100 1178 | #mr_trace "SZ2-1 = $SZ2" 1179 | [ $SZ2 -gt 0 ] || SZ2=1 1180 | #mr_trace "SZ2-2 = $SZ2" 1181 | SZ1=$(( ( $SZ - $SZ * $RESERV_RATIO ) - $SZ2 )) 1182 | #mr_trace "SZ1-0 = $SZ1" 1183 | [ $SZ1 -lt 10 ] || SZ1=10 1184 | #mr_trace "SZ1-1 = $SZ1" 1185 | [ $SZ1 -gt 0 ] || SZ1=1 1186 | #mr_trace "SZ1-2 = $SZ1" 1187 | SZLEFT=$(( $SZ - $SZ1 - $SZ2 )) 1188 | #mr_trace "SZLEFT-0 = $SZLEFT" 1189 | [ $SZLEFT -gt 0 ] || SZLEFT=$(( ( $SZ / 3 + $SZ ) * $RESERV_RATIO )) 1190 | #mr_trace "SZLEFT-1 = $SZLEFT" 1191 | [ $SZLEFT -gt 0 ] || SZLEFT=1 1192 | #mr_trace "SZLEFT-2 = $SZLEFT" 1193 | SZ1=$(( ( $SZ - $SZLEFT ) / 2 )) 1194 | [ $SZ1 -lt 10 ] || SZ1=10 1195 | [ $SZ1 -gt 0 ] || SZ1=0 1196 | SZ2=$(( $SZ - $SZLEFT - $SZ1 )) 1197 | [ $SZ2 -lt 100 ] || SZ2=100 1198 | [ $SZ2 -gt 0 ] || SZ2=0 1199 | SZLEFT=$(( $SZ - $SZ1 - $SZ2 )) 1200 | #mr_trace SZ1=$SZ1 1201 | #mr_trace SZ2=$SZ2 1202 | #mr_trace SZLEFT=$SZLEFT 1203 | 1204 | MID=$(( $intBCST - $SZ2 - 1 )) 1205 | [ $MID -lt $intBCST ] || MID=$(( $intBCST - 1 )) 1206 | 1207 | #OUTPUT_IPV4_DHCP_ROUTER= 1208 | # IP unknown range 1209 | OUTPUT_IPV4_DHCP_UNKNOW_RANGE="$( IPv4_from_int $(( $MID + 1 )) ) $( IPv4_from_int $(( $intBCST - 1 )) )" 1210 | # IP known range 1211 | OUTPUT_IPV4_DHCP_KNOW_RANGE="$( IPv4_from_int $(( $intBASE + 1 + $SZ1 )) ) $( IPv4_from_int $(( $MID )) )" 1212 | } 1213 | 1214 | ##################################################################### 1215 | # http://blog.n01se.net/blog-n01se-net-p-145.html 1216 | # redirect tty fds to /dev/null 1217 | redirect_std() { 1218 | [[ -t 0 ]] && exec /dev/null 1220 | [[ -t 2 ]] && exec 2>/dev/null 1221 | } 1222 | 1223 | # close all non-std* fds 1224 | close_fds() { 1225 | eval exec {3..255}\>\&- 1226 | } 1227 | 1228 | # full daemonization of external command with setsid 1229 | daemonize() { 1230 | ( # 1. fork 1231 | redirect-std # 2.1. redirect stdin/stdout/stderr before setsid 1232 | cd / # 3. ensure cwd isn't a mounted fs 1233 | # umask 0 # 4. umask (leave this to caller) 1234 | close-fds # 5. close unneeded fds 1235 | exec setsid "$@" 1236 | ) & 1237 | } 1238 | 1239 | # daemonize without setsid, keeps the child in the jobs table 1240 | daemonize_job() { 1241 | ( # 1. fork 1242 | redirect-std # 2.2.1. redirect stdin/stdout/stderr 1243 | trap '' 1 2 # 2.2.2. guard against HUP and INT (in child) 1244 | cd / # 3. ensure cwd isn't a mounted fs 1245 | # umask 0 # 4. umask (leave this to caller) 1246 | close-fds # 5. close unneeded fds 1247 | if [[ $(type -t "$1") != file ]]; then 1248 | "$@" 1249 | else 1250 | exec "$@" 1251 | fi 1252 | ) & 1253 | disown -h $! # 2.2.3. guard against HUP (in parent) 1254 | } 1255 | 1256 | ##################################################################### 1257 | HDFF_EXCLUDE_4PREFIX="\.\,?\!\-_:;\]\[\#\|\$()\"%" 1258 | 1259 | ## @fn generate_prefix_from_filename() 1260 | ## @brief generate a prefix string from a file name 1261 | ## @param fn the file name 1262 | ## 1263 | generate_prefix_from_filename() { 1264 | local PARAM_FN="$1" 1265 | shift 1266 | 1267 | echo "${PARAM_FN//[${HDFF_EXCLUDE_4PREFIX}]/}" | tr [:upper:] [:lower:] 1268 | } 1269 | 1270 | HDFF_EXCLUDE_4FILENAME="\"" 1271 | 1272 | ## @fn unquote_filename() 1273 | ## @brief remove double quotes from string 1274 | ## @param fn the file name 1275 | ## 1276 | unquote_filename() { 1277 | local PARAM_FN="$1" 1278 | shift 1279 | #mr_trace "PARAM_FN=${PARAM_FN}; dirname=$(dirname "${PARAM_FN}"); readlink2=$(readlink -f "$(dirname "${PARAM_FN}")" )" 1280 | echo "${PARAM_FN//[${HDFF_EXCLUDE_4FILENAME}]/}" | sed 's/\t//g' 1281 | } 1282 | -------------------------------------------------------------------------------- /src/pxelinuxiso.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | #This project helps the user to boot/install the Linux distributions more easy from ISO files. 3 | # 4 | # Supported Linux distributions: 5 | # - CentOS/Fedora 6 | # - Debian/Ubuntu 7 | # - Kali/BackTrack 8 | # - Mint linux 9 | # 10 | # Copyright 2013 Yunhui Fu 11 | # License: GPL v3.0 or later 12 | 13 | # TODO: 14 | # 1) low case the file name, otherwise the tftp server won't work 15 | # 2) update http://vercot.com/%7Eserva/an/NonWindowsPXE3.html 16 | 17 | # 3) NFS test: nfsmount -o nolock -o ro 192.168.3.56:/media/tftpboot/images-server/ubuntu/18.04.1/amd64 /mnt 18 | # bug: https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1755863 19 | 20 | 21 | #DN_EXEC=`echo "$0" | ${EXEC_AWK} -F/ '{b=$1; for (i=2; i < NF; i ++) {b=b "/" $(i)}; print b}'` 22 | DN_EXEC="$(dirname $(readlink -f "$0"))" 23 | if [ ! "${DN_EXEC}" = "" ]; then 24 | DN_EXEC="${DN_EXEC}/" 25 | else 26 | DN_EXEC="./" 27 | fi 28 | 29 | DO_EXEC=echo 30 | 31 | . ${DN_EXEC}/libbash.sh 32 | 33 | if [ ! -x "${EXEC_AWK}" ]; then 34 | EXEC_AWK="$(which gawk)" 35 | fi 36 | 37 | FN_TMP_PREFIX="/tmp/pxelinuxiso-" 38 | 39 | FN_TMP_LASTMSG="${FN_TMP_PREFIX}lastmsg" 40 | # the iso file list saved from arguments 41 | FN_TMP_LIST="${FN_TMP_PREFIX}iso-file-list" 42 | 43 | # the system top directory, should be '/' if you use current OS 44 | # or somewhere else if you mount the target system in a sub directory 45 | export SYSTEM_TOP=/ 46 | 47 | export TFTP_ROOT=/var/lib/tftpboot 48 | export DIST_NFSIP=192.168.0.1 49 | 50 | export HTTPD_ROOT=/var/www 51 | export SYSLINUX_ROOT=/usr/lib/syslinux 52 | case "$OSTYPE" in 53 | RedHat) 54 | export SYSLINUX_ROOT=/usr/share/syslinux 55 | export HTTPD_ROOT=/var/www/html 56 | ;; 57 | Arch) 58 | export HTTPD_ROOT=/srv/http 59 | ;; 60 | OpenWrt) 61 | export HTTPD_ROOT=/www 62 | ;; 63 | esac 64 | 65 | ############################################################ 66 | # detect the linux distribution 67 | FN_AWK_DET_ISO="${FN_TMP_PREFIX}detlinuxiso.awk" 68 | FN_AWK_DET_URL="${FN_TMP_PREFIX}detlinuxurl.awk" 69 | 70 | gen_detect_urliso_script () { 71 | PARAM_FN_AWK=$1 72 | if [ "${PARAM_FN_AWK}" = "" ]; then 73 | PARAM_FN_AWK="${FN_AWK_DET_URL}" 74 | fi 75 | cat << EOF > "${PARAM_FN_AWK}" 76 | #!/usr/bin/awk 77 | # try to guess the linux distribution from download URL 78 | # Copyright 2013 Yunhui Fu 79 | # License: GPL v3.0 or later 80 | 81 | BEGIN { 82 | FN_OUTPUT=FNOUT 83 | if ("" == FN_OUTPUT) { 84 | FN_OUTPUT="guess-linux-dist-output-url" 85 | print "[DBG] Warning: use the default output file name: " FN_OUTPUT; 86 | print "[DBG] please specify the output file name via 'awk -v FNOUT=outfile'"; 87 | } 88 | flg_live=0; 89 | flg_nfs=0; 90 | dist_release=""; 91 | dist_name=""; 92 | dist_arch=""; 93 | dist_type="net"; 94 | dist_ui=""; 95 | } 96 | { 97 | # process url, such as "http://sample.com/path/to/unix-i386.iso" 98 | split (\$0, a, "/"); 99 | 100 | # remove the last '.iso' 101 | split (a[length(a)], b, "."); 102 | #print "[DBG] len(b)=" length(b); 103 | #print "[DBG] last(a)=" a[length(a)]; 104 | #print "[DBG] last(b)=" b[length(b)]; 105 | if (length(b) > 1) { 106 | #print "[DBG] last?, len(b)=" length(b); 107 | c = b[1]; 108 | for (i = 2; i < length(b); i ++) { 109 | c = c "." b[i]; 110 | } 111 | #print "[DBG] c=" c; 112 | a[length(a)]=c; 113 | } 114 | 115 | # process the file name, split with '-' 116 | split (a[length(a)], b, "-"); 117 | if (length(b) > 1) { 118 | pos = length(a); 119 | for (i = 1; i <= length(b); i ++) { 120 | a[pos] = b[i]; 121 | pos ++; 122 | } 123 | } 124 | 125 | # skip 'http://sample.com/' 126 | i = 1; 127 | if (match(a[1], /[~:]*:/)) { 128 | i = 4; 129 | print "[DBG] skip to " i; 130 | } 131 | 132 | for (; i <= length(a); i ++) { 133 | switch (a[i]) { 134 | case "": 135 | # ignore 136 | break; 137 | case "BT5": 138 | dist_name = "backtrack"; 139 | dist_release = 5; 140 | dist_type="live"; 141 | break; 142 | case "BT5R1": 143 | dist_name = "backtrack"; 144 | dist_release = "5r1"; 145 | dist_type="live"; 146 | break; 147 | case "BT5R2": 148 | dist_name = "backtrack"; 149 | dist_release = "5r2"; 150 | dist_type="live"; 151 | break; 152 | case "BT5R3": 153 | dist_name = "backtrack"; 154 | dist_release = "5r3"; 155 | dist_type="live"; 156 | break; 157 | case "bt4": 158 | dist_name = "backtrack"; 159 | dist_release = "4"; 160 | dist_type="oldlive"; 161 | dist_arch = "i386"; 162 | break; 163 | 164 | # tinycorelinux.net 165 | case "Core": 166 | dist_name = "tinycore"; 167 | dist_release = "4.7.7"; 168 | dist_type="core"; 169 | dist_arch = "x86"; 170 | break; 171 | case "TinyCore": 172 | dist_name = "tinycore"; 173 | dist_release = "4.7.7"; 174 | dist_type="tiny"; 175 | dist_arch = "x86"; 176 | break; 177 | case "CorePlus": 178 | dist_name = "tinycore"; 179 | dist_release = "4.7.7"; 180 | dist_type="plus"; 181 | dist_arch = "x86"; 182 | break; 183 | case "SL": 184 | dist_name = "scientificlinux"; 185 | break; 186 | 187 | default: 188 | lstr = tolower (a[i]); 189 | print "[DBG] lstr=" lstr; 190 | switch (lstr) { 191 | case "debian": 192 | dist_name = "debian"; 193 | break; 194 | case "ubuntu": 195 | dist_name = "ubuntu"; 196 | break; 197 | case "edubuntu": 198 | dist_name = "edubuntu"; 199 | dist_type="desktop"; 200 | break; 201 | case "lxle": 202 | dist_name = "lxle"; 203 | break; 204 | case "doudoulinux": 205 | dist_name = "doudoulinux"; 206 | break; 207 | case "centos": 208 | dist_name = "centos"; 209 | break; 210 | case "fedora": 211 | dist_name = "fedora"; 212 | break; 213 | case "archlinux": 214 | dist_name = "arch"; 215 | break; 216 | case "archassault": 217 | dist_name = "archassault"; 218 | break; 219 | case "blackarchlinux": 220 | dist_name = "blackarchlinux"; 221 | break; 222 | case "antergos": 223 | dist_name = "antergos"; 224 | dist_type="live"; 225 | break; 226 | case "manjaro": 227 | dist_name = "manjaro"; 228 | dist_type="live"; 229 | break; 230 | case "evolution": 231 | dist_name = "evolution"; 232 | break; 233 | case "tails": 234 | dist_name = "tails"; 235 | dist_type="live"; 236 | break; 237 | case "ctkarchlive": 238 | dist_name = "ctkarchlive"; 239 | break; 240 | case "linuxmint": 241 | dist_name = "mint"; 242 | break; 243 | case "clonezilla": 244 | dist_name = "clonezilla"; 245 | dist_type="live"; 246 | break; 247 | case "kali": 248 | dist_name = "kali"; 249 | dist_type = "live"; 250 | print "[DBG] change kali value: dist_name=" dist_name "; dist_type=" dist_type 251 | break; 252 | case "elementaryos": 253 | dist_name = "elementaryos"; 254 | break; 255 | case "beini": 256 | dist_name = "beini"; 257 | dist_type = "live"; 258 | dist_arch = "x86"; 259 | break; 260 | case "puppy": 261 | dist_name = "puppy"; 262 | dist_type = "live"; 263 | break; 264 | case "veket": 265 | dist_name = "veket"; 266 | dist_type = "live"; 267 | break; 268 | case "opensuse": 269 | dist_name = "opensuse"; 270 | dist_type = "live"; 271 | break; 272 | case "leap": # openSUSE name 273 | break; 274 | case "mageia": 275 | dist_name = "mageia"; 276 | break; 277 | # VMware 278 | case "vmware": 279 | dist_name = "vmware"; 280 | break; 281 | case "vmvisor": 282 | dist_type = "vmvisor"; 283 | dist_arch = "x86_64"; 284 | break; 285 | case "5969303.x86_64": 286 | dist_arch = "x86_64"; 287 | break; 288 | 289 | case "x86_64": 290 | dist_arch = "x86_64"; 291 | break; 292 | case "64bit": 293 | case "amd64": 294 | dist_arch = "amd64"; 295 | break; 296 | case "x86": 297 | dist_arch = "x86"; 298 | break; 299 | case "i386": 300 | case "i586": 301 | dist_arch = "i386"; 302 | break; 303 | case "32bit": 304 | case "i686": 305 | dist_arch = "i686"; 306 | break; 307 | case "live": 308 | if (match(dist_name, /ubuntu/)) { 309 | break; 310 | } 311 | case "livecd": 312 | case "dvd": # opensuse, mageia 313 | flg_live = 1; 314 | break; 315 | case "livedvdkde": # SL 316 | flg_live = 1; 317 | dist_ui = "kde" 318 | break; 319 | case "livedvdgnome": # SL 320 | flg_live = 1; 321 | dist_ui = "gnome" 322 | break; 323 | case "desktop": 324 | dist_type="desktop"; 325 | flg_nfs=1; 326 | break; 327 | case "server": 328 | case "alternate": 329 | dist_type="server"; 330 | flg_nfs=1; 331 | break; 332 | case "netinstall": # CentOS 333 | case "netboot": 334 | case "netinst": 335 | case "net": # opensuse 336 | case "light": # kali 337 | dist_type="net"; 338 | break; 339 | # CentOS: minimal 340 | case "minimal": 341 | dist_type="server"; 342 | flg_nfs=1; 343 | break; 344 | # Ubuntu: mini 345 | case "mini": 346 | dist_type="net"; 347 | flg_nfs=1; 348 | break; 349 | # Arch: dual 350 | case "dual": 351 | dist_type="net"; 352 | dist_arch = "dual"; 353 | flg_nfs=1; 354 | break; 355 | # tinycore 356 | case "current": 357 | if (match(dist_name, /tinycore/)) { 358 | dist_release = "4.7.7"; 359 | } 360 | break; 361 | 362 | case "testing": 363 | case "stable": 364 | break; 365 | # kali: linux 366 | case "linux": 367 | # BT: final 368 | case "final": 369 | # BT: KDE 370 | case "kde": 371 | case "gnome": 372 | case "xfce": # manjaro 373 | dist_ui=lstr; 374 | break 375 | case "http:": 376 | case "https:": 377 | case "ftp:": 378 | # ignore 379 | print "[DBG] ignore key=" a[i]; 380 | break; 381 | 382 | default: 383 | flg_ignore=1 384 | if (match(lstr, /amd64/)) { 385 | dist_arch = "amd64"; 386 | flg_ignore=0 387 | #print "[DBG] set arch=" dist_arch; 388 | } else if (match(lstr, /64bit/)) { 389 | dist_arch = "amd64"; 390 | flg_ignore=0 391 | } else if (match(lstr, /64bit/)) { 392 | dist_arch = "amd64"; 393 | flg_ignore=0 394 | } else if (match(lstr, /x86_64/)) { 395 | dist_arch = "x86_64"; 396 | flg_ignore=0 397 | } else if (match(lstr, /32bit/)) { 398 | dist_arch = "i386"; 399 | flg_ignore=0 400 | #print "[DBG] set arch=" dist_arch; 401 | } 402 | if ("debian" == dist_name) { 403 | if (match(lstr, /squeeze/)) { 404 | dist_release = "6.0.7"; 405 | flg_ignore=0 406 | } else if (match(lstr, /wheezy/)) { 407 | dist_release = "7.1"; 408 | flg_ignore=0 409 | } else if (match(lstr, /jessie/)) { 410 | dist_release = "testing"; 411 | flg_ignore=0 412 | } else if (match(lstr, /sid/)) { 413 | dist_release = "unstable"; 414 | flg_ignore=0 415 | } else { 416 | # if all is digit or . 417 | if (match(lstr, /^[0-9\.]+$/)) { 418 | dist_release = lstr; 419 | flg_ignore=0 420 | #print "[DBG] set release=" dist_release; 421 | } 422 | } 423 | } else if ("ubuntu" == dist_name) { 424 | if (match(lstr, /lucid/)) { 425 | dist_release = "10.04"; 426 | flg_ignore=0 427 | } else if (match(lstr, /precise/)) { 428 | dist_release = "12.04"; 429 | flg_ignore=0 430 | } else if (match(lstr, /quantal/)) { 431 | dist_release = "12.10"; 432 | flg_ignore=0 433 | } else if (match(lstr, /raring/)) { 434 | dist_release = "13.04"; 435 | flg_ignore=0 436 | } else if (match(lstr, /saucy/)) { 437 | dist_release = "14.04"; 438 | flg_ignore=0 439 | } else { 440 | # if all is digit or . 441 | if (match(lstr, /^[0-9\.]+$/)) { 442 | dist_release = lstr; 443 | flg_ignore=0 444 | #print "[DBG] set release=" dist_release; 445 | } 446 | } 447 | } else { 448 | if ("" == dist_release) { 449 | #print "[DBG] fill release=" lstr; 450 | dist_release=lstr; 451 | flg_ignore=0 452 | } else if ("" == dist_arch) { 453 | #print "[DBG] fill arch=" lstr; 454 | if ("64" == lstr) { 455 | dist_arch = "amd64"; 456 | flg_ignore=0 457 | } else { 458 | dist_arch = "i386"; 459 | flg_ignore=0 460 | } 461 | } 462 | #print "[DBG] set arch=" dist_arch; 463 | } 464 | if (flg_ignore) { 465 | print "[DBG] ignore key=" a[i]; 466 | } 467 | break; 468 | } 469 | break; 470 | } 471 | } 472 | } 473 | 474 | END { 475 | print "[DBG]" \ 476 | " name=" (""==dist_name?"unknown":dist_name) \ 477 | " release=" (""==dist_release?"unknown":dist_release) \ 478 | " arch=" (""==dist_arch?"unknown":dist_arch) \ 479 | " type=" (""==dist_type?"unknown":dist_type) \ 480 | " UI=" (""==dist_ui?"unknown":dist_ui) \ 481 | (flg_live==0?"":"(Live)") \ 482 | (flg_nfs==0?"":"(NFS)") \ 483 | ; 484 | print "DECLNXOUT_NAME=" dist_name > FN_OUTPUT 485 | print "DECLNXOUT_RELEASE=" dist_release >> FN_OUTPUT 486 | print "DECLNXOUT_ARCH=" dist_arch >> FN_OUTPUT 487 | print "DECLNXOUT_TYPE=" dist_type >> FN_OUTPUT 488 | print "DECLNXOUT_UI=" dist_ui >> FN_OUTPUT 489 | print "DECLNXOUT_FLG_LIVE=" flg_live >> FN_OUTPUT 490 | print "DECLNXOUT_FLG_NFS=" flg_nfs >> FN_OUTPUT 491 | } 492 | EOF 493 | } 494 | 495 | DECLNXOUT_NAME="" 496 | DECLNXOUT_RELEASE="" 497 | DECLNXOUT_ARCH="" 498 | DECLNXOUT_TYPE="" 499 | DECLNXOUT_UI="" 500 | DECLNXOUT_FLG_LIVE=0 501 | DECLNXOUT_FLG_NFS=0 502 | 503 | _detect_export_values () { 504 | PARAM_FNOUT="$1" 505 | shift 506 | 507 | DECLNXOUT_NAME="" 508 | DECLNXOUT_RELEASE="" 509 | DECLNXOUT_ARCH="" 510 | DECLNXOUT_TYPE="" 511 | DECLNXOUT_UI="" 512 | DECLNXOUT_FLG_LIVE=0 513 | DECLNXOUT_FLG_NFS=0 514 | if [ -f "${PARAM_FNOUT}" ]; then 515 | . "${PARAM_FNOUT}" 516 | fi 517 | } 518 | 519 | detect_linux_dist () { 520 | PARAM_URL2="$1" 521 | shift 522 | 523 | FN_SINGLE=$(basename "${PARAM_URL2}") 524 | #URL2BASE=$(dirname "${PARAM_URL2}") 525 | 526 | mr_trace "[DBG] FN_SINGLE=${FN_SINGLE}" 527 | 528 | FN_TMP=${FN_TMP_PREFIX}out-iso 529 | gen_detect_urliso_script "${FN_AWK_DET_ISO}" 530 | echo "${FN_SINGLE}" | ${EXEC_AWK} -v TYP=iso -v FNOUT=${FN_TMP} -f "${FN_AWK_DET_ISO}" 531 | _detect_export_values "${FN_TMP}" 532 | if [ "${DECLNXOUT_NAME}" = "" ]; then 533 | gen_detect_urliso_script "${FN_AWK_DET_URL}" 534 | echo "${PARAM_URL2}" | ${EXEC_AWK} -v TYP=url -v FNOUT=${FN_TMP} -f "${FN_AWK_DET_URL}" 535 | _detect_export_values "${FN_TMP}" 536 | fi 537 | } 538 | ############################################################ 539 | 540 | FN_MD5TMP="${FN_TMP_PREFIX}md5sumall" 541 | FN_SHA1TMP="${FN_TMP_PREFIX}sha1sumall" 542 | 543 | check_xxxsum () { 544 | # sumname is MD5SUM or SHA1SUM 545 | PARAM_SUMNAME=$1 546 | shift 547 | # progname is md5sum or sha1sum 548 | PARAM_PROGNAME=$1 549 | shift 550 | # internal MD5SUM/SHA1SUM record for the file 551 | PARAM_STATIC_SUM=$1 552 | shift 553 | # the file name 554 | PARAM_RENAME1=$1 555 | shift 556 | 557 | mr_trace "[DBG] PARAM_SUMNAME=$PARAM_SUMNAME" 558 | mr_trace "[DBG] PARAM_PROGNAME=$PARAM_PROGNAME" 559 | mr_trace "[DBG] PARAM_STATIC_SUM=$PARAM_STATIC_SUM" 560 | mr_trace "[DBG] PARAM_RENAME1=$PARAM_RENAME1" 561 | 562 | FLG_DW=1 563 | if [ -f "${PARAM_RENAME1}" ]; then 564 | mr_trace "[DBG] 1 set flg_dw back to 0" 565 | FLG_DW=0 566 | fi 567 | MD5SUM_DW=${PARAM_STATIC_SUM} 568 | MD5SUM_LOCAL= 569 | FN=$(dirname "${PARAM_RENAME1}")/${PARAM_SUMNAME} 570 | if [ -f "${FN}" ]; then 571 | MD5SUM_LOCAL=$(grep -i "${FN_SINGLE}" "${FN}" | ${EXEC_AWK} '{print $1}') 572 | if [ ! "${MD5SUM_LOCAL}" = "" ]; then 573 | if [ ! "${MD5SUM_LOCAL}" = "${MD5SUM_DW}" ]; then 574 | mr_trace "[DBG] MD5SUM_LOCAL($MD5SUM_LOCAL) != PARAM_STATIC_SUM($PARAM_STATIC_SUM)" 575 | MD5SUM_DW=${PARAM_STATIC_SUM} 576 | FLG_DW=1 577 | fi 578 | mr_trace "[DBG] 2 set flg_dw=${FLG_DW}" 579 | fi 580 | else 581 | # no local MD5SUM, down load file 582 | FLG_DW=1 583 | touch "${FN}" 584 | fi 585 | MD5SUM_REMOTE= 586 | rm -f "${FN_TMP_PREFIX}md5tmp" 587 | wget --tries=3 --no-check-certificate $(dirname "${PARAM_URL0}")/${PARAM_SUMNAME} -O "${FN_TMP_PREFIX}md5tmp" 588 | if [ ! "$?" = "0" ]; then 589 | rm -f "${FN_TMP_PREFIX}md5tmp" 590 | FN_BASE1=$(echo "${PARAM_SUMNAME}" | tr '[A-Z]' '[a-z]') 591 | wget --tries=3 --no-check-certificate $(dirname "${PARAM_URL0}")/${FN_BASE1}.txt -O "${FN_TMP_PREFIX}md5tmp" 592 | if [ ! "$?" = "0" ]; then 593 | rm -f "${FN_TMP_PREFIX}md5tmp" 594 | fi 595 | fi 596 | if [ ! -f "${FN_TMP_PREFIX}md5tmp" ]; then 597 | FN_BASE1=$(basename "${FN_SINGLE}" | ${EXEC_AWK} -F. '{b=$1; for (i=2; i < NF; i ++) {b=b "." $(i)}; print b}') 598 | wget --tries=3 --no-check-certificate $(dirname "${PARAM_URL0}")/${FN_BASE1}.txt -O "${FN_TMP_PREFIX}md5tmp" 599 | if [ ! "$?" = "0" ]; then 600 | rm -f "${FN_TMP_PREFIX}md5tmp" 601 | fi 602 | fi 603 | if [ ! -f "${FN_TMP_PREFIX}md5tmp" ]; then 604 | wget --tries=3 --no-check-certificate $(dirname "${PARAM_URL0}")/${PARAM_SUMNAME}.md5.txt -O "${FN_TMP_PREFIX}md5tmp" 605 | if [ ! "$?" = "0" ]; then 606 | rm -f "${FN_TMP_PREFIX}md5tmp" 607 | fi 608 | fi 609 | if [ -f "${FN_TMP_PREFIX}md5tmp" ]; then 610 | mr_trace "[DBG] chk file ${FN_TMP_PREFIX}md5tmp" 611 | mr_trace "[DBG] grep -i ${FN_SINGLE} ${FN_TMP_PREFIX}md5tmp | ${EXEC_AWK} '{print $1}'" 612 | MD5SUM_REMOTE=$(grep -i "${FN_SINGLE}" "${FN_TMP_PREFIX}md5tmp" | ${EXEC_AWK} '{print $1}') 613 | mr_trace "[DBG] MD5SUM_REMOTE=$MD5SUM_REMOTE" 614 | mr_trace "[DBG] PARAM_STATIC_SUM=$PARAM_STATIC_SUM" 615 | if [ ! "${MD5SUM_REMOTE}" = "" ]; then 616 | if [ ! "${MD5SUM_REMOTE}" = "${MD5SUM_DW}" ]; then 617 | mr_trace "[DBG] MD5SUM_REMOTE($MD5SUM_REMOTE) != PARAM_STATIC_SUM($PARAM_STATIC_SUM)" 618 | MD5SUM_DW=${MD5SUM_REMOTE} 619 | FLG_DW=1 620 | mr_trace "[DBG] 3 set flg_dw=${FLG_DW}" 621 | fi 622 | fi 623 | fi 624 | FLG_TMP1=0 625 | if [ -f "${PARAM_RENAME1}" ]; then 626 | FLG_TMP1=1 627 | fi 628 | if [ -L "${PARAM_RENAME1}" ]; then 629 | FLG_TMP1=1 630 | fi 631 | if [ "${FLG_TMP1}" = "1" ]; then 632 | if [ "${FLG_DW}" = "1" ]; then 633 | mr_trace "[DBG] chk sum: ${PARAM_PROGNAME} ${MD5SUM_DW} ${PARAM_RENAME1}" 634 | echo "${MD5SUM_DW} ${PARAM_RENAME1}" > md5sumtmp2 635 | #mr_trace "[DBG] md5sum check:"; cat md5sumtmp2 | while read a; do mr_trace $a; done; mr_trace ""; mr_trace "[DBG] md5sum --------------" 636 | ${PARAM_PROGNAME} -c md5sumtmp2 637 | RET=$? 638 | rm -f md5sumtmp2 639 | #mr_trace "[DBG] md5sum check ret = $RET" 640 | if [ ${RET} = 0 ]; then 641 | FLG_DW=0 642 | # update local MD5SUMS 643 | #mr_trace "[DBG] FN=${FN}" 644 | grep -v "$( basename "${PARAM_RENAME1}" )" "${FN}" > "${FN}-new" 645 | mv "${FN}-new" "${FN}" 646 | echo "${MD5SUM_DW} ${PARAM_RENAME1}" >> "${FN}" 647 | else 648 | FLG_DW=1 649 | fi 650 | mr_trace "[DBG] 4 set flg_dw=${FLG_DW}" 651 | fi 652 | else 653 | FLG_DW=1 654 | mr_trace "[DBG] filename=${PARAM_RENAME1}" 655 | mr_trace "[DBG] 5 set flg_dw=${FLG_DW}" 656 | fi 657 | mr_trace "[DBG] check sum done: flg_down=${FLG_DW}" 658 | echo "${FLG_DW}" 659 | } 660 | 661 | down_url () { 662 | PARAM_URL0="$1" 663 | shift 664 | PARAM_RENAME= 665 | if [ $# -gt 0 ]; then 666 | PARAM_RENAME="$1" 667 | shift 668 | fi 669 | 670 | mr_trace "[DBG] PARAM_RENAME-0=$PARAM_RENAME" 671 | 672 | if [ "${PARAM_RENAME}" = "" ]; then 673 | FNDOWN0=$(echo "${PARAM_URL0}" | ${EXEC_AWK} -F? '{print $1}') 674 | 675 | DN_SRCS=downloads 676 | PARAM_RENAME=${DN_SRCS}/$(basename "${FNDOWN0}") 677 | 678 | mr_trace "[DBG] PARAM_RENAME-1=$PARAM_RENAME" 679 | fi 680 | FN_SINGLE=$(basename "${PARAM_RENAME}") 681 | DN_SRCS=$(dirname "${PARAM_RENAME}") 682 | mr_trace "[DBG] FN_SINGLE=$FN_SINGLE" 683 | mr_trace "[DBG] DN_SRCS=$DN_SRCS" 684 | 685 | MD5SUM_STATIC=$(grep -i "${FN_SINGLE}" "${FN_MD5TMP}" | ${EXEC_AWK} '{print $1}') 686 | FLG_DOWN=$( check_xxxsum MD5SUMS md5sum "${MD5SUM_STATIC}" "${PARAM_RENAME}" ) 687 | if [ "${FLG_DOWN}" = "1" ]; then 688 | MD5SUM_STATIC=$(grep -i "${FN_SINGLE}" "${FN_MD5TMP}" | ${EXEC_AWK} '{print $1}') 689 | FLG_DOWN=$( check_xxxsum MD5SUM md5sum "${MD5SUM_STATIC}" "${PARAM_RENAME}" ) 690 | fi 691 | if [ "${FLG_DOWN}" = "1" ]; then 692 | MD5SUM_STATIC=$(grep -i "${FN_SINGLE}" "${FN_SHA1TMP}" | ${EXEC_AWK} '{print $1}') 693 | FLG_DOWN=$( check_xxxsum SHA1SUMS sha1sum "${MD5SUM_STATIC}" "${PARAM_RENAME}" ) 694 | fi 695 | if [ "${FLG_DOWN}" = "1" ]; then 696 | MD5SUM_STATIC=$(grep -i "${FN_SINGLE}" "${FN_SHA1TMP}" | ${EXEC_AWK} '{print $1}') 697 | FLG_DOWN=$( check_xxxsum SHA1SUM sha1sum "${MD5SUM_STATIC}" "${PARAM_RENAME}" ) 698 | fi 699 | 700 | if [ "${FLG_DOWN}" = "1" ]; then 701 | mr_trace "[DBG] start download file: ${PARAM_URL0}" 702 | if [ "${FLG_NOINTERACTIVE}" = "0" ]; then 703 | read -rsn 1 -p "Press any key to continue..." 704 | fi 705 | #mr_trace "[DBG] exit 0"; exit 0 706 | 707 | mr_trace "[DBG] " download_file "${DN_SRCS}" "${MD5SUM_DW}" "${FN_SINGLE}" "${PARAM_URL0}" 708 | RET=0 709 | $DO_EXEC rm -f "${DN_SRCS}/${FN_SINGLE}" 710 | $DO_EXEC wget --tries=3 --no-check-certificate -c "${PARAM_URL0}" -O "${DN_SRCS}/${FN_SINGLE}" 711 | RET=$? 712 | if [ ${RET} = 0 ]; then 713 | mr_trace "[INFO] md5sum ... ${FN_SINGLE}" 714 | md5sum "${DN_SRCS}/${FN_SINGLE}" > ${FN_TMP_PREFIX}md5sum-down 715 | $DO_EXEC attach_to_file ${FN_TMP_PREFIX}md5sum-down "${DN_SRCS}/MD5SUMS" 716 | mr_trace "[INFO] sha1sum ... ${FN_SINGLE}" 717 | sha1sum "${DN_SRCS}/${FN_SINGLE}" > ${FN_TMP_PREFIX}sha1sum-down 718 | $DO_EXEC attach_to_file ${FN_TMP_PREFIX}sha1sum-down "${DN_SRCS}/SHA1SUMS" 719 | else 720 | mr_trace "[ERR] download file ${PARAM_URL0} error!" 721 | #mr_trace "[DBG] exit 0" 722 | #exit 0 723 | fi 724 | fi 725 | } 726 | 727 | tftp_init_directories () { 728 | 729 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg" 730 | 731 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/images-server/" 732 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/images-desktop/" 733 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/images-net/" 734 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/images-live/" 735 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/" 736 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/kickstarts/" 737 | 738 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${HTTPD_ROOT}" 739 | 740 | # setup downloads folder, all of the ISO files will be stored here 741 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/" 742 | } 743 | 744 | tftp_init_service () { 745 | mr_trace "[DBG] Install TFTP/NFS/DHCP servers ..." 746 | if [ "${SYSTEM_TOP}" = "/" ]; then 747 | install_package tftpd-hpa nfs-kernel-server dhcp3-server #bind9 748 | fi 749 | 750 | if [ ! -d "${SYSLINUX_ROOT}" ]; then 751 | mr_trace "[WARNING] Not found syslinux, try to install one" 752 | install_package syslinux pxelinux 753 | fi 754 | 755 | if [ ! -d "${SYSLINUX_ROOT}" ]; then 756 | export SYSLINUX_ROOT=/usr/share/syslinux/ 757 | fi 758 | if [ ! -d "${SYSLINUX_ROOT}" ]; then 759 | export SYSLINUX_ROOT=/tmp/usr/lib/syslinux/ 760 | fi 761 | if [ ! -d "${SYSLINUX_ROOT}" ]; then 762 | export SYSLINUX_ROOT="${DN_INSTALLED_SYSLINUX}" 763 | fi 764 | if [ ! -d "${SYSLINUX_ROOT}" ]; then 765 | mr_trace "[DBG] Error in searching syslinux folder: ${SYSLINUX_ROOT}" 766 | exit 1 767 | fi 768 | 769 | tftp_init_directories 770 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/" 771 | 772 | $DO_EXEC alias cp=cp 773 | 774 | local FN_PXELINUX=$(find "${SYSLINUX_ROOT}" -name pxelinux.0 | sort | head -n 1) 775 | if [ ! -f "${FN_PXELINUX}" ]; then 776 | FN_PXELINUX=$(find "/usr/lib/PXELINUX/" -name pxelinux.0 | sort | head -n 1) 777 | fi 778 | if [ -f "${FN_PXELINUX}" ]; then 779 | $DO_EXEC cp "${FN_PXELINUX}" "${SYSTEM_TOP}/${TFTP_ROOT}/" 780 | fi 781 | 782 | local FN_MEMDISK=$(find "${SYSLINUX_ROOT}" -name memdisk | sort | head -n 1) 783 | if [ -f "${FN_MEMDISK}" ]; then 784 | $DO_EXEC cp "${FN_MEMDISK}" "${SYSTEM_TOP}/${TFTP_ROOT}/" 785 | fi 786 | 787 | local FN_LDLINUX=$(find "${SYSLINUX_ROOT}" -name ldlinux.c32 | sort | head -n 1) 788 | if [ -f "${FN_LDLINUX}" ]; then 789 | $DO_EXEC cp "${FN_LDLINUX}" "${SYSTEM_TOP}/${TFTP_ROOT}/" 790 | fi 791 | 792 | local FN_LIBUTIL=$(find "${SYSLINUX_ROOT}" -name libutil.c32 | sort | head -n 1) 793 | if [ -f "${FN_LIBUTIL}" ]; then 794 | $DO_EXEC cp "${FN_LIBUTIL}" "${SYSTEM_TOP}/${TFTP_ROOT}/" 795 | fi 796 | 797 | local FN_MENU=$(find "${SYSLINUX_ROOT}" -name menu.c32 | sort | head -n 1) 798 | if [ -f "${FN_MENU}" ]; then 799 | $DO_EXEC cp "${FN_MENU}" "${SYSTEM_TOP}/${TFTP_ROOT}/" 800 | fi 801 | 802 | local FN_MBOOT=$(find "${SYSLINUX_ROOT}" -name mboot.c32 | sort | head -n 1) 803 | if [ -f "${FN_MBOOT}" ]; then 804 | $DO_EXEC cp "${FN_MBOOT}" "${SYSTEM_TOP}/${TFTP_ROOT}/" 805 | fi 806 | 807 | local FN_CHAIN=$(find "${SYSLINUX_ROOT}" -name chain.c32 | sort | head -n 1) 808 | if [ -f "${FN_CHAIN}" ]; then 809 | $DO_EXEC cp "${FN_CHAIN}" "${SYSTEM_TOP}/${TFTP_ROOT}/" 810 | fi 811 | 812 | local FN_PXECHAIN=$(find "${SYSLINUX_ROOT}" -name pxechain.com | sort | head -n 1) 813 | if [ ! -f "${FN_PXECHAIN}" ]; then 814 | FN_PXECHAIN=$(find "${SYSLINUX_ROOT}" -name pxechn.c32 | sort | head -n 1) 815 | fi 816 | if [ -f "${FN_PXECHAIN}" ]; then 817 | $DO_EXEC cp "${FN_PXECHAIN}" "${SYSTEM_TOP}/${TFTP_ROOT}/" 818 | fi 819 | 820 | # 然后构建文件链接:(注意链接要使用相对链接文件所在目录的路径!) 821 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/images-server/" 822 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/images-desktop/" 823 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/images-net/" 824 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/images-live/" 825 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/" 826 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/kickstarts/" 827 | 828 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${HTTPD_ROOT}" 829 | $DO_EXEC cd "${SYSTEM_TOP}/${HTTPD_ROOT}" 830 | $DO_EXEC ln -sf "${TFTP_ROOT}" "tftpboot" 831 | $DO_EXEC cd - 832 | 833 | # set the header of configuration file 834 | cat > ${FN_TMP_PREFIX}tftpdefault << EOF 835 | #PROMPT 1 836 | #TIMEOUT 0 837 | #DISPLAY pxelinux.cfg/boot.txt 838 | #DEFAULT local 839 | 840 | DEFAULT menu 841 | PROMPT 0 842 | MENU TITLE pxeBoot | yhfudev@gmail.com 843 | TIMEOUT 200 844 | TOTALTIMEOUT 600 845 | ONTIMEOUT local 846 | 847 | LABEL local 848 | MENU LABEL (local) 849 | MENU DEFAULT 850 | LOCALBOOT 0 851 | 852 | EOF 853 | $DO_EXEC mv ${FN_TMP_PREFIX}tftpdefault "${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/default" 854 | 855 | cat > ${FN_TMP_PREFIX}tftpboot << EOF 856 | Available Boot Options: 857 | ======================= 858 | EOF 859 | $DO_EXEC mv ${FN_TMP_PREFIX}tftpboot "${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/boot.txt" 860 | 861 | rm -f ${FN_TMP_PREFIX}tftpdefault ${FN_TMP_PREFIX}tftpboot 862 | } 863 | 864 | 865 | # detect the pxe booting files 866 | detect_file () { 867 | #${DIST_MOUNTPOINT}/casper/vmlinuz 868 | PARAM_MNTPNT="$1" 869 | shift 870 | PARAM_PREFIX="$1" 871 | shift 872 | PARAM_LIST="$1" 873 | shift 874 | FLG_FOUND=0 875 | OUT= 876 | if [ "" = "${PARAM_LIST}" ] ; then 877 | A=$(find "${PARAM_MNTPNT}/" -name "${PARAM_PREFIX}*" | head -n 1) 878 | if [ -f "${A}" ]; then 879 | FLG_FOUND=1 880 | OUT="${A}" 881 | fi 882 | else 883 | for i in ${PARAM_LIST} ; do 884 | A=$(find "${PARAM_MNTPNT}/$i/" -name "${PARAM_PREFIX}*" | head -n 1) 885 | if [ -f "${A}" ]; then 886 | FLG_FOUND=1 887 | OUT="${A}" 888 | break 889 | fi 890 | done 891 | fi 892 | if [ -f "${OUT}" ]; then 893 | echo "${OUT}" 894 | fi 895 | } 896 | 897 | # the default search dirs 898 | DEFAULT_BOOTIMG_DIRS='images/pxeboot/ casper live install isolinux boot boot/i686 boot/x86_64 boot/i586' 899 | 900 | detect_vmlinu_initrd () { 901 | # mount point 902 | PARAM_MNTPNT="$1" 903 | shift 904 | # the ISO file 905 | PARAM_DIST_FILE="$1" 906 | shift 907 | # the root of tftp 908 | PARAM_TFTP_ROOT="$1" 909 | shift 910 | # search dirs 911 | PARAM_SEARCH_DIRS="$1" 912 | shift 913 | 914 | # automatically check the name of the 'vmlinuz' 915 | $DO_EXEC mkdir -p "${PARAM_TFTP_ROOT}/${PARAM_MNTPNT}" 916 | $DO_EXEC mount -o loop,utf8 "${PARAM_DIST_FILE}" "${PARAM_TFTP_ROOT}/${PARAM_MNTPNT}" 917 | $DO_EXEC cd "${PARAM_TFTP_ROOT}" 918 | mr_trace "current dir: `pwd`" 919 | A=$(detect_file "${PARAM_MNTPNT}" "vmlinu" "${PARAM_SEARCH_DIRS}" ) 920 | if [ ! -f "${A}" ]; then 921 | A=$(detect_file "${PARAM_MNTPNT}" "linu" "${PARAM_SEARCH_DIRS}" ) 922 | fi 923 | TFTP_KERNEL="${A}" 924 | #mr_trace "[INFO] KERNEL:${TFTP_KERNEL}" 925 | A=$(detect_file "${PARAM_MNTPNT}" "initrd" "${PARAM_SEARCH_DIRS}" ) 926 | TFTP_APPEND_INITRD="${A}" 927 | #mr_trace "[INFO] initrd:${TFTP_APPEND_INITRD}" 928 | $DO_EXEC umount "${PARAM_DIST_FILE}" 929 | echo "${TFTP_KERNEL} ${TFTP_APPEND_INITRD}" 930 | $DO_EXEC cd - 931 | } 932 | 933 | FN_TMP_ETCEXPORTS="${FN_TMP_PREFIX}etcexports" 934 | FN_TMP_ETCFSTAB="${FN_TMP_PREFIX}etcfstab" 935 | FN_TMP_OPENWRTFSTAB="${FN_TMP_PREFIX}openwrtfstab" 936 | FN_TMP_TFTPMENU="${FN_TMP_PREFIX}tftpmenu" 937 | FN_TMP_ETCRCLOCAL="${FN_TMP_PREFIX}etc.rc.local" 938 | 939 | # parse the ISO file and setup a pxe config for it. 940 | tftp_setup_pxe_iso () { 941 | PARAM_URL1="$1" 942 | shift 943 | PARAM_USER_LABEL= 944 | if [ $# -gt 0 ]; then 945 | PARAM_USER_LABEL="$1" 946 | shift 947 | fi 948 | DIST_URL="${PARAM_URL1}" 949 | 950 | #mr_trace "[DBG] 1 detect_linux_dist ${DIST_URL}" 951 | detect_linux_dist "${DIST_URL}" 952 | DIST_NAME_TYPE="${DECLNXOUT_NAME}" 953 | DIST_NAME="${DECLNXOUT_NAME}" 954 | DIST_RELEASE="${DECLNXOUT_RELEASE}" 955 | DIST_ARCH="${DECLNXOUT_ARCH}" 956 | DIST_TYPE="${DECLNXOUT_TYPE}" 957 | DIST_UI="${DECLNXOUT_UI}" 958 | FLG_LIVE="${DECLNXOUT_FLG_LIVE}" 959 | DIST_NAME2="${DECLNXOUT_FLG_NFS}" 960 | # if use NFS to share the content of ISO 961 | FLG_NFS=0 962 | # if need to mount the ISO file; There's no need to mount ISO if ISO is small and boot from ISO directly. 963 | FLG_MOUNT=1 964 | 965 | if [ ! "${A_DIST_NAME}" = "" ]; then 966 | DIST_NAME_TYPE="${A_DIST_NAME}" 967 | DIST_NAME="${A_DIST_NAME}" 968 | fi 969 | if [ ! "${A_DIST_RELEASE}" = "" ]; then 970 | DIST_RELEASE="${A_DIST_RELEASE}" 971 | fi 972 | if [ ! "${A_DIST_ARCH}" = "" ]; then 973 | DIST_ARCH="${A_DIST_ARCH}" 974 | fi 975 | if [ ! "${A_DIST_TYPE}" = "" ]; then 976 | DIST_TYPE="${A_DIST_TYPE}" 977 | fi 978 | if [ ! "${A_DIST_UI}" = "" ]; then 979 | DIST_UI="${A_DIST_UI}" 980 | fi 981 | 982 | mr_trace "[DBG] DIST_NAME=${DIST_NAME}" 983 | mr_trace "[DBG] DIST_RELEASE=${DIST_RELEASE}" 984 | mr_trace "[DBG] DIST_ARCH=${DIST_ARCH}" 985 | mr_trace "[DBG] DIST_TYPE=${DIST_TYPE}" 986 | mr_trace "[DBG] DIST_UI=${DIST_UI}" 987 | FLG_QUIT=0 988 | if [ "${DIST_NAME}" = "" ]; then 989 | FLG_QUIT=1 990 | mr_trace "[ERR] Unable to detect the distribution name" 991 | mr_trace "[ERR] please specify by --distname option!" 992 | fi 993 | if [ "${DIST_RELEASE}" = "" ]; then 994 | FLG_QUIT=1 995 | mr_trace "[ERR] Unable to detect the distribution release" 996 | mr_trace "[ERR] please specify by --distrelease option!" 997 | fi 998 | if [ "${DIST_ARCH}" = "" ]; then 999 | FLG_QUIT=1 1000 | mr_trace "[ERR] Unable to detect the distribution release" 1001 | mr_trace "[ERR] please specify by --distarch option!" 1002 | fi 1003 | if [ "${DIST_TYPE}" = "" ]; then 1004 | FLG_QUIT=1 1005 | mr_trace "[ERR] Unable to detect the distribution release" 1006 | mr_trace "[ERR] please specify by --disttype option!" 1007 | fi 1008 | 1009 | export ISO_NAME=$(basename "${DIST_URL}") 1010 | if [ "${FLG_QUIT}" = "1" ]; then 1011 | DIST_NAME="${ISO_NAME}" 1012 | DIST_NAME_TYPE="" 1013 | DIST_RELEASE="" 1014 | DIST_ARCH="" 1015 | DIST_TYPE="" 1016 | DIST_UI="" 1017 | fi 1018 | 1019 | case "$DIST_NAME" in 1020 | "debian") 1021 | if [ "${FLG_LIVE}" = "1" ]; then 1022 | DIST_TYPE="live" 1023 | else 1024 | if [ "${DIST_TYPE}" = "net" ]; then 1025 | DIST_NAME_TYPE="ubuntu" 1026 | fi 1027 | fi 1028 | ;; 1029 | "centos") 1030 | if [ "${FLG_LIVE}" = "1" ]; then 1031 | DIST_TYPE="live" 1032 | fi 1033 | ;; 1034 | "fedora") 1035 | DIST_TYPE="desktop" 1036 | if [ "${FLG_LIVE}" = "1" ]; then 1037 | DIST_TYPE="live" 1038 | fi 1039 | ;; 1040 | 1041 | "mint"|"lxle") 1042 | DIST_NAME_TYPE="ubuntu" 1043 | DIST_TYPE="desktop" 1044 | if [ "${FLG_LIVE}" = "1" ]; then 1045 | DIST_TYPE="live" 1046 | fi 1047 | ;; 1048 | 1049 | "backtrack") 1050 | case "$DIST_RELEASE" in 1051 | 4) 1052 | DIST_TYPE="oldlive" 1053 | ;; 1054 | 5) 1055 | DIST_TYPE="live" 1056 | ;; 1057 | esac 1058 | ;; 1059 | 1060 | "beini") 1061 | DIST_NAME_TYPE="tinycore" 1062 | if [ "${FLG_LIVE}" = "1" ]; then 1063 | DIST_TYPE="live" 1064 | fi 1065 | ;; 1066 | "veket") 1067 | DIST_NAME_TYPE="puppy" 1068 | if [ "${FLG_LIVE}" = "1" ]; then 1069 | DIST_TYPE="live" 1070 | fi 1071 | ;; 1072 | *) 1073 | if [ "${FLG_LIVE}" = "1" ]; then 1074 | DIST_TYPE="live" 1075 | fi 1076 | ;; 1077 | esac 1078 | 1079 | # if we unable to get information correctly from the name 1080 | #mr_trace "[DBG] 2 detect_linux_dist ${ISO_NAME}" 1081 | detect_linux_dist "${ISO_NAME}" 1082 | if [ "${DECLNXOUT_NAME}" = "" ]; then 1083 | if [ ! "${DIST_TYPE}" = "" ]; then 1084 | ISO_NAME="${DIST_NAME}-${DIST_RELEASE}-${DIST_ARCH}-${DIST_TYPE}-${ISO_NAME}" 1085 | fi 1086 | fi 1087 | 1088 | export DIST_PATHR="${DIST_NAME}/${DIST_RELEASE}/${DIST_ARCH}/${DIST_UI}" 1089 | export DIST_FILE="${TFTP_ROOT}/downloads/${ISO_NAME}" 1090 | export DIST_MOUNTPOINT="images-${DIST_TYPE}/${DIST_PATHR}" 1091 | 1092 | TFTP_TAG_LABEL="${DIST_NAME}_${DIST_RELEASE}_${DIST_ARCH}_${DIST_TYPE}_${DIST_UI}" 1093 | TFTP_MENU_LABEL="${TFTP_TAG_LABEL}" 1094 | if [ ! "${PARAM_USER_LABEL}" = "" ]; then 1095 | TFTP_MENU_LABEL="${PARAM_USER_LABEL}" 1096 | fi 1097 | 1098 | mr_trace "[DBG] ISO_NAME=${ISO_NAME}" 1099 | mr_trace "[DBG] DIST_MOUNTPOINT=${DIST_MOUNTPOINT}" 1100 | mr_trace "[DBG] DIST_FILE=${DIST_FILE}" 1101 | 1102 | # download and check the file 1103 | $DO_EXEC down_url "${DIST_URL}" "${DIST_FILE}" 1104 | if [ "${FLG_QUIT}" = "1" ]; then 1105 | SZ=$(ls -s "${DIST_FILE}" | ${EXEC_AWK} '{print $1}') 1106 | if [ $(( $SZ < 100000 )) = 1 ]; then 1107 | # we boot it from ISO image 1108 | FLG_QUIT=0 1109 | TFTP_MENU_LABEL="${ISO_NAME} (ISO)" 1110 | TFTP_TAG_LABEL="${ISO_NAME}" 1111 | #ISO_NAME="" 1112 | fi 1113 | fi 1114 | if [ "${FLG_QUIT}" = "1" ]; then 1115 | exit 0 1116 | fi 1117 | 1118 | # default values: 1119 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/casper/initrd.gz" 1120 | TFTP_APPEND_NFS="boot=casper netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1121 | TFTP_APPEND_OTHER="nosplash --" 1122 | #TFTP_APPEND="APPEND ${TFTP_APPEND_INITRD} ${TFTP_APPEND_NFS} ${TFTP_APPEND_OTHER}" 1123 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/casper/vmlinuz" 1124 | 1125 | rm -f "${FN_TMP_TFTPMENU}" 1126 | # setup values 1127 | TFTP_APPEND_NFS="" 1128 | case "$DIST_NAME_TYPE" in 1129 | "gentoo") 1130 | FLG_NFS=1 1131 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/isolinux/gentoo.igz" 1132 | TFTP_APPEND_NFS="root=/dev/ram0 loop=/image.squashfs init=/linuxrc looptype=squashfs cdroot=1 console=tty1 dokeymap" 1133 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} real_root=/dev/nfs netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1134 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1135 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/isolinux/gentoo" 1136 | ;; 1137 | 1138 | "doudoulinux") 1139 | # debian based live cd 1140 | FLG_NFS=1 1141 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/live/initrd.img" 1142 | TFTP_APPEND_NFS="boot=live config locales=zh_CN.UTF-8 nox11autologin splash nomodeset video=uvesafb:mode_option=640x480-16,mtrr=3,scroll=ywrap live-media=removable persistent persistent-subtext=doudoulinux username=tux hostname=doudoulinux quiet" 1143 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=/dev/nfs netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1144 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1145 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/live/vmlinuz" 1146 | 1147 | # automatically check the name of the 'vmlinuz' 1148 | A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS}") 1149 | B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1150 | TFTP_KERNEL="KERNEL ${B}" 1151 | B=$(echo ${A} | ${EXEC_AWK} '{print $2}' ) 1152 | TFTP_APPEND_INITRD="initrd=${B}" 1153 | ;; 1154 | 1155 | "debian") 1156 | mr_trace "[DBG] dist debian" 1157 | case "$DIST_TYPE" in 1158 | "server") 1159 | ;; 1160 | "live") 1161 | FLG_NFS=1 1162 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/live/initrd1.img" 1163 | TFTP_APPEND_NFS="boot=live live-config" 1164 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=/dev/nfs netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1165 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1166 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/live/vmlinuz1" 1167 | ;; 1168 | *) 1169 | mr_trace "[ERR] Not supported ubuntu type: ${DIST_TYPE}" 1170 | exit 0 1171 | ;; 1172 | esac 1173 | ;; 1174 | 1175 | "ubuntu"|"edubuntu") 1176 | mr_trace "[DBG] dist ubuntu" 1177 | case "$DIST_TYPE" in 1178 | "server") # server, alternate 1179 | mr_trace "[DBG] type server" 1180 | FLG_NFS=0 1181 | 1182 | # automatically check the name of the 'vmlinuz' 1183 | mr_trace "Ubuntu Server: " detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS} install/netboot/ubuntu-installer/${DIST_ARCH}/" 1184 | A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS} install/netboot/ubuntu-installer/${DIST_ARCH}/") 1185 | mr_trace "Ubuntu Server: detect_vmlinu_initrd() return: $A" 1186 | B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1187 | TFTP_KERNEL="KERNEL ${B}" 1188 | B=$(echo ${A} | ${EXEC_AWK} '{print $2}' ) 1189 | TFTP_APPEND_INITRD="initrd=${B}" 1190 | 1191 | TFTP_APPEND_INITRD="${TFTP_APPEND_INITRD} systemd.mask=dev-hugepages.mount systemd.mask=dev-mqueue.mount systemd.mask=sys-fs-fuse-connections.mount systemd.mask=sys-kernel-config.mount systemd.mask=sys-kernel-debug.mount systemd.mask=tmp.mount" 1192 | 1193 | TFTP_APPEND_NFS="showmounts toram boot=casper ip=dhcp ro ipv6.disable=1" 1194 | case "${SVR_PROTO}" in 1195 | "http") 1196 | #TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=live:http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}/casper/filesystem.squashfs ksdevice=bootif repo=http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}/" 1197 | # for 12 and above 1198 | TFTP_APPEND_NFS="mirror/country=manual mirror/http/hostname=${DIST_NFSIP} mirror/http/directory=/tftpboot/${DIST_MOUNTPOINT} live-installer/net-image=http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}/casper/filesystem.squashfs" 1199 | ;; 1200 | "tftp") 1201 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=live:tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT}/casper/filesystem.squashfs ksdevice=bootif repo=tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT}/" 1202 | ;; 1203 | *) 1204 | FLG_NFS=1 1205 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=/dev/nfs netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1206 | #TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=/dev/cifs netboot=cifs nfsroot=//${DIST_NFSIP}/${DIST_MOUNTPOINT} NFSOPTS=-ouser=user,pass=mypass,sec=ntlm,vers=1.0,ro " 1207 | ;; 1208 | esac 1209 | 1210 | 1211 | mr_trace "Ubuntu Server: TFTP_KERNEL: $TFTP_KERNEL" 1212 | mr_trace "Ubuntu Server: TFTP_APPEND_INITRD: $TFTP_APPEND_INITRD" 1213 | 1214 | 1215 | if [ "${FLG_NON_PAE}" = "1" ]; then 1216 | 1217 | #TFTP_ROOT="/home/yhfu/homegw/var/lib/tftpboot" 1218 | #DIST_MOUNTPOINT="images-server/ubuntu/13.04/i386" 1219 | #URL_INITRD="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/initrd3.8.019wtnonpa-20130429091312-e20cgo6obhlyk3fi-1/initrd-3.8.0-19-wt-non-pae_3.8.0-19.29_i386.lz" 1220 | 1221 | #cp "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}/install/netboot/ubuntu-installer/i386/initrd.gz" cd-initrd.gz 1222 | #cp "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/$(basename "${URL_INITRD}")" url-initrd.lz 1223 | 1224 | #mkdir cd 1225 | #cd cd 1226 | #gzip -dc ../cd-initrd.gz | cpio -id 1227 | #cd .. 1228 | 1229 | #mkdir url 1230 | #cd url 1231 | #lzma -dc -S .lz ../url-initrd.lz | cpio -id 1232 | #cd .. 1233 | 1234 | #cp -rp url/lib/modules/ cd/lib/ 1235 | #cp -rp url/lib/firmware/ cd/lib/ 1236 | 1237 | #cd cd 1238 | #find . | cpio --quiet --dereference -o -H newc | gzip -9 > ../new-initrd.gz 1239 | ## find . | cpio --quiet --dereference -o -H newc | lzma -7 > ../new-initrd.lz 1240 | #cd .. 1241 | 1242 | 1243 | URL_INITRD="http://${DIST_NFSIP}/initrd-3.8.0-19-wt-non-pae_3.8.0-19.29_i386.gz" 1244 | URL_VMLINUZ="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/vmlinuz3.8.019wtnonp-20130429091312-e20cgo6obhlyk3fi-5/vmlinuz-3.8.0-19-wt-non-pae_3.8.0-19.29_i386" 1245 | TFTP_KERNEL="KERNEL downloads/$(basename "${URL_VMLINUZ}")" 1246 | TFTP_APPEND_INITRD="initrd=downloads/$(basename "${URL_INITRD}")" 1247 | fi 1248 | ;; 1249 | 1250 | "desktop"|"live") 1251 | # desktop, live 1252 | FLG_NFS=0 1253 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/casper/initrd.lz" 1254 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1255 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/casper/vmlinuz" 1256 | 1257 | # automatically check the name of the 'vmlinuz' 1258 | mr_trace "Ubuntu Desktop: " detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS} install/netboot/ubuntu-installer/${DIST_ARCH}/" 1259 | A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS} install/netboot/ubuntu-installer/${DIST_ARCH}/") 1260 | mr_trace "Ubuntu Desktop: detect_vmlinu_initrd() return: $A" 1261 | B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1262 | TFTP_KERNEL="KERNEL ${B}" 1263 | #DEBUG: if [ ! "${TFTP_KERNEL}" = "KERNEL images-desktop/ubuntu/17.04/amd64/casper/vmlinuz.efi" ]; then mr_trace "[TEST] un-expected KERNEL!"; exit 2; fi 1264 | B=$(echo ${A} | ${EXEC_AWK} '{print $2}' ) 1265 | TFTP_APPEND_INITRD="initrd=${B}" 1266 | #DEBUG: if [ ! "${TFTP_APPEND_INITRD}" = "initrd=images-desktop/ubuntu/17.04/amd64/casper/initrd.lz" ]; then mr_trace "[TEST] un-expected initrd!"; exit 2; fi 1267 | 1268 | 1269 | TFTP_APPEND_NFS="showmounts toram boot=casper ip=dhcp ro ipv6.disable=1" 1270 | case "${SVR_PROTO}" in 1271 | "http") 1272 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=live:http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}/casper/filesystem.squashfs ksdevice=bootif repo=http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}/" 1273 | ;; 1274 | "tftp") 1275 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=live:tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT}/casper/filesystem.squashfs ksdevice=bootif repo=tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT}/" 1276 | ;; 1277 | *) 1278 | FLG_NFS=1 1279 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=/dev/nfs netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1280 | #TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=/dev/cifs netboot=cifs nfsroot=//${DIST_NFSIP}/${DIST_MOUNTPOINT} NFSOPTS=-ouser=user,pass=mypass,sec=ntlm,vers=1.0,ro " 1281 | ;; 1282 | esac 1283 | 1284 | 1285 | mr_trace "Ubuntu Desktop: TFTP_KERNEL: $TFTP_KERNEL" 1286 | mr_trace "Ubuntu Desktop: TFTP_APPEND_INITRD: $TFTP_APPEND_INITRD" 1287 | 1288 | if [ "${FLG_NON_PAE}" = "1" ]; then 1289 | URL_VMLINUZ= 1290 | if [ $(echo | ${EXEC_AWK} -v VER=$DIST_RELEASE '{ if (VER < 11) print 1; else print 0; }') = 1 ]; then 1291 | echo "Ubuntu 10 or lower support non-PAE. No need to use special steps" >> "${FN_TMP_LASTMSG}" 1292 | #elif [ $(echo | ${EXEC_AWK} -v VER=$DIST_RELEASE '{ if (VER < 12) print 1; else print 0; }') = 1 ]; then 1293 | ## version 11.x 1294 | #echo "" 1295 | elif [ $(echo | ${EXEC_AWK} -v VER=$DIST_RELEASE '{ if (VER < 13) print 1; else print 0; }') = 1 ]; then 1296 | # version 12.x 1297 | URL_VMLINUZ="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/vmlinuz3.5.017wtnonp-20121104150059-2ifucieir3hr7d7r-1/vmlinuz-3.5.0-17-wt-non-pae_3.5.0-17.28_i386" 1298 | URL_INITRD="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/initrd3.5.017wtnonpa-20121104150054-x38900ty5mmg8bub-1/initrd-3.5.0-17-wt-non-pae_3.5.0-17.28_i386.lz" 1299 | URL_PKG1="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/linuximage3.5.027wtn-20130411174046-2g7c1jtopun2y43m-1/linux-image-3.5.0-27-wt-non-pae_3.5.0-27.46_i386.deb" 1300 | URL_PKG2="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/linuxheaders3.5.027w-20130411174046-2g7c1jtopun2y43m-3/linux-headers-3.5.0-27-wt-non-pae_3.5.0-27.46_i386.deb" 1301 | URL_PKG3="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/linuxheaders3.5.027_-20130411174046-2g7c1jtopun2y43m-2/linux-headers-3.5.0-27_3.5.0-27.46_all.deb" 1302 | 1303 | elif [ $(echo | ${EXEC_AWK} -v VER=$DIST_RELEASE '{ if (VER < 14) print 1; else print 0; }') = 1 ]; then 1304 | # version 13.x 1305 | URL_INITRD="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/initrd3.8.019wtnonpa-20130429091312-e20cgo6obhlyk3fi-1/initrd-3.8.0-19-wt-non-pae_3.8.0-19.29_i386.lz" 1306 | URL_VMLINUZ="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/vmlinuz3.8.019wtnonp-20130429091312-e20cgo6obhlyk3fi-5/vmlinuz-3.8.0-19-wt-non-pae_3.8.0-19.29_i386" 1307 | URL_PKG1="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/linuximage3.8.019wtn-20130503212031-gaxgocw9r3bsn1mo-3/linux-image-3.8.0-19-wt-non-pae_3.8.0-19.30_i386.deb" 1308 | URL_PKG2="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/linuxheaders3.8.019w-20130503212031-gaxgocw9r3bsn1mo-2/linux-headers-3.8.0-19-wt-non-pae_3.8.0-19.30_i386.deb" 1309 | URL_PKG3="http://bazaar.launchpad.net/~webtom/+junk/linux-image-i386-non-pae/download/head:/linuxheaders3.8.019_-20130503212031-gaxgocw9r3bsn1mo-1/linux-headers-3.8.0-19_3.8.0-19.30_all.deb" 1310 | fi 1311 | if [ ! "${URL_VMLINUZ}" = "" ]; then 1312 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/" 1313 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/kickstarts/" 1314 | #$DO_EXEC down_url "${URL_INITRD}" 1315 | #$DO_EXEC down_url "${URL_VMLINUZ}" 1316 | #$DO_EXEC down_url "${URL_PKG1}" 1317 | #$DO_EXEC down_url "${URL_PKG2}" 1318 | #$DO_EXEC down_url "${URL_PKG3}" 1319 | $DO_EXEC wget --tries=3 --no-check-certificate -c "${URL_INITRD}" -O "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/$(basename "${URL_INITRD}")" 1320 | $DO_EXEC wget --tries=3 --no-check-certificate -c "${URL_VMLINUZ}" -O "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/$(basename "${URL_VMLINUZ}")" 1321 | $DO_EXEC wget --tries=3 --no-check-certificate -c "${URL_PKG1}" -O "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/$(basename "${URL_PKG1}")" 1322 | $DO_EXEC wget --tries=3 --no-check-certificate -c "${URL_PKG2}" -O "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/$(basename "${URL_PKG2}")" 1323 | $DO_EXEC wget --tries=3 --no-check-certificate -c "${URL_PKG3}" -O "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/$(basename "${URL_PKG3}")" 1324 | 1325 | TFTP_APPEND_INITRD="initrd=downloads/$(basename "${URL_INITRD}")" 1326 | #TFTP_APPEND_OTHER="nosplash ${TFTP_APPEND_OTHER}" 1327 | TFTP_KERNEL="KERNEL downloads/$(basename "${URL_VMLINUZ}")" 1328 | TFTP_MENU_LABEL="${TFTP_MENU_LABEL} non-PAE" 1329 | TFTP_TAG_LABEL="${TFTP_TAG_LABEL}_nonpae" 1330 | # kickstart: 1331 | FN_KS="ks-${DIST_NAME}-${DIST_RELEASE}-${DIST_ARCH}-${DIST_TYPE}-nonpae.ks" 1332 | cat << EOF > "${SYSTEM_TOP}/${TFTP_ROOT}/kickstarts/${FN_KS}" 1333 | %post 1334 | #wget --tries=3 --no-check-certificate "http://${DIST_NFSIP}/downloads/$(basename "${URL_PKG1}")" 1335 | #wget --tries=3 --no-check-certificate "http://${DIST_NFSIP}/downloads/$(basename "${URL_PKG2}")" 1336 | #wget --tries=3 --no-check-certificate "http://${DIST_NFSIP}/downloads/$(basename "${URL_PKG3}")" 1337 | 1338 | wget --tries=3 --no-check-certificate "${URL_PKG1}" 1339 | wget --tries=3 --no-check-certificate "${URL_PKG2}" 1340 | wget --tries=3 --no-check-certificate "${URL_PKG3}" 1341 | 1342 | dpkg --root=/target -i $(basename "${URL_PKG1}") 1343 | dpkg --root=/target -i $(basename "${URL_PKG2}") 1344 | dpkg --root=/target -i $(basename "${URL_PKG3}") 1345 | %end 1346 | EOF 1347 | TFTP_APPEND_OTHER="ks=http://${DIST_NFSIP}/kickstarts/${FN_KS} ${TFTP_APPEND_OTHER}" 1348 | echo "You may want to install non-PAE Linux kernel before the system reboots:" >> "${FN_TMP_LASTMSG}" 1349 | echo " (press ALT+CTRL+F1 to switch to the console)" >> "${FN_TMP_LASTMSG}" 1350 | echo " wget --tries=3 '${URL_PKG1}'" >> "${FN_TMP_LASTMSG}" 1351 | echo " wget --tries=3 '${URL_PKG2}'" >> "${FN_TMP_LASTMSG}" 1352 | echo " wget --tries=3 '${URL_PKG3}'" >> "${FN_TMP_LASTMSG}" 1353 | echo " dpkg --root=/target -i $(basename "${URL_PKG1}")" >> "${FN_TMP_LASTMSG}" 1354 | echo " dpkg --root=/target -i $(basename "${URL_PKG2}")" >> "${FN_TMP_LASTMSG}" 1355 | echo " dpkg --root=/target -i $(basename "${URL_PKG3}")" >> "${FN_TMP_LASTMSG}" 1356 | FLG_NON_PAE_PROCESSED=1 1357 | 1358 | fi 1359 | fi 1360 | ;; 1361 | 1362 | "net") 1363 | # netinstall 1364 | FLG_NFS=0 1365 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/initrd.gz" 1366 | TFTP_APPEND_NFS="" 1367 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1368 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/linux" 1369 | ;; 1370 | 1371 | *) 1372 | mr_trace "[ERR] Not supported ubuntu type: ${DIST_TYPE}" 1373 | exit 0 1374 | ;; 1375 | esac 1376 | ;; 1377 | 1378 | "elementaryos") 1379 | # desktop, live? 1380 | FLG_NFS=1 1381 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/casper/initrd.lz" 1382 | TFTP_APPEND_NFS="showmounts toram boot=casper ip=dhcp ro" 1383 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=/dev/nfs netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1384 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1385 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/casper/vmlinuz" 1386 | 1387 | # automatically check the name of the 'vmlinuz' 1388 | #A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS}") 1389 | #B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1390 | #TFTP_KERNEL="KERNEL ${B}" 1391 | #B=$(echo ${A} | ${EXEC_AWK} '{print $2}' ) 1392 | #TFTP_APPEND_INITRD="initrd=${B}" 1393 | ;; 1394 | 1395 | "mageia") 1396 | ITYPE="${DIST_ARCH}" 1397 | case "${DIST_ARCH}" in 1398 | "i386") 1399 | ITYPE=i586 1400 | ;; 1401 | esac 1402 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/isolinux/${ITYPE}/all.rdz automatic=method:http,ser:${DIST_NFSIP},dir:${DIST_MOUNTPOINT}/${ITYPE}/,int:eth0,netw:dhcp" 1403 | #TFTP_APPEND_NFS="root=/dev/nfs boot=casper netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1404 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1405 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/isolinux/${ITYPE}/vmlinuz" 1406 | 1407 | # automatically check the name of the 'vmlinuz' 1408 | A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS}") 1409 | B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1410 | TFTP_KERNEL="KERNEL ${B}" 1411 | ;; 1412 | 1413 | "backtrack") 1414 | FLG_NFS=1 1415 | mr_trace "[DBG] dist backtrack" 1416 | case "$DIST_TYPE" in 1417 | "oldlive") 1418 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/boot/initrd.gz" 1419 | TFTP_APPEND_NFS="BOOT=casper boot=casper nopersistent rw quite vga=0x317 " 1420 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1421 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1422 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/boot/vmlinuz" 1423 | ;; 1424 | 1425 | "live") 1426 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/casper/initrd.gz" 1427 | TFTP_APPEND_NFS="boot=casper" 1428 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1429 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1430 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/casper/vmlinuz" 1431 | ;; 1432 | 1433 | *) 1434 | mr_trace "[ERR] Not supported BT type: ${DIST_TYPE}" 1435 | exit 0 1436 | ;; 1437 | esac 1438 | ;; 1439 | 1440 | "kali") 1441 | mr_trace "[DBG] dist kali, type=$DIST_TYPE" 1442 | case "$DIST_TYPE" in 1443 | "net"|"mini") 1444 | FLG_NFS=0 1445 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/initrd.gz" 1446 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/linux" 1447 | ;; 1448 | "live") 1449 | FLG_NFS=1 1450 | # ISO: it's not feasible, the size of iso is larger than 2 GB. 1451 | #TFTP_APPEND_INITRD="iso raw" 1452 | #TFTP_KERNEL="KERNEL memdisk\n INITRD downloads/${ISO_NAME}" 1453 | 1454 | # NFS: 1455 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/live/initrd.img" 1456 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/live/vmlinuz" 1457 | TFTP_APPEND_NFS="noconfig=sudo username=root hostname=kali boot=live" 1458 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=/dev/nfs netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1459 | 1460 | FLG_DOWNKALIFIX=0 1461 | FN_INITRD= 1462 | URL_INITRD= 1463 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/kali1-fix/" 1464 | case "$DIST_RELEASE" in 1465 | "1.0.3") 1466 | FLG_NFS=1 1467 | if [ "${DIST_ARCH}" = "i386" ]; then 1468 | FN_INITRD=initrd-kali-1.0.3-3.7-trunk-686-pae.img 1469 | URL_INITRD="https://www.hashdump.org/files/initrd.img" 1470 | mr_trace "[WARNING] Use the i386 patch from" 1471 | mr_trace "[WARNING] https://wiki.hashdump.org/index.php/PXE::Kali" 1472 | else 1473 | mr_trace "[ERR] Unable to boot from NFS, please see" 1474 | mr_trace "[ERR] https://wiki.hashdump.org/index.php/PXE::Kali" 1475 | mr_trace "[ERR] for solution." 1476 | exit 0 1477 | FN_INITRD=initrd-kali-1.0.3-3.7-trunk-amd64.img 1478 | URL_INITRD="https://downloads.pxe-linux-iso.googlecode.com/git/patches/kali/${FN_INITRD}" 1479 | fi 1480 | DN_SAVE_INITRD="${SYSTEM_TOP}/${TFTP_ROOT}/downloads/kali1-fix/" 1481 | $DO_EXEC mkdir -p "${DN_SAVE_INITRD}" 1482 | $DO_EXEC down_url "${URL_INITRD}" "${DN_SAVE_INITRD}/${FN_INITRD}" 1483 | TFTP_APPEND_INITRD="initrd=downloads/kali1-fix/${FN_INITRD}" 1484 | ;; 1485 | 1486 | "1.0.4") 1487 | FLG_NFS=1 1488 | FLG_DOWNKALIFIX=1 1489 | if [ "${DIST_ARCH}" = "i386" ]; then 1490 | FN_INITRD=initrd-kali-1.0.4-3.7-trunk-686-pae.img 1491 | else 1492 | FN_INITRD=initrd-kali-1.0.4-3.7-trunk-amd64.img 1493 | fi 1494 | URL_INITRD="https://downloads.pxe-linux-iso.googlecode.com/git/patches/kali/${FN_INITRD}" 1495 | mr_trace "[DBG] kali 1.0.4, URL=${URL_INITRD}, INITRD=${FN_INITRD}" 1496 | ;; 1497 | 1498 | #"1.1.0") 1499 | #FLG_NFS=1 1500 | #FLG_DOWNKALIFIX=1 1501 | #if [ "${DIST_ARCH}" = "i386" ]; then 1502 | #FN_INITRD=initrd-kali-1.1.0-3.18.0-kali1-686-pae.img 1503 | #else 1504 | #FN_INITRD=initrd-kali-1.1.0-3.18.0-kali1-amd64.img 1505 | #fi 1506 | #URL_INITRD="https://downloads.pxe-linux-iso.googlecode.com/git/patches/kali/${FN_INITRD}" 1507 | #mr_trace "[DBG] kali 1.1.0, URL=${URL_INITRD}, INITRD=${FN_INITRD}" 1508 | #;; 1509 | 1510 | esac 1511 | if [ "${FLG_DOWNKALIFIX}" = "1" ]; then 1512 | mr_trace "[WARNING] Use the ${DIST_ARCH} patch from" 1513 | mr_trace "[WARNING] ${URL_INITRD}" 1514 | 1515 | DN_SAVE_INITRD="${SYSTEM_TOP}/${TFTP_ROOT}/downloads/kali1-fix/" 1516 | $DO_EXEC mkdir -p "${DN_SAVE_INITRD}" 1517 | $DO_EXEC down_url "${URL_INITRD}" "${DN_SAVE_INITRD}/${FN_INITRD}" 1518 | TFTP_APPEND_INITRD="initrd=downloads/kali1-fix/${FN_INITRD}" 1519 | if [ "${FLG_NON_PAE}" = "1" ]; then 1520 | echo "Not support Kali non-PAE kernel at present," >> "${FN_TMP_LASTMSG}" 1521 | echo "You may ask the author to add it in, or" >> "${FN_TMP_LASTMSG}" 1522 | echo "you want to read this to compile kernel by yourself:" >> "${FN_TMP_LASTMSG}" 1523 | echo "http://docs.kali.org/development/live-build-a-custom-kali-iso" >> "${FN_TMP_LASTMSG}" 1524 | echo "http://docs.kali.org/pdf/kali-book-en.pdf" >> "${FN_TMP_LASTMSG}" 1525 | echo "http://samiux.blogspot.com/2013/03/howto-rebuild-kali-linux-101.html" >> "${FN_TMP_LASTMSG}" 1526 | 1527 | #apt-get install git live-build cdebootstrap kali-archive-keyring 1528 | #git clone git://git.kali.org/live-build-config.git 1529 | #cd live-build-config 1530 | #sed -i 's/686-pae/486/g' auto/config 1531 | #lb clean 1532 | #lb config --architecture i386 1533 | #lb build 1534 | 1535 | fi 1536 | fi 1537 | ;; 1538 | esac 1539 | ;; 1540 | 1541 | "fedora") 1542 | mr_trace "[DBG] dist fedora" 1543 | case "$DIST_TYPE" in 1544 | "desktop"|"live") 1545 | #FLG_NFS=1 1546 | FLG_NFS=0 1547 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/isolinux/initrd0.img" 1548 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1549 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/isolinux/vmlinuz0" 1550 | 1551 | # automatically check the name of the 'vmlinuz' 1552 | A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS}") 1553 | B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1554 | TFTP_KERNEL="KERNEL ${B}" 1555 | B=$(echo ${A} | ${EXEC_AWK} '{print $2}' ) 1556 | TFTP_APPEND_INITRD="initrd=${B}" 1557 | TFTP_APPEND_INITRD="${TFTP_APPEND_INITRD} repo=http://${DIST_NFSIP}/${DIST_MOUNTPOINT}/ live:http://${DIST_NFSIP}/${DIST_MOUNTPOINT}/LiveOS/squashfs.img" 1558 | ;; 1559 | *) 1560 | mr_trace "[ERR] Not supported fedora type: ${DIST_TYPE}" 1561 | exit 0 1562 | ;; 1563 | esac 1564 | ;; 1565 | 1566 | "centos") 1567 | case "$DIST_TYPE" in 1568 | "server") 1569 | FLG_NFS=1 1570 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/isolinux/initrd.img" 1571 | TFTP_APPEND_NFS="" 1572 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1573 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/isolinux/vmlinuz" 1574 | ;; 1575 | 1576 | "net") 1577 | FLG_MOUNT=0 1578 | # following are ignored 1579 | 1580 | # netinstall 1581 | FLG_NFS=0 1582 | 1583 | TFTP_APPEND_NFS="" 1584 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1585 | 1586 | # automatically check the name of the 'vmlinuz' 1587 | A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS}") 1588 | B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1589 | TFTP_KERNEL="KERNEL ${B}" 1590 | B=$(echo ${A} | ${EXEC_AWK} '{print $2}' ) 1591 | TFTP_APPEND_INITRD="initrd=${B}" 1592 | ;; 1593 | 1594 | "desktop"|"live") 1595 | FLG_NFS=1 1596 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1597 | # automatically check the name of the 'vmlinuz' 1598 | A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DEFAULT_BOOTIMG_DIRS}") 1599 | B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1600 | TFTP_KERNEL="KERNEL ${B}" 1601 | B=$(echo ${A} | ${EXEC_AWK} '{print $2}' ) 1602 | TFTP_APPEND_INITRD="initrd=${B}" 1603 | 1604 | case "${SVR_PROTO}" in 1605 | "http") 1606 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=live:http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}/LiveOS/squashfs.img ksdevice=bootif repo=http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}/" 1607 | ;; 1608 | "tftp") 1609 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=live:tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT}/LiveOS/squashfs.img ksdevice=bootif repo=tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT}/" 1610 | ;; 1611 | *) 1612 | mr_trace "[ERR] unsupported file server protocol: ${SVR_PROTO}" 1613 | # ;; 1614 | #"nfs") 1615 | TFTP_APPEND_NFS="boot=casper" 1616 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} ip=dhcp root=/dev/nfs netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT} rw selinux=0" 1617 | ;; 1618 | esac 1619 | 1620 | ;; 1621 | *) 1622 | mr_trace "[ERR] Not supported centos type: ${DIST_TYPE}" 1623 | exit 0 1624 | ;; 1625 | esac 1626 | ;; 1627 | 1628 | "scientificlinux") 1629 | case "$DIST_TYPE" in 1630 | "server") 1631 | FLG_NFS=1 1632 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/isolinux/initrd.img" 1633 | TFTP_APPEND_NFS="" 1634 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1635 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/isolinux/vmlinuz" 1636 | ;; 1637 | "net") 1638 | FLG_MOUNT=0 1639 | ;; 1640 | 1641 | "desktop"|"live") 1642 | FLG_NFS=1 1643 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/isolinux/initrd0.img" 1644 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1645 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/isolinux/vmlinuz0" 1646 | TFTP_APPEND_NFS="boot=casper" 1647 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} root=/dev/nfs netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1648 | ;; 1649 | *) 1650 | mr_trace "[ERR] Not supported scientificlinux type: ${DIST_TYPE}" 1651 | exit 0 1652 | ;; 1653 | esac 1654 | ;; 1655 | 1656 | "opensuse") 1657 | case "$DIST_TYPE" in 1658 | "server") 1659 | FLG_NFS=1 1660 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/isolinux/initrd.img" 1661 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1662 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/isolinux/vmlinuz" 1663 | TFTP_APPEND_NFS="" 1664 | ;; 1665 | "net") 1666 | # netinstall 1667 | FLG_NFS=0 1668 | TFTP_APPEND_HTTP="install=http://download.opensuse.org/factory/repo/oss/" 1669 | 1670 | ITYPE="${DIST_ARCH}" 1671 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/boot/${ITYPE}/loader/initrd splash=silent vga=0x314 showopts" 1672 | TFTP_APPEND_OTHER="root=/dev/ram0 load_ramdisk=1 ramdisk_size=4096 init=linuxrc" 1673 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/boot/${ITYPE}/loader/linux" 1674 | ;; 1675 | "desktop"|"live") 1676 | FLG_NFS=0 1677 | TFTP_APPEND_HTTP="install=http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}/" 1678 | 1679 | ITYPE="${DIST_ARCH}" 1680 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/boot/${ITYPE}/loader/initrd splash=silent vga=0x314 showopts" 1681 | #TFTP_APPEND_NFS="root=/dev/nfs boot=casper netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1682 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1683 | TFTP_APPEND_OTHER="root=/dev/ram0 load_ramdisk=1 ramdisk_size=4096 init=linuxrc" 1684 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/boot/${ITYPE}/loader/linux" 1685 | ;; 1686 | *) 1687 | mr_trace "[ERR] Not supported centos type: ${DIST_TYPE}" 1688 | exit 0 1689 | ;; 1690 | esac 1691 | ;; 1692 | 1693 | "arch") 1694 | # dual option 1: load ISO to memory 1695 | # all of the command lines are passed 1696 | cat << EOF > "${FN_TMP_TFTPMENU}" 1697 | LABEL ${TFTP_TAG_LABEL}_iso 1698 | MENU LABEL ${TFTP_MENU_LABEL} (ISO) 1699 | KERNEL memdisk 1700 | #LINUX memdisk 1701 | INITRD downloads/${ISO_NAME} 1702 | #APPEND iso 1703 | APPEND iso raw 1704 | EOF 1705 | 1706 | # dual option 2-1: NFS i686 1707 | FLG_NFS=1 1708 | ITYPE="i686" 1709 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/arch/boot/${ITYPE}/archiso.img" 1710 | #TFTP_APPEND_HTTP="archiso_http_srv=http://${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1711 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/arch/boot/${ITYPE}/vmlinuz" 1712 | 1713 | #TFTP_APPEND_NFS="root=/dev/nfs boot=casper netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1714 | TFTP_APPEND_NFS="archisobasedir=arch" 1715 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} archiso_nfs_srv=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT} ip=:::::eth0:dhcp -" 1716 | 1717 | #TFTP_APPEND_OTHER="arch=i586" 1718 | #TFTP_APPEND="APPEND ${TFTP_APPEND_INITRD} ${TFTP_APPEND_NFS} ${TFTP_APPEND_OTHER}" 1719 | #cat << EOF >> "${FN_TMP_TFTPMENU}" 1720 | #LABEL ${TFTP_TAG_LABEL}_i586 1721 | #MENU LABEL ${TFTP_MENU_LABEL} (i586) 1722 | #${TFTP_KERNEL} 1723 | #${TFTP_APPEND} 1724 | #EOF 1725 | TFTP_APPEND_OTHER="arch=i686" 1726 | TFTP_APPEND="APPEND ${TFTP_APPEND_INITRD} ${TFTP_APPEND_NFS} ${TFTP_APPEND_OTHER}" 1727 | cat << EOF >> "${FN_TMP_TFTPMENU}" 1728 | LABEL ${TFTP_TAG_LABEL}_i686 1729 | MENU LABEL ${TFTP_MENU_LABEL} (i686) 1730 | ${TFTP_KERNEL} nouveau.modeset=0 i915.preliminary_hw_support=1 1731 | ${TFTP_APPEND} 1732 | EOF 1733 | 1734 | # dual option 2-2: NFS x86_64 1735 | ITYPE="x86_64" 1736 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/arch/boot/${ITYPE}/archiso.img" 1737 | TFTP_APPEND_OTHER="" 1738 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/arch/boot/${ITYPE}/vmlinuz" 1739 | TFTP_MENU_LABEL="${TFTP_MENU_LABEL} (x86_64)" 1740 | 1741 | TFTP_APPEND_NFS="archisobasedir=arch" 1742 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} archiso_nfs_srv=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT} ip=:::::eth0:dhcp -" 1743 | #TFTP_APPEND="APPEND ${TFTP_APPEND_INITRD} ${TFTP_APPEND_NFS} ${TFTP_APPEND_OTHER}" 1744 | 1745 | # or http? 1746 | # TFTP_APPEND_NFS="archisobasedir=arch archiso_pxe_http=${DIST_NFSIP}/${DIST_MOUNTPOINT} ip=:::::eth0:dhcp -" 1747 | ;; 1748 | 1749 | "antergos") 1750 | FLG_NFS=1 1751 | ITYPE="${DIST_ARCH}" 1752 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/arch/boot/archiso.img" 1753 | TFTP_APPEND_OTHER="" 1754 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/arch/boot/vmlinuz" 1755 | 1756 | TFTP_APPEND_NFS="archisobasedir=arch" 1757 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} archiso_nfs_srv=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT} ip=:::::eth0:dhcp -" 1758 | #TFTP_APPEND="APPEND ${TFTP_APPEND_INITRD} ${TFTP_APPEND_NFS} ${TFTP_APPEND_OTHER}" 1759 | ;; 1760 | 1761 | "archassault"|"evolution") 1762 | FLG_NFS=1 1763 | ITYPE="${DIST_ARCH}" 1764 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/arch/boot/${ITYPE}/archiso.img" 1765 | TFTP_APPEND_OTHER="arch=${DIST_ARCH}" 1766 | 1767 | TFTP_APPEND_NFS="archisobasedir=arch " 1768 | case "${SVR_PROTO}" in 1769 | "http") 1770 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} archiso_http_srv=http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT} ip=:::::eth0:dhcp -" 1771 | ;; 1772 | "tftp") 1773 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} archiso_tftp_srv=tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT} ip=:::::eth0:dhcp -" 1774 | ;; 1775 | *) 1776 | mr_trace "[ERR] unsupported file server protocol: ${SVR_PROTO}" 1777 | # ;; 1778 | #"nfs") 1779 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} archiso_nfs_srv=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT} ip=:::::eth0:dhcp -" 1780 | ;; 1781 | esac 1782 | 1783 | #TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/arch/boot/${ITYPE}/vmlinuz" 1784 | # automatically check the name of the 'vmlinuz' 1785 | A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "arch/boot ${DEFAULT_BOOTIMG_DIRS}") 1786 | B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1787 | TFTP_KERNEL="KERNEL ${B}" 1788 | ;; 1789 | 1790 | "manjaro") 1791 | FLG_NFS=1 1792 | ITYPE="${DIST_ARCH}" 1793 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/boot/intel_ucode.img,${DIST_MOUNTPOINT}/boot/initramfs-${ITYPE}.img" 1794 | TFTP_APPEND_NFS="misobasedir=manjaro ip=dhcp ipv6.disable=1 copytoram=y" 1795 | #misolabel=MJRO0812 nouveau.modeset=1 i915.modeset=1 radeon.modeset=1 logo.nologo overlay=free quiet splash showopts ip=dhcp 1796 | case "${SVR_PROTO}" in 1797 | "http") 1798 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} miso_http_srv=http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}" 1799 | ;; 1800 | "tftp") 1801 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} miso_tftp_srv=tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT}" 1802 | ;; 1803 | *) 1804 | mr_trace "[ERR] unsupported file server protocol: ${SVR_PROTO}" 1805 | # ;; 1806 | #"nfs") 1807 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} miso_nfs_srv=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1808 | ;; 1809 | esac 1810 | 1811 | #TFTP_APPEND_HTTP="archiso_http_srv=http://${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1812 | TFTP_APPEND_OTHER="arch=${DIST_ARCH}" 1813 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/boot/vmlinuz-${ITYPE}" 1814 | 1815 | # automatically check the name of the 'vmlinuz' 1816 | #A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "${DIST_NAME}/boot ${DEFAULT_BOOTIMG_DIRS}") 1817 | #B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1818 | #TFTP_KERNEL="KERNEL ${B}" 1819 | ;; 1820 | 1821 | "blackarchlinux") 1822 | #FLG_MOUNT=0 1823 | #echo "archassault|blackarchlinux|evolution is not support PXE?" 1824 | FLG_NFS=1 1825 | ITYPE="${DIST_ARCH}" 1826 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/blackarch/boot/${ITYPE}/archiso.img" 1827 | TFTP_APPEND_NFS="archisobasedir=blackarch ip=:::::eth0:dhcp" 1828 | case "${SVR_PROTO}" in 1829 | "http") 1830 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} archiso_http_srv=http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}" 1831 | ;; 1832 | "tftp") 1833 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} archiso_tftp_srv=tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT}" 1834 | ;; 1835 | *) 1836 | mr_trace "[ERR] unsupported file server protocol: ${SVR_PROTO}" 1837 | # ;; 1838 | #"nfs") 1839 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} archiso_nfs_srv=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1840 | ;; 1841 | esac 1842 | TFTP_APPEND_OTHER="arch=${DIST_ARCH}" 1843 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/blackarch/boot/${ITYPE}/vmlinuz" 1844 | 1845 | # automatically check the name of the 'vmlinuz' 1846 | A=$(detect_vmlinu_initrd "${DIST_MOUNTPOINT}" "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}" "blackarch/boot ${DEFAULT_BOOTIMG_DIRS}") 1847 | B=$(echo ${A} | ${EXEC_AWK} '{print $1}' ) 1848 | TFTP_KERNEL="KERNEL ${B}" 1849 | # the default password: 1850 | TFTP_MENU_LABEL=${TFTP_MENU_LABEL} root:blackarch 1851 | ;; 1852 | 1853 | "tails") 1854 | FLG_MOUNT=0 1855 | # following are ignored 1856 | 1857 | FLG_NFS=1 1858 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/live/initrd.img" 1859 | TFTP_APPEND_OTHER="" 1860 | TFTP_APPEND_OTHER="${TFTP_APPEND_OTHER} boot=live config live-media=removable apparmor=1 security=apparmor nopersistence noprompt block.events_dfl_poll_msecs=1000 noautologin module=Tails kaslr slab_nomerge slub_debug=FZ mce=0 vsyscall=none ipby=dhcp ro ipv6.disable=1" 1861 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/live/vmlinuz" 1862 | 1863 | TFTP_APPEND_NFS="netboot=cifs" 1864 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT} NFSOPTS=-ouser=serva,pass=avres,sec=ntlmssp,ro" 1865 | ;; 1866 | 1867 | "tinycore") 1868 | case "$DIST_TYPE" in 1869 | "plus") 1870 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/boot/vmlinuz" 1871 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/boot/core.gz" 1872 | DNR_TCE="cde/optional" 1873 | ;; 1874 | *) 1875 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/boot/bzImage" 1876 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/boot/tinycore.gz" 1877 | DNR_TCE="tce" 1878 | ;; 1879 | esac 1880 | 1881 | DNR_TINYCORE="downloads/tinycore-fix/" 1882 | $DO_EXEC mkdir -p "${DN_SAVE_INITRD}" 1883 | FN_NFSUTILS=tinycore-${DIST_RELEASE}-nfs-utils.tcz 1884 | $DO_EXEC down_url "http://tinycorelinux.net/4.x/${DIST_ARCH}/tcz/nfs-utils.tcz" "${SYSTEM_TOP}/${TFTP_ROOT}/${DNR_TINYCORE}/${FN_NFSUTILS}" 1885 | echo "/${DNR_TINYCORE}/${FN_NFSUTILS}" > "${SYSTEM_TOP}/${TFTP_ROOT}/${DNR_TINYCORE}/${ISO_NAME}-nfs.list" 1886 | TFTP_APPEND_NFS="tftplist=${DIST_NFSIP}:/${DNR_TINYCORE}/${ISO_NAME}-nfs.list tce=${DNR_TINYCORE}" 1887 | TFTP_APPEND_NFS="${TFTP_APPEND_NFS} nfsmount=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1888 | 1889 | ;; 1890 | 1891 | "clonezilla") 1892 | mr_trace "[DBG] dist fedora" 1893 | case "$DIST_TYPE" in 1894 | "live") 1895 | # http://clonezilla.org/livepxe.php 1896 | FLG_NFS=0 1897 | TFTP_APPEND_INITRD="initrd=${DIST_MOUNTPOINT}/live/initrd.img" 1898 | TFTP_APPEND_NFS="" 1899 | TFTP_APPEND_OTHER="" 1900 | if [ "${DIST_ARCH}" = "i386" ]; then 1901 | # add the 'union=overlay ' for using overlay (instead of aufs) 1902 | # according to http://sourceforge.net/p/clonezilla/discussion/Clonezilla_live/thread/0f8505b0/ 1903 | TFTP_APPEND_OTHER="union=overlay" 1904 | fi 1905 | TFTP_APPEND_OTHER="${TFTP_APPEND_OTHER} boot=live config noswap nolocales edd=on nomodeset ocs_live_run=\"ocs-live-general\" ocs_live_extra_param=\"\" keyboard-layouts=\"\" ocs_live_batch=\"no\" locales=\"\" vga=788 nosplash noprompt fetch=tftp://${DIST_NFSIP}/${DIST_MOUNTPOINT}/live/filesystem.squashfs" 1906 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/live/vmlinuz" 1907 | ;; 1908 | *) 1909 | mr_trace "[ERR] Not supported ISO type: ${DIST_TYPE}" 1910 | exit 0 1911 | ;; 1912 | esac 1913 | ;; 1914 | 1915 | "puppy") 1916 | # http://vercot.com/~serva/an/NonWindowsPXE3.html 1917 | #$DO_EXEC wget --tries=3 -c http://vercot.com/~serva/download/INITRD_N01.GZ -O ${TFTP_ROOT}/downloads/puppy-initrd_n01.gz 1918 | #cat << EOF > "${FN_TMP_TFTPMENU}" 1919 | #LABEL ${TFTP_TAG_LABEL}_iso 1920 | #MENU LABEL ${TFTP_MENU_LABEL} 1921 | #IPAPPEND 2 1922 | #KERNEL ${DIST_MOUNTPOINT}/vmlinuz 1923 | #INITRD ${DIST_MOUNTPOINT}/initrd.gz,downloads/puppy-initrd_n01.gz 1924 | #APPEND netpath=http://${DIST_NFSIP}/${DIST_MOUNTPOINT}/ 1925 | #EOF 1926 | check_install_package "$(which cpio)" cpio 1927 | $DO_EXEC rm -rf "${SYSTEM_TOP}/${TFTP_ROOT}/temp" 1928 | $DO_EXEC mkdir "${SYSTEM_TOP}/${TFTP_ROOT}/temp" 1929 | $DO_EXEC cd "${SYSTEM_TOP}/${TFTP_ROOT}/temp" 1930 | zcat "${SYSTEM_TOP}/${TFTP_ROOT}${TFTP_ROOT}/${DIST_MOUNTPOINT}/initrd.gz" | cpio -i -d 1931 | $DO_EXEC cp ${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}/*.sfs "${SYSTEM_TOP}/${TFTP_ROOT}/temp/" 1932 | find . | cpio -o -H newc | gzip -4 > "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/${DIST_NAME}-${DIST_ARCH}-${DIST_RELEASE}-initrd.gz" 1933 | $DO_EXEC cd .. 1934 | $DO_EXEC rm -rf "${SYSTEM_TOP}/${TFTP_ROOT}/temp" 1935 | $DO_EXEC cp "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}/vmlinuz" "${SYSTEM_TOP}/${TFTP_ROOT}/downloads/${DIST_NAME}-${DIST_ARCH}-${DIST_RELEASE}-vmlinuz" 1936 | $DO_EXEC umount "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1937 | TFTP_KERNEL="KERNEL downloads/${DIST_NAME}-${DIST_ARCH}-${DIST_RELEASE}-vmlinuz" 1938 | TFTP_APPEND_INITRD="initrd=downloads/${DIST_NAME}-${DIST_ARCH}-${DIST_RELEASE}-initrd.gz" 1939 | ;; 1940 | 1941 | "vmware") 1942 | FLG_NFS=1 1943 | mr_trace "[DBG] dist vmware" 1944 | case "$DIST_TYPE" in 1945 | "vmvisor") 1946 | FLG_NFS=0 1947 | #TFTP_APPEND_HTTP="prefix=http://${DIST_NFSIP}/tftpboot/${DIST_MOUNTPOINT}/" 1948 | #TFTP_APPEND_NFS="BOOT=casper boot=casper nopersistent rw quite vga=0x317 " 1949 | #TFTP_APPEND_NFS="${TFTP_APPEND_NFS} netboot=nfs nfsroot=${DIST_NFSIP}:${TFTP_ROOT}/${DIST_MOUNTPOINT}" 1950 | TFTP_APPEND_INITRD="-c ${DIST_MOUNTPOINT}/boot.cfg" 1951 | #TFTP_APPEND_OTHER=" ${TFTP_APPEND_OTHER}" 1952 | TFTP_KERNEL="KERNEL ${DIST_MOUNTPOINT}/mboot.c32" 1953 | ;; 1954 | 1955 | *) 1956 | mr_trace "[ERR] Not supported vmware type: ${DIST_TYPE}" 1957 | exit 0 1958 | ;; 1959 | esac 1960 | ;; 1961 | 1962 | 1963 | *) 1964 | mr_trace "[ERR] Not supported distribution: ${DIST_NAME}" 1965 | FLG_MOUNT=0 1966 | #exit 0 1967 | ;; 1968 | esac 1969 | 1970 | if [ "${FLG_MOUNT}" = "1" ]; then 1971 | TFTP_APPEND="APPEND ${TFTP_APPEND_INITRD} ${TFTP_APPEND_NFS} ${TFTP_APPEND_HTTP} ${TFTP_APPEND_OTHER}" 1972 | cat << EOF >> "${FN_TMP_TFTPMENU}" 1973 | LABEL ${TFTP_TAG_LABEL} 1974 | MENU LABEL ${TFTP_MENU_LABEL} 1975 | ${TFTP_KERNEL} nomodeset nouveau.modeset=0 i915.modeset=1 radeon.modeset=1 i915.preliminary_hw_support=1 1976 | ${TFTP_APPEND} 1977 | EOF 1978 | else 1979 | cat << EOF > "${FN_TMP_TFTPMENU}" 1980 | LABEL ${TFTP_TAG_LABEL}_iso 1981 | MENU LABEL ${TFTP_MENU_LABEL} 1982 | KERNEL memdisk 1983 | INITRD downloads/${ISO_NAME} 1984 | APPEND iso raw 1985 | EOF 1986 | # FIXME: the iso file has to be the real file, and should exists at the same folder as pxelinux.0 1987 | fi 1988 | 1989 | if [ "${FLG_MOUNT}" = "1" ]; then 1990 | if [ "$OSTYPE" = "OpenWrt" ]; then # openwrt 1991 | echo "config mount" > "${FN_TMP_OPENWRTFSTAB}" 1992 | echo " option enabled '1'" >> "${FN_TMP_OPENWRTFSTAB}" 1993 | echo " option options 'loop'" >> "${FN_TMP_OPENWRTFSTAB}" 1994 | echo " option fstype 'iso9660'" >> "${FN_TMP_OPENWRTFSTAB}" 1995 | echo " option device '${DIST_FILE}'" >> "${FN_TMP_OPENWRTFSTAB}" 1996 | echo " option target '${TFTP_ROOT}/${DIST_MOUNTPOINT}'" >> "${FN_TMP_OPENWRTFSTAB}" 1997 | echo "${DIST_FILE} ${TFTP_ROOT}/${DIST_MOUNTPOINT} udf,iso9660 loop,utf8 0 0" > "${FN_TMP_ETCFSTAB}" 1998 | else 1999 | echo "${DIST_FILE} ${TFTP_ROOT}/${DIST_MOUNTPOINT} udf,iso9660 auto,user,loop,utf8 0 0" > "${FN_TMP_ETCFSTAB}" 2000 | fi 2001 | fi 2002 | if [ "${FLG_NFS}" = "1" ]; then 2003 | echo "${TFTP_ROOT}/${DIST_MOUNTPOINT} *(ro,sync,no_wdelay,insecure_locks,no_subtree_check,no_root_squash,insecure)" > "${FN_TMP_ETCEXPORTS}" 2004 | fi 2005 | 2006 | if [ "${FLG_MOUNT}" = "1" ]; then 2007 | mr_trace "[INFO] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" 2008 | mr_trace "[INFO] You may want to mount the ISO by manual to test the file:" 2009 | mr_trace "[INFO] mkdir -p '${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}'" 2010 | mr_trace "[INFO] mount -o loop,utf8 '${SYSTEM_TOP}/${DIST_FILE}' '${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}'" 2011 | if [ "$OSTYPE" = "OpenWrt" ]; then # openwrt 2012 | mr_trace "[INFO] The following content will be attached to the etc/config/fstab file '${SYSTEM_TOP}/etc/config/fstab':" 2013 | mr_trace "" 2014 | cat "${FN_TMP_OPENWRTFSTAB}" | while read a; do mr_trace $a; done 2015 | fi 2016 | mr_trace "[INFO] The following content will be attached to the file etc/fstab '${SYSTEM_TOP}/etc/fstab':" 2017 | mr_trace "" 2018 | cat "${FN_TMP_ETCFSTAB}" | while read a; do mr_trace $a; done 2019 | mr_trace "" 2020 | mr_trace "[INFO] ==============================================================" 2021 | fi 2022 | 2023 | if [ "${FLG_NFS}" = "1" ]; then 2024 | mr_trace "[INFO] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" 2025 | mr_trace "[INFO] The following content will be attached to the etc/exports file '${SYSTEM_TOP}/etc/exports':" 2026 | mr_trace "" 2027 | cat "${FN_TMP_ETCEXPORTS}" | while read a; do mr_trace $a; done 2028 | mr_trace "" 2029 | mr_trace "[INFO] ==============================================================" 2030 | fi 2031 | if [ ! "${TFTP_APPEND_HTTP}" = "" ]; then 2032 | mr_trace "You need also setup HTTP server, so that the directory '${TFTP_ROOT}' can be accessed by: " 2033 | mr_trace " 'http://${DIST_NFSIP}/tftpboot/'" 2034 | fi 2035 | 2036 | mr_trace "[INFO] ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++" 2037 | mr_trace "[INFO] The following content will be attached to the pxelinux.cfg/default file" 2038 | mr_trace "[INFO] '${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/default':" 2039 | mr_trace "" 2040 | cat "${FN_TMP_TFTPMENU}" | while read a; do mr_trace $a; done 2041 | mr_trace "" 2042 | mr_trace "[INFO] ==============================================================" 2043 | 2044 | if [ "${FLG_NOINTERACTIVE}" = "0" ]; then 2045 | read -rsn 1 -p "Press any key to continue..." 2046 | fi 2047 | #mr_trace "[DBG] exit 0"; exit 0 2048 | EXEC_NFSEXT=$(which exportfs) 2049 | if [ ! -e "${EXEC_NFSEXT}" ]; then 2050 | if [ "${SYSTEM_TOP}" = "/" ]; then 2051 | $DO_EXEC install_package nfs-common nfs-kernel-server portmap 2052 | EXEC_NFSEXT=$(which exportfs) 2053 | fi 2054 | fi 2055 | 2056 | DN_PXEBACKUP="${SYSTEM_TOP}/etc/pxelinuxisobak/" 2057 | mkdir -p "${DN_PXEBACKUP}" 2058 | # -- ISO file mount point: ${SYSTEM_TOP}/etc/fstab 2059 | $DO_EXEC mkdir -p "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}/" 2060 | $DO_EXEC umount "${DIST_FILE}" 2061 | $DO_EXEC umount "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}" 2062 | #$DO_EXEC mount -o loop,utf8 "${DIST_FILE}" "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}" 2063 | if [ ! "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}" = "${SYSTEM_TOP}//" ]; then 2064 | grep -v "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}" ${SYSTEM_TOP}/etc/fstab > /tmp/bbb 2065 | else 2066 | cp ${SYSTEM_TOP}/etc/fstab /tmp/bbb 2067 | fi 2068 | if [ ! "${DIST_FILE}" = "" ]; then 2069 | grep -v "${DIST_FILE}" /tmp/bbb > /tmp/aaa 2070 | else 2071 | cp /tmp/bbb /tmp/aaa 2072 | fi 2073 | diff -Nbu ${SYSTEM_TOP}/etc/fstab /tmp/aaa 2074 | RET=$? 2075 | if [ ! "$RET" = "0" ]; then 2076 | # backup the old fstab 2077 | mr_trace "[INFO] the old ${SYSTEM_TOP}/etc/fstab saved to ${DN_PXEBACKUP}/fstab-$(date +%Y%m%d-%H%M%S)" 2078 | $DO_EXEC cp ${SYSTEM_TOP}/etc/fstab "${DN_PXEBACKUP}/fstab-$(date +%Y%m%d-%H%M%S)" 2079 | # update the fatab 2080 | $DO_EXEC mv /tmp/aaa ${SYSTEM_TOP}/etc/fstab 2081 | fi 2082 | $DO_EXEC attach_to_file "${FN_TMP_ETCFSTAB}" ${SYSTEM_TOP}/etc/fstab 2083 | 2084 | # fstab for openwrt: 2085 | if [ "$OSTYPE" = "OpenWrt" ]; then # openwrt 2086 | mr_trace "[DBG] add to fstab for openwrt" 2087 | $DO_EXEC cat "${FN_TMP_OPENWRTFSTAB}" >> ${SYSTEM_TOP}/etc/config/fstab 2088 | if [ "${SYSTEM_TOP}" = "/" ]; then 2089 | $DO_EXEC ${SYSTEM_TOP}/etc/init.d/fstab enable # enable at boot 2090 | $DO_EXEC block umount 2091 | $DO_EXEC block mount # start now 2092 | fi 2093 | fi 2094 | 2095 | echo "mount ${TFTP_ROOT}/${DIST_MOUNTPOINT}" > "${FN_TMP_ETCRCLOCAL}" 2096 | grep -v "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}" ${SYSTEM_TOP}/etc/rc.local > /tmp/aaa 2097 | diff -Nbu ${SYSTEM_TOP}/etc/rc.local /tmp/aaa 2098 | RET=$? 2099 | if [ ! "$RET" = "0" ]; then 2100 | # backup the old rc.local 2101 | mr_trace "[INFO] the old ${SYSTEM_TOP}/etc/rc.local saved to ${DN_PXEBACKUP}/rc.local-$(date +%Y%m%d-%H%M%S)" 2102 | $DO_EXEC cp ${SYSTEM_TOP}/etc/rc.local "${DN_PXEBACKUP}/rc.local-$(date +%Y%m%d-%H%M%S)" 2103 | # update the rc.local 2104 | $DO_EXEC mv /tmp/aaa ${SYSTEM_TOP}/etc/rc.local 2105 | fi 2106 | $DO_EXEC attach_to_file "${FN_TMP_ETCRCLOCAL}" ${SYSTEM_TOP}/etc/rc.local 2107 | #$DO_EXEC mount -a 2108 | #chmod 755 "${FN_TMP_ETCRCLOCAL}" 2109 | . "${FN_TMP_ETCRCLOCAL}" 2110 | 2111 | # -- NFS 2112 | if [ "${FLG_NFS}" = "1" ]; then 2113 | if [ ! "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}" = "/" ]; then 2114 | grep -v "${SYSTEM_TOP}/${TFTP_ROOT}/${DIST_MOUNTPOINT}" ${SYSTEM_TOP}/etc/exports > /tmp/aaa 2115 | # backup the old exports 2116 | mr_trace "[INFO] the old ${SYSTEM_TOP}/etc/exports saved to ${DN_PXEBACKUP}/exports-$(date +%Y%m%d-%H%M%S)" 2117 | $DO_EXEC cp ${SYSTEM_TOP}/etc/exports "${DN_PXEBACKUP}/exports-$(date +%Y%m%d-%H%M%S)" 2118 | # update exports 2119 | $DO_EXEC cp /tmp/aaa ${SYSTEM_TOP}/etc/exports 2120 | fi 2121 | $DO_EXEC attach_to_file "${FN_TMP_ETCEXPORTS}" ${SYSTEM_TOP}/etc/exports 2122 | if [ "${SYSTEM_TOP}" = "/" ]; then 2123 | #if [ -e `which systemctl` ]; then $DO_EXEC sudo service nfs-kernel-server restart; fi # Debian/Ubuntu 2124 | #if [ -e `which systemctl` ]; then $DO_EXEC service nfs restart; fi # RedHat/CentOS 2125 | #if [ -e `which systemctl` ]; then $DO_EXEC systemctl restart rpc-idmapd.service; fi 2126 | #if [ -e `which systemctl` ]; then $DO_EXEC systemctl restart rpc-mountd.service; fi 2127 | if [ -e "${EXEC_NFSEXT}" ]; then $DO_EXEC ${EXEC_NFSEXT} -arv; fi 2128 | if [ -e `which systemctl` ]; then $DO_EXEC systemctl restart rpcbind nfs-server; fi 2129 | if [ -e /etc/init.d/rpcd ]; then $DO_EXEC /etc/init.d/rpcd restart; fi # openwrt 2130 | if [ -e /etc/init.d/nfsd ]; then $DO_EXEC /etc/init.d/nfsd restart; fi # openwrt 2131 | fi 2132 | fi 2133 | 2134 | # -- TFTP menu: ${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/default 2135 | $DO_EXEC attach_to_file "${FN_TMP_TFTPMENU}" "${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/default" 2136 | 2137 | # -- TFTP menu msg: ${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/boot.txt 2138 | if [ ! "${DIST_NAME}_${DIST_RELEASE}_${DIST_ARCH}_nfs" = "" ]; then 2139 | grep -v "${TFTP_TAG_LABEL}" "${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/boot.txt" > /tmp/aaa 2140 | $DO_EXEC mv /tmp/aaa "${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/boot.txt" 2141 | fi 2142 | $DO_EXEC echo "${TFTP_TAG_LABEL}" >> "${SYSTEM_TOP}/${TFTP_ROOT}/pxelinux.cfg/boot.txt" 2143 | if [ "${SYSTEM_TOP}" = "/" ]; then 2144 | if [ -e /etc/init.d/tftpd-hpa ]; then $DO_EXEC /etc/init.d/tftpd-hpa restart; fi # debian/ubuntu 2145 | if [ -e `which service` ]; then $DO_EXEC service xinetd restart; fi # redhat/centos 2146 | if [ -e `which systemctl` ]; then $DO_EXEC systemctl restart tftpd.socket tftpd.service; fi # arch 2147 | if [ -e /etc/init.d/dnsmasq ]; then $DO_EXEC /etc/init.d/dnsmasq restart; fi # openwrt 2148 | fi 2149 | } 2150 | 2151 | process_file_list () { 2152 | #FN_MD5SUM=$1 2153 | #shift 2154 | 2155 | #mr_trace "[DBG] begin 1" 2156 | while : 2157 | do 2158 | #mr_trace "[DBG] read 1" 2159 | read TMPFN 2160 | if [ "${TMPFN}" = "" ]; then 2161 | #mr_trace "[DBG] End of TMPFN" 2162 | break; 2163 | fi 2164 | if [ "${TITLE_BOOT}" = "" ]; then 2165 | mr_trace "[DBG] tftp_setup_pxe_iso '${TMPFN}'" 2166 | tftp_setup_pxe_iso "${TMPFN}" 2167 | else 2168 | mr_trace "[DBG] tftp_setup_pxe_iso '${TMPFN}' '${TITLE_BOOT}'" 2169 | tftp_setup_pxe_iso "${TMPFN}" "${TITLE_BOOT}" 2170 | fi 2171 | done 2172 | } 2173 | 2174 | ##################################################################### 2175 | # start of script 2176 | # read the arguments of commandline 2177 | # 2178 | 2179 | usage () { 2180 | PARAM_NAME="$1" 2181 | 2182 | echo "${PARAM_NAME} v0.1" ${OUT_TO_STDERR} 2183 | echo "" ${OUT_TO_STDERR} 2184 | echo "Prepare the TFTP root directory for Linux distributions' ISO files" ${OUT_TO_STDERR} 2185 | echo "So you can boot the installation CD/DVD from network(PXE)" ${OUT_TO_STDERR} 2186 | echo "Written by yhfudev(yhfudev@gmail.com), 2013-07" ${OUT_TO_STDERR} 2187 | echo "" ${OUT_TO_STDERR} 2188 | echo "${PARAM_NAME} [options] " ${OUT_TO_STDERR} 2189 | echo "" ${OUT_TO_STDERR} 2190 | echo "Options:" ${OUT_TO_STDERR} 2191 | echo " --help Print this message" ${OUT_TO_STDERR} 2192 | echo " --init Init TFTP directory environment" ${OUT_TO_STDERR} 2193 | echo " --chgroot set the system top directory, default: ${SYSTEM_TOP}" ${OUT_TO_STDERR} 2194 | echo " --tftproot set the tftp root folder, default: ${TFTP_ROOT}" ${OUT_TO_STDERR} 2195 | echo " --nfsip set NFS server IP, default: ${DIST_NFSIP}" ${OUT_TO_STDERR} 2196 | echo " --title set the boot title" ${OUT_TO_STDERR} 2197 | echo " --nonpae add non-PAE for old machine" ${OUT_TO_STDERR} 2198 | 2199 | echo " --distname set the OS type of ISO, such as centos, ubuntu, arch" ${OUT_TO_STDERR} 2200 | echo " --distarch set the arch of the OS, such as amd64, x86_64, i386, i686" ${OUT_TO_STDERR} 2201 | echo " --distrelease set the distribution release, such as quantal,raring" ${OUT_TO_STDERR} 2202 | echo " --disttype set the type of ISO, such as net, server, desktop." ${OUT_TO_STDERR} 2203 | 2204 | echo " --nointeractive|-n not interactive" ${OUT_TO_STDERR} 2205 | echo " --simulate|-s not do the real work, just show the info" ${OUT_TO_STDERR} 2206 | echo "" ${OUT_TO_STDERR} 2207 | echo "Features" ${OUT_TO_STDERR} 2208 | echo " 1. One single command line to setup a PXE entry to boot from CD/DVD" ${OUT_TO_STDERR} 2209 | echo " 2. Can be run in Redhat/CentOS/Ubuntu/Archlinux" ${OUT_TO_STDERR} 2210 | echo " 2. Support CD/DVDs of Fedora/CentOS/Debian/Ubuntu/Mint/Kali/..." ${OUT_TO_STDERR} 2211 | echo "" ${OUT_TO_STDERR} 2212 | echo "Prerequisites" ${OUT_TO_STDERR} 2213 | echo "" ${OUT_TO_STDERR} 2214 | echo " 1. Installed NFS server. This script will append lines to file ${SYSTEM_TOP}/etc/exports;" ${OUT_TO_STDERR} 2215 | echo " 2. Installed TFTP server. This script will append lines to file" ${OUT_TO_STDERR} 2216 | echo " /var/lib/tftpboot/pxelinux.cfg/default;" ${OUT_TO_STDERR} 2217 | echo " 3. To mount ISO files as loop device, a line will also be appended to ${SYSTEM_TOP}/etc/fstab, and" ${OUT_TO_STDERR} 2218 | echo " ${SYSTEM_TOP}/etc/rc.local;" ${OUT_TO_STDERR} 2219 | echo " 4. Installed syslinux;" ${OUT_TO_STDERR} 2220 | echo "" ${OUT_TO_STDERR} 2221 | echo "Installation" ${OUT_TO_STDERR} 2222 | echo " Download the source files from GIT repo" ${OUT_TO_STDERR} 2223 | echo " git clone https://code.google.com/p/pxe-linux-iso/" ${OUT_TO_STDERR} 2224 | echo "" ${OUT_TO_STDERR} 2225 | echo "Initialize directories" ${OUT_TO_STDERR} 2226 | echo "" ${OUT_TO_STDERR} 2227 | echo " This script use following tree structure to manage the ISO files:" ${OUT_TO_STDERR} 2228 | echo " /var/lib/tftpboot/" ${OUT_TO_STDERR} 2229 | echo " |-- downloads # the downloaded CD/DVD ISO files and patches" ${OUT_TO_STDERR} 2230 | echo " |-- images-desktop # mount points for Linux desktop distributions" ${OUT_TO_STDERR} 2231 | echo " |-- images-server # mount points for Linux server distributions" ${OUT_TO_STDERR} 2232 | echo " |-- images-net # mount points for netinstall" ${OUT_TO_STDERR} 2233 | echo " |-- kickstarts # kickstart scripts" ${OUT_TO_STDERR} 2234 | echo "" ${OUT_TO_STDERR} 2235 | echo " The following files also be initialized with default headers:" ${OUT_TO_STDERR} 2236 | echo " /var/lib/tftpboot/pxelinux.cfg/default" ${OUT_TO_STDERR} 2237 | echo " /var/lib/tftpboot/pxelinux.cfg/boot.txt" ${OUT_TO_STDERR} 2238 | echo "" ${OUT_TO_STDERR} 2239 | echo "Examples" ${OUT_TO_STDERR} 2240 | echo "" ${OUT_TO_STDERR} 2241 | echo " 0. Help!" ${OUT_TO_STDERR} 2242 | echo " ${PARAM_NAME} --help" ${OUT_TO_STDERR} 2243 | echo "" ${OUT_TO_STDERR} 2244 | echo " 1. Initialize directories" ${OUT_TO_STDERR} 2245 | echo " sudo ${PARAM_NAME} --init" ${OUT_TO_STDERR} 2246 | echo "" ${OUT_TO_STDERR} 2247 | echo " 2. Add entries to the PXE server" ${OUT_TO_STDERR} 2248 | echo "" ${OUT_TO_STDERR} 2249 | echo " 2.1 Add Ubuntu mini" ${OUT_TO_STDERR} 2250 | echo " sudo ${PARAM_NAME} --nfsip 192.168.1.1 'http://mirror.anl.gov/pub/ubuntu/dists/quantal/main/installer-amd64/current/images/netboot/mini.iso'" ${OUT_TO_STDERR} 2251 | echo "" ${OUT_TO_STDERR} 2252 | echo " 2.2 Add Kali" ${OUT_TO_STDERR} 2253 | echo " sudo ${PARAM_NAME} --nfsip 192.168.1.1 --title 'Kali' 'http://archive-5.kali.org/kali-images/kali-linux-1.0.4-amd64.iso'" ${OUT_TO_STDERR} 2254 | echo "" ${OUT_TO_STDERR} 2255 | } 2256 | 2257 | rm -f "${FN_TMP_LIST}" 2258 | rm -f "${FN_TMP_LASTMSG}" 2259 | touch "${FN_TMP_LASTMSG}" 2260 | 2261 | # the file server protocol: nfs, http, https, ftp, tftp etc 2262 | SVR_PROTO=nfs 2263 | # init tftp directory? 2264 | FLG_INIT_TFTPROOT=0 2265 | # add non-PAE installation (for Ubuntu) 2266 | FLG_NON_PAE=0 2267 | FLG_NON_PAE_PROCESSED=0 2268 | # ask user for choices? 2269 | FLG_NOINTERACTIVE=0 2270 | # simulate 2271 | FLG_SIMULATE=0 2272 | FN_FULL="" 2273 | TITLE_BOOT="" 2274 | A_DIST_NAME="" 2275 | A_DIST_RELEASE="" 2276 | A_DIST_ARCH="" 2277 | A_DIST_TYPE="" 2278 | while [ ! "$1" = "" ]; do 2279 | case "$1" in 2280 | --help|-h) 2281 | usage "$0" 2282 | exit 0 2283 | ;; 2284 | --init) 2285 | FLG_INIT_TFTPROOT=1 2286 | ;; 2287 | 2288 | --chgroot) 2289 | shift 2290 | export SYSTEM_TOP="$1" 2291 | ;; 2292 | 2293 | --svrproto) 2294 | shift 2295 | export SVR_PROTO="$1" 2296 | ;; 2297 | --tftproot) 2298 | shift 2299 | export TFTP_ROOT="$1" 2300 | ;; 2301 | --nfsip) 2302 | shift 2303 | export DIST_NFSIP="$1" 2304 | ;; 2305 | --title) 2306 | shift 2307 | TITLE_BOOT="$1" 2308 | ;; 2309 | --distname) 2310 | shift 2311 | A_DIST_NAME="$1" 2312 | ;; 2313 | --distui) 2314 | shift 2315 | A_DIST_UI="$1" 2316 | ;; 2317 | --distarch) 2318 | shift 2319 | A_DIST_ARCH="$1" 2320 | ;; 2321 | --distrelease) 2322 | shift 2323 | A_DIST_RELEASE="$1" 2324 | ;; 2325 | --disttype) 2326 | shift 2327 | A_DIST_TYPE="$1" 2328 | ;; 2329 | --nointeractive|-n) 2330 | FLG_NOINTERACTIVE=1 2331 | ;; 2332 | --simulate|-s) 2333 | FLG_SIMULATE=1 2334 | ;; 2335 | --nonpae|--nopae) 2336 | FLG_NON_PAE=1 2337 | ;; 2338 | -*) 2339 | mr_trace "Unknown option: $1" 2340 | mr_trace "Use option --help to get the usages." 2341 | exit 1 2342 | ;; 2343 | *) 2344 | echo "$1" >> "${FN_TMP_LIST}" 2345 | FN_FULL="${FN_FULL} $1" 2346 | break; 2347 | ;; 2348 | esac 2349 | shift 2350 | done 2351 | 2352 | if [ ! "${SYSTEM_TOP}" = "/" ]; then 2353 | mr_trace "TFTP_ROOT also used in the config file, so we use prefix ${SYSTEM_TOP}/${TFTP_ROOT}" 2354 | #export TFTP_ROOT=${SYSTEM_TOP}/${TFTP_ROOT} 2355 | #export HTTPD_ROOT=${SYSTEM_TOP}/${HTTPD_ROOT} 2356 | fi 2357 | 2358 | if [ ! -d "${SYSTEM_TOP}/${TFTP_ROOT}" ]; then 2359 | TFTP_ROOT="/media/tftpboot" 2360 | fi 2361 | if [ ! -d "${SYSTEM_TOP}/${TFTP_ROOT}" ]; then 2362 | TFTP_ROOT="/srv/tftp" 2363 | fi 2364 | if [ ! -d "${SYSTEM_TOP}/${TFTP_ROOT}" ]; then 2365 | TFTP_ROOT="/mnt/tftpboot" 2366 | fi 2367 | if [ ! -d "${SYSTEM_TOP}/${HTTPD_ROOT}" ]; then 2368 | export HTTPD_ROOT=/srv/http 2369 | fi 2370 | if [ ! -d "${SYSTEM_TOP}/${HTTPD_ROOT}" ]; then 2371 | export HTTPD_ROOT=/var/www/html 2372 | fi 2373 | if [ ! -d "${SYSTEM_TOP}/${HTTPD_ROOT}" ]; then 2374 | export HTTPD_ROOT=/www 2375 | fi 2376 | 2377 | 2378 | mr_trace "[DBG] FN_FULL=$FN_FULL" 2379 | mr_trace "[DBG] FLG_NON_PAE=$FLG_NON_PAE" 2380 | 2381 | # attach the content of a file to the end of another file. 2382 | attach_to_file () { 2383 | if [ -f "$1" ]; then 2384 | cat "$1" >> "$2" 2385 | fi 2386 | } 2387 | DO_EXEC=myexec_trace 2388 | #DO_EXEC= 2389 | if [ "$FLG_SIMULATE" = "1" ]; then 2390 | DO_EXEC=myexec_ignore 2391 | fi 2392 | 2393 | mr_trace "[DBG] Install basic software packages ..." 2394 | 2395 | EXEC_AWK="$(which gawk)" 2396 | if [ ! -x "${EXEC_AWK}" ]; then 2397 | install_package gawk 2398 | fi 2399 | 2400 | EXEC_AWK="$(which gawk)" 2401 | if [ ! -x "${EXEC_AWK}" ]; then 2402 | mr_trace "[ERR] Not exist awk!" 2403 | exit 1 2404 | fi 2405 | echo | ${EXEC_AWK} '{a = 1; switch(a) { case 0: break; } }' > /dev/null 2>&1 2406 | if [ $? = 1 ]; then 2407 | # patch gawk 2408 | mr_trace "[WARNING] awk not support switch() ..." 2409 | install_package gawk 2410 | fi 2411 | 2412 | EXEC_WGET="$(which wget)" 2413 | if [ ! -x "${EXEC_WGET}" ]; then 2414 | mr_trace "[DBG] Try to install wget." 2415 | install_package wget 2416 | fi 2417 | 2418 | EXEC_WGET="$(which wget)" 2419 | if [ ! -x "${EXEC_WGET}" ]; then 2420 | mr_trace "[ERR] Not exist wget!" 2421 | exit 1 2422 | fi 2423 | 2424 | EXEC_ENV="$(which env)" 2425 | if [ ! -x "${EXEC_ENV}" ]; then 2426 | mr_trace "[DBG] Try to install coreutils." 2427 | install_package coreutils 2428 | fi 2429 | 2430 | tftp_init_directories 2431 | if [ "${FLG_INIT_TFTPROOT}" = "1" ]; then 2432 | tftp_init_service 2433 | fi 2434 | 2435 | #if [ "${FN_FULL}" = "" ]; then 2436 | #usage "$0" 2437 | #exit 1 2438 | #fi 2439 | 2440 | cat << EOF > ${FN_MD5TMP} 2441 | 0c5fab6fff4c431a8827754f0b3bc13f archlinux-2013.07.01-dual.iso 2442 | af139d2a085978618dc53cabc67b9269 bt4-final.iso 2443 | d324687fb891e695089745d461268576 BT5R3-KDE-32.iso 2444 | 981b897b7fdf34fb1431ba84fe93249f BT5R3-KDE-64.iso 2445 | afb8c6192a2e1d1ba0fa3db9c531be6d pentoo-i686-2013.0_RC1.8.iso 2446 | 9ed0286a23eeae77be6fd9b952c5f62c initrd-kali-1.0.3-3.7-trunk-686-pae.img 2447 | a6aaec29dad544d9d3c86d3bf63d7486 initrd-kali-1.0.4-3.7-trunk-686-pae.img 2448 | a5bd239b9017943e0e4598ece7e7e85f initrd-kali-1.0.4-3.7-trunk-amd64.img 2449 | e9cae6b8b1c8bbf9ceae4ea7cf575589 beini-1.2.5-es.iso 2450 | 2451 | 8d72e2db7e72e13813731eab37a14d26 ubuntu-13.04-desktop-amd64.iso 2452 | 73d595b804149fca9547ed94db8ff44f ubuntu-13.04-server-i386.iso 2453 | c187e39bdb6e09283a8976caadd756b6 linux-headers-3.8.0-19_3.8.0-19.30_all.deb 2454 | 037f96bdbfef9c587289c58532e40f47 linux-headers-3.8.0-19-wt-non-pae_3.8.0-19.30_i386.deb 2455 | a7ef8da234153e7c8daba0f82f282df8 linux-image-3.8.0-19-wt-non-pae_3.8.0-19.30_i386.deb 2456 | 0f707986757bd93a4f0efb9b521aca38 initrd-3.8.0-19-wt-non-pae_3.8.0-19.29_i386.lz 2457 | d3374a10f71468978428a383c3267aae vmlinuz-3.8.0-19-wt-non-pae_3.8.0-19.29_i386 2458 | 2459 | 4a5fa01c81cc300f4729136e28ebe600 CentOS-6.4-x86_64-minimal.iso 2460 | f87e89a502fb2d1f30ca0f9a927c9a91 archlinux-2013.09.01-dual.iso 2461 | e6b72dee252d9b3c32d9b7d56ed93b51 archlinux-2014.02.01-dual.iso 2462 | 03c490a202ffa7accf2638b62a357849 clonezilla-live-20131216-trusty-i386.iso 2463 | 2464 | b6658ab75cd5d48f358f0ee31b06b934 lupu-525.iso 2465 | ea177aa9af0b4806cc82742f7ba946df slacko-5.6-4G-NON-PAE.iso 2466 | EOF 2467 | 2468 | cat << EOF > ${FN_SHA1TMP} 2469 | bb074cad7b6d8e09f936ee7c922a30362d8d7940 kali-linux-1.0-amd64-mini.iso 2470 | f1c1dbce42d88bae4ed5683655701e5847e23246 kali-linux-1.0-i386-mini.iso 2471 | 95a0eab94407d7ebf0ec6fbd189d883aa772d21d kali-linux-1.0.3-amd64.iso 2472 | 54af51b9f4bf3d77ecd45e548de308837c546b12 kali-linux-1.0.3-i386.iso 2473 | fed4ae5157237c57d7815e475f7a9ddc38a13208 kali-linux-1.0.4-amd64-mini.iso 2474 | bb14f4e1fc0656a14615e40d727f6c49e8202d38 kali-linux-1.0.4-amd64.iso 2475 | 01324e8486f16d7d754e1602b9afe135f5e98c8a kali-linux-1.0.4-i386-mini.iso 2476 | 68b91a8894709cc132ab7cd9eca57513e1ce478b kali-linux-1.0.4-i386.iso 2477 | 6232efa014d9c6798396b63152c4c9a08b279f5e CentOS-6.4-x86_64-minimal.iso 2478 | 27bbe172d66d4ce634d10fd655e840f72fe56130 ubuntu-13.04-server-i386.iso 2479 | 3b087acd273656c55244baa7b7f1a147be7da990 archlinux-2013.09.01-dual.iso 2480 | eb4c971c71b505b5c1be25f1710e6579987fda3b archlinux-2014.02.01-dual.iso 2481 | eeb8088f5fbf555093086c30e90f0e0d82cf7825 clonezilla-live-20131216-trusty-i386.iso 2482 | 2483 | 18fecad3e94be2026e1bb12b8c14eb76324a56a1 lupu-525.iso 2484 | 497f6b61f4265e7dadc961039167b7c2f97c97ee slacko-5.6-4G-NON-PAE.iso 2485 | EOF 2486 | 2487 | mr_trace "[DBG] file list: ${FN_TMP_LIST}" 2488 | if [ -f "${FN_TMP_LIST}" ]; then 2489 | process_file_list "" < "${FN_TMP_LIST}" 2490 | fi 2491 | 2492 | #rm -f "${FN_TMP_LIST}" 2493 | mr_trace "Done!" 2494 | mr_trace "Don't forget to add these lines to your DHCP server config file:" 2495 | mr_trace " next-server ${DIST_NFSIP};" 2496 | mr_trace ' filename "/pxelinux.0"'; 2497 | mr_trace "and restart your DHCP server!" 2498 | 2499 | 2500 | cat "${FN_TMP_LASTMSG}" | while read a; do mr_trace $a; done 2501 | if [ "${FLG_NON_PAE}" = "1" ]; then 2502 | if [ "${FLG_NON_PAE_PROCESSED}" = "0" ]; then 2503 | mr_trace "[ERR] Not process non-PAE option!" 2504 | fi 2505 | fi 2506 | 2507 | test_down_some_iso () { 2508 | down_url "http://ftp.halifax.rwth-aachen.de/backtrack/BT5R3-KDE-32.iso" 2509 | #down_url "http://ftp.halifax.rwth-aachen.de/backtrack/BT5R3-KDE-64.iso" 2510 | #down_url "http://ftp.halifax.rwth-aachen.de/backtrack/BT5R3-GNOME-32.iso" 2511 | #down_url "http://ftp.halifax.rwth-aachen.de/backtrack/BT5R3-GNOME-64.iso" 2512 | 2513 | #down_url "http://mirrors.kernel.org/archlinux/iso/2014.02.01/archlinux-2014.02.01-dual.iso" 2514 | #down_url "http://www.gtlib.gatech.edu/pub/archlinux/iso/2014.02.01/archlinux-2014.02.01-dual.iso" 2515 | 2516 | #down_url "http://archive.ubuntu.com/ubuntu/dists/quantal/main/installer-amd64/current/images/netboot/mini.iso" "ubuntu-mini-amd64-quantal.iso" 2517 | #down_url "http://mirror.anl.gov/pub/ubuntu/dists/quantal/main/installer-amd64/current/images/netboot/mini.iso" "ubuntu-mini-amd64-quantal.iso" 2518 | 2519 | #tftp_setup_pxe_iso "ftp://189.115.48.10/linux/bt4-final.iso" 2520 | #tftp_setup_pxe_iso "http://ftp.halifax.rwth-aachen.de/backtrack/BT5R3-KDE-32.iso" 2521 | #tftp_setup_pxe_iso "http://archive-5.kali.org/kali-images/kali-linux-1.0.4-i386.iso" 2522 | #tftp_setup_pxe_iso "http://archive-5.kali.org/kali-images/kali-linux-1.0.4-amd64.iso" 2523 | #tftp_setup_pxe_iso "http://cdimage.kali.org/kali-latest/amd64/kali-linux-1.0.6-amd64.iso" 2524 | 2525 | #tftp_setup_pxe_iso "http://ftp.ticklers.org/releases.ubuntu.org/releases/saucy/ubuntu-13.10-desktop-amd64.iso" 2526 | #tftp_setup_pxe_iso "http://us.releases.ubuntu.com/saucy/ubuntu-13.10-desktop-amd64.iso" 2527 | # http://www.archive.ubuntu.com/ubuntu/dists/precise/main/installer-i386/current/images/netboot/non-pae/mini.iso 2528 | #http://us.releases.ubuntu.com/raring/ubuntu-13.04-server-i386.iso 2529 | 2530 | #http://mirror.anl.gov/pub/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-LiveCD.iso 2531 | #http://mirror.anl.gov/pub/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-minimal.iso 2532 | #http://mirror.anl.gov/pub/centos/6.4/isos/x86_64/CentOS-6.4-x86_64-netinstall.iso 2533 | #http://sourceforge.net/projects/clonezilla/files/clonezilla_live_alternative_testing/20131216-trusty/clonezilla-live-20131216-trusty-i386.iso 2534 | #http://mirror.anl.gov/pub/centos/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso 2535 | } 2536 | 2537 | # remove temp files 2538 | $DO_EXEC rm -f ${FN_TMP_PREFIX}* 2539 | --------------------------------------------------------------------------------