| 1 | #!/bin/bashscip-shell filesystem . . `/bin/bash`. |
| 2 | # Author: Steven Shiau <steven _at_ clonezilla org>, Ceasar Sun <ceasar _at_ nchc ogr tw> |
| 3 | # License: GPL |
| 4 | |
| 5 | # Load DRBL setting and functions |
| 6 | DRBL_SCRIPT_PATH="${DRBL_SCRIPT_PATH:-/usr/share/drbl}" |
| 7 | . $DRBL_SCRIPT_PATH/sbin/drbl-conf-functions |
| 8 | |
| 9 | # |
| 10 | USAGEscip-shell shell shell-project 0.0.0 USAGE().() { |
| 11 | echoscip-shell system . . echo. "Usage: $0 [OPTION]" |
| 12 | echoscip-shell system . . echo. "OPTION" |
| 13 | language_help_prompt_by_idx_no |
| 14 | echoscip-shell system . . echo. "-o, --console-output OPT: Set the console output parameters." |
| 15 | echoscip-shell system . . echo. "-i, --pxe-serial-output OPT: Set the PXE menu to work with serial console output." |
| 16 | echoscip-shell system . . echo. "-k, --client-kernel-pkg KERNEL_PKG: Specify the KERNEL_PKG (rpm or deb) which you want DRBL client to use." |
| 17 | echoscip-shell system . . echo. "-e, --extra-client-kernel-pkg EXTRA_KERNEL_PKG: Specify the extra KERNEL_PKG (rpm or deb) which you want DRBL client to use. Usually this is specially for Ubuntu linux-restricted-modules and SuSE kernel-default-nongpl. Must use this with option -k|--client-kernel-pkg." |
| 18 | echoscip-shell system . . echo. "-s, --client-kernel-ver-from-server KERNEL_VER: Use the kernel version KERNEL_VER from server, i.e. from /boot/vmlinuz-KERNEL_VER and /usr/lib/modules/KERNEL_VER..." |
| 19 | echoscip-shell system . . echo. "-c, --no-required-pkgs-check: Force NOT to check the required packages, assume they are installed." |
| 20 | echoscip-shell system . . echo. "-a, --no-prompt-different-arch-pkgs: Force NOT to show the messages about different architecture packages re-installation in the different CPU arch for server and client." |
| 21 | echoscip-shell system . . echo. "-p, --skip-client-kernel-install: Force NOT to install the kernel for client. This option is used when a kernel for client already exists." |
| 22 | echoscip-shell system . . echo. "-r, --only-show-required-pkgs: Do noting, just show the necessary packages." |
| 23 | echoscip-shell system . . echo. "-d, --dev-for-client-is-ready: Dev files are already ready for clients, do not let $0 check it again." |
| 24 | echoscip-shell system . . echo. "-v, --verbose: Prints verbose information" |
| 25 | } # end of USAGE |
| 26 | |
| 27 | check_debian_dev_for_clientscip-shell shell shell-project 0.0.0 check_debian_dev_for_client().() { |
| 28 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 29 | # dev for client machines |
| 30 | # For Debian woody & B2D pureKDE20050603..It's necessary to make one before run |
| 31 | # this... (Just create the tarball from some Debian machine) |
| 32 | # It's ugly here... |
| 33 | # The solution: Make udev as the 1st priority |
| 34 | [scip-shell system . . `[`. ! -d $drbl_pkgdir ] && mkdirscip-shell system . . mkdir. -p $drbl_pkgdir |
| 35 | |
| 36 | if ! chk_deb_installed udev; then |
| 37 | # udev is not available, use tarball |
| 38 | if [scip-shell system . . `[`. -f $drbl_setup_path/files/$OS_Version/dev.$OS_Version.tgz ]; then |
| 39 | echoscip-shell system . . echo. "Udev is not available, use pre-packaged device files." |
| 40 | cpscip-shell system . . cp. -f $drbl_setup_path/files/$OS_Version/dev.$OS_Version.tgz $drbl_pkgdir/dev.tgz |
| 41 | else |
| 42 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 43 | echoscip-shell system . . echo. "No udev, and no pre-packaged device files!!! Program terminated!" |
| 44 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 45 | exit 1 |
| 46 | fi |
| 47 | fi |
| 48 | } # end of check_debian_dev_for_client |
| 49 | |
| 50 | check_required_pkgsscip-shell shell shell-project 0.0.0 check_required_pkgs().() { |
| 51 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 52 | eval PKG_FROM_OS=\$PKG_FROM_${OS_type} |
| 53 | echoscip-shell system . . echo. "$msg_necessary_pkgs_from_dists" |
| 54 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 55 | echoscip-shell system . . echo. "$PKG_FROM_OS $PKG_DEV" |
| 56 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 57 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 58 | echoscip-shell system . . echo. "$msg_necessary_pkgs_from_drbl" |
| 59 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 60 | echoscip-shell system . . echo. "$PKG_FROM_DRBL" |
| 61 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 62 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 63 | echoscip-shell system . . echo. "$msg_recommended_pkgs_from_dists" |
| 64 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 65 | echoscip-shell system . . echo. "$PKG_TO_QUERY" |
| 66 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 67 | # if it's only show required packages, we exit here. |
| 68 | [scip-shell system . . `[`. "$only_show_required_pkgs" = "yes" ] && exit 0 |
| 69 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 70 | echoscip-shell system . . echo. -n "$msg_press_ctrl_c_stop Or $msg_press_enter_to_continue " |
| 71 | read |
| 72 | echoscip-shell system . . echo. "Check if they are installed... " |
| 73 | pkg_not_installed="" |
| 74 | ret=0 |
| 75 | for ipkg in $PKG_FROM_OS $PKG_FROM_DRBL $PKG_DEV; do |
| 76 | echoscip-shell system . . echo. -n "Checking $ipkg... " |
| 77 | if ! $query_pkglist_exist_cmd $ipkg &>/dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 78 | pkg_not_installed="$pkg_not_installed $ipkg" |
| 79 | ret=$((ret + 1)) |
| 80 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 81 | echoscip-shell system . . echo. "NOT installed!" |
| 82 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 83 | else |
| 84 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_SUCCESS |
| 85 | echoscip-shell system . . echo. "installed." |
| 86 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 87 | fi |
| 88 | done |
| 89 | if [scip-shell system . . `[`. "$ret" -gt 0 ]; then |
| 90 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 91 | echoscip-shell system . . echo. "$msg_some_required_pkgs_not_installed: $pkg_not_installed." |
| 92 | echoscip-shell system . . echo. "$msg_use_drblsrv_instead" |
| 93 | echoscip-shell system . . echo. "$msg_continue_may_not_work" |
| 94 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 95 | echoscip-shell system . . echo. "$msg_are_u_sure_u_want_to_continue" |
| 96 | echoscip-shell system . . echo. -n "[y/N] " |
| 97 | read continue_run_ans |
| 98 | case "$continue_run_ans" in |
| 99 | y|Y|[yY][eE][sS]) |
| 100 | echoscip-shell system . . echo. "$msg_ok_let_do_it" |
| 101 | ;; |
| 102 | *) |
| 103 | echoscip-shell system . . echo. "$msg_program_stop" |
| 104 | exit 1 |
| 105 | ;; |
| 106 | esac |
| 107 | fi |
| 108 | } # end of check_required_pkgs |
| 109 | # |
| 110 | check_installed_pkgs_archscip-shell shell shell-project 0.0.0 check_installed_pkgs_arch().() { |
| 111 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 112 | case "$OS_type" in |
| 113 | RH) |
| 114 | echoscip-shell system . . echo. -n "Checking the installed packages of different arch..." |
| 115 | reinstall_pkg="" |
| 116 | for ipkg in $i686_pkg_check_list_RH_like; do |
| 117 | if rpm -q $ipkg &>/dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 118 | echoscip-shell system . . echo. -n "." |
| 119 | installed_pkg="$(rpm -qa | grepscip-shell system . . grep. -E "^${ipkg}-[0-9]" | pkg-ver-latest)" |
| 120 | reinstall_pkg="$reinstall_pkg $installed_pkg.i386.rpm" |
| 121 | fi |
| 122 | done |
| 123 | echoscip-shell system . . echo. " done!" |
| 124 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 125 | echoscip-shell system . . echo. "$msg_install_glibc_etc_arch_by_yourself" |
| 126 | echoscip-shell system . . echo. "rpm -Uvh --force $reinstall_pkg" |
| 127 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 128 | echoscip-shell system . . echo. -n "$msg_press_ctrl_c_stop Or $msg_press_enter_to_continue" |
| 129 | read |
| 130 | ;; |
| 131 | SUSE) |
| 132 | echoscip-shell system . . echo. -n "Checking the installed packages of different arch..." |
| 133 | reinstall_pkg="" |
| 134 | for ipkg in $i686_pkg_check_list_SUSE; do |
| 135 | if rpm -q $ipkg &>/dev/nullscip-shell filesystem . . `/dev/null`.; then |
| 136 | echoscip-shell system . . echo. -n "." |
| 137 | installed_pkg=`rpm -qa | grepscip-shell system . . grep. ^${ipkg}-[0-9]` |
| 138 | reinstall_pkg="$reinstall_pkg $installed_pkg.i586.rpm" |
| 139 | fi |
| 140 | done |
| 141 | echoscip-shell system . . echo. " done!" |
| 142 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 143 | echoscip-shell system . . echo. "$msg_install_glibc_etc_arch_by_yourself" |
| 144 | echoscip-shell system . . echo. "rpm -Uvh --force $reinstall_pkg" |
| 145 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 146 | echoscip-shell system . . echo. -n "$msg_press_ctrl_c_stop Or $msg_press_enter_to_continue" |
| 147 | read |
| 148 | ;; |
| 149 | MDK|MDV|DBN) |
| 150 | # Not necessary, since only single arch package in this distribution |
| 151 | truescip-shell system . . true. |
| 152 | ;; |
| 153 | esac |
| 154 | } # end of check_installed_pkgs_arch |
| 155 | # |
| 156 | install_kernel_for_client_funcscip-shell shell shell-project 0.0.0 install_kernel_for_client_func().() { |
| 157 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 158 | echoscip-shell system . . echo. "$msg_install_kernel_for_clients ... " |
| 159 | case "$client_krn_mode" in |
| 160 | "from_pkg") |
| 161 | echoscip-shell system . . echo. "The kernel for client is from specific package $client_kernel_pkg." |
| 162 | install-kernel-for-client $verbose_opt -l $lang -k $client_kernel_pkg |
| 163 | rc=$? |
| 164 | # We install the extra kernel package (linux-restricted-modules and linux-ubuntu-modules (from ubuntu 7.10) ) after the main kernel since if depmod is later, we will see some warning like: |
| 165 | # WARNING: /usr/lib/modules/2.6.17-10-386/madwifi/ath_rate_sample.ko needs unknown symbol ath_hal_computetxtime |
| 166 | # Ubuntu restricted kernel is mounted in /usr/lib/modules/$KVER/volatile/ when booting (/etc/init.d/linux-restricted-modules-common), and depmod will be run by /sbin/lrm-manager about the mounting. |
| 167 | # From ubuntu 7.10, another kernel module is linux-ubuntu-modules. |
| 168 | if [scip-shell system . . `[`. -n "$extra_client_kernel_pkg" ]; then |
| 169 | for i in $extra_client_kernel_pkg; do |
| 170 | # FC 22 or later use kernel[-PAE]*-modules-*.rpm for extra modules |
| 171 | if [scip-shell system . . `[`. -n "$(LC_ALL=C echoscip-shell system . . echo. $i | grepscip-shell system . . grep. -E 'linux-restricted-modules|kernel[-PAE]*-modules' )" ]; then |
| 172 | install_extra_opt="--just-cp-files" |
| 173 | else |
| 174 | install_extra_opt="" |
| 175 | fi |
| 176 | install-kernel-for-client $verbose_opt -l $lang $install_extra_opt -k $i |
| 177 | done |
| 178 | fi |
| 179 | ;; |
| 180 | "from_server") |
| 181 | echoscip-shell system . . echo. "The kernel for client is copied from server." |
| 182 | install-kernel-for-client $verbose_opt -l $lang -s $client_kernel_ver_from_server |
| 183 | rc=$? |
| 184 | ;; |
| 185 | esac |
| 186 | # check if kernel installed successfully |
| 187 | if [scip-shell system . . `[`. "$rc" -gt 0 ]; then |
| 188 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 189 | echoscip-shell system . . echo. "Failed to install the kernel for client!" |
| 190 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 191 | echoscip-shell system . . echo. "$msg_program_stop" |
| 192 | exit 1 |
| 193 | fi |
| 194 | } # end of install_kernel_for_client_func |
| 195 | # |
| 196 | check_input_kernel_paramscip-shell shell shell-project 0.0.0 check_input_kernel_param().() { |
| 197 | if [scip-shell system . . `[`. -n "$client_kernel_pkg" ]; then |
| 198 | # check if the kernel package exists |
| 199 | if [scip-shell system . . `[`. ! -f "$client_kernel_pkg" ]; then |
| 200 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 201 | echoscip-shell system . . echo. "$client_kernel_pkg does NOT exist!!!" |
| 202 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 203 | echoscip-shell system . . echo. "$msg_program_stop" |
| 204 | exit 1 |
| 205 | fi |
| 206 | client_krn_mode="from_pkg" |
| 207 | echoscip-shell system . . echo. "Kernel package $client_kernel_pkg is used for client..." |
| 208 | elif [scip-shell system . . `[`. -n "$client_kernel_ver_from_server" -a \ |
| 209 | -f /boot/vmlinuz-$client_kernel_ver_from_server -a \ |
| 210 | -d /usr/lib/modules/$client_kernel_ver_from_server ]; then |
| 211 | client_krn_mode="from_server" |
| 212 | echoscip-shell system . . echo. "Using kernel from this server for client..." |
| 213 | else |
| 214 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 215 | echoscip-shell system . . echo. "You must provide the kernel package (rpm or deb) or the kernel in the server" |
| 216 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 217 | USAGEscip-shell shell shell-project 0.0.0 USAGE(). |
| 218 | exit 1 |
| 219 | fi |
| 220 | # 1. $PKG_FROM_* and $PKG_FROM_DRBL are loaded from conf/drbl.conf |
| 221 | # TODO: how about kernel 2.4 ? no udev ? how to prompt them ? |
| 222 | # If the kernel is version 2.6 for client, we must use udev. |
| 223 | # For package name, like: linux-image-2.6.15-26-686_2.6.15-26.46_i386.deb |
| 224 | # FC5: kernel-2.6.17-1.2174_FC5.i686.rpm |
| 225 | # RH9: kernel#2.4.20-46.9.legacy_2.4.20-46.9.legacy_i586.rpm |
| 226 | # For kernel version like: 2.6.15-26-386 |
| 227 | if [scip-shell system . . `[`. -n "$(echoscip-shell system . . echo. $client_kernel_pkg | grepscip-shell system . . grep. -iE "[_-][[:digit:]]+\.[[:digit:]]+")" -o \ |
| 228 | -n "$(echoscip-shell system . . echo. $client_kernel_ver_from_server | grepscip-shell system . . grep. -iE "^[[:digit:]]+\.[[:digit:]]+")" ]; then |
| 229 | PKG_DEV="udev" |
| 230 | else |
| 231 | if [scip-shell system . . `[`. "$dev_for_client_is_ready" = "no" ]; then |
| 232 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_FAILURE |
| 233 | echoscip-shell system . . echo. "This script `basenamescip-shell system . . basename. $0` only works in kernel 2.6 or 3 or later with udev supported! The running kernel for client is not kernel 2.6 or 3 or later! Program terminated!" |
| 234 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 235 | exit 1 |
| 236 | fi |
| 237 | fi |
| 238 | } # end of check_input_kernel_param |
| 239 | |
| 240 | |
| 241 | ################# |
| 242 | #### Main #### |
| 243 | ################# |
| 244 | # some default settings |
| 245 | required_pkgs_check="yes" |
| 246 | prompt_different_arch_pkgs="yes" |
| 247 | install_client_kernel="yes" |
| 248 | only_show_required_pkgs="no" |
| 249 | dev_for_client_is_ready="no" |
| 250 | extra_client_kernel_pkg="" |
| 251 | |
| 252 | # Parse command-line options |
| 253 | while [scip-shell system . . `[`. $# -gt 0 ]; do |
| 254 | case "$1" in |
| 255 | -l|--language) |
| 256 | shift |
| 257 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 258 | # skip the -xx option, in case |
| 259 | specified_lang="$1" |
| 260 | shift |
| 261 | fi |
| 262 | [scip-shell system . . `[`. -z "$specified_lang" ] && USAGEscip-shell shell shell-project 0.0.0 USAGE(). && exit 1 |
| 263 | ;; |
| 264 | -k|--client-kernel-pkg) |
| 265 | shift |
| 266 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 267 | # skip the -xx option, in case |
| 268 | client_kernel_pkg="$1" |
| 269 | shift |
| 270 | fi |
| 271 | [scip-shell system . . `[`. -z "$client_kernel_pkg" ] && USAGEscip-shell shell shell-project 0.0.0 USAGE(). && exit 1 |
| 272 | ;; |
| 273 | -e|--extra-client-kernel-pkg) |
| 274 | shift |
| 275 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 276 | # skip the -xx option, in case |
| 277 | extra_client_kernel_pkg="$extra_client_kernel_pkg $1" |
| 278 | shift |
| 279 | fi |
| 280 | [scip-shell system . . `[`. -z "$extra_client_kernel_pkg" ] && USAGEscip-shell shell shell-project 0.0.0 USAGE(). && exit 1 |
| 281 | ;; |
| 282 | -s|--client-kernel-ver-from-server) |
| 283 | shift |
| 284 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 285 | # skip the -xx option, in case |
| 286 | client_kernel_ver_from_server="$1" |
| 287 | shift |
| 288 | fi |
| 289 | [scip-shell system . . `[`. -z "$client_kernel_ver_from_server" ] && USAGEscip-shell shell shell-project 0.0.0 USAGE(). && exit 1 |
| 290 | ;; |
| 291 | -o|--console-output) |
| 292 | shift |
| 293 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 294 | # skip the -xx option, in case |
| 295 | CONSOLE_OUTPUT="$1" |
| 296 | shift |
| 297 | fi |
| 298 | [scip-shell system . . `[`. -z "$CONSOLE_OUTPUT" ] && USAGEscip-shell shell shell-project 0.0.0 USAGE(). && exit 1 |
| 299 | ;; |
| 300 | -i|--pxe-serial-output) |
| 301 | shift |
| 302 | if [scip-shell system . . `[`. -z "$(echoscip-shell system . . echo. $1 |grepscip-shell system . . grep. ^-.)" ]; then |
| 303 | # skip the -xx option, in case |
| 304 | PXE_SERIAL_OUTPUT="$1" |
| 305 | shift |
| 306 | fi |
| 307 | [scip-shell system . . `[`. -z "$PXE_SERIAL_OUTPUT" ] && USAGEscip-shell shell shell-project 0.0.0 USAGE(). && exit 1 |
| 308 | ;; |
| 309 | -c|--no-required-pkgs-check) |
| 310 | required_pkgs_check="no" |
| 311 | shift;; |
| 312 | -a|--no-prompt-different-arch-pkgs) |
| 313 | prompt_different_arch_pkgs="no" |
| 314 | shift;; |
| 315 | -p|--skip-client-kernel-install) |
| 316 | install_client_kernel="no" |
| 317 | shift;; |
| 318 | -r|--only-show-required-pkgs) |
| 319 | only_show_required_pkgs="yes" |
| 320 | shift;; |
| 321 | -d|--dev-for-client-is-ready) |
| 322 | dev_for_client_is_ready="yes" |
| 323 | shift;; |
| 324 | -v|--verbose) |
| 325 | verbose="on" |
| 326 | verbose_opt="-v" |
| 327 | shift ;; |
| 328 | -*) echoscip-shell system . . echo. "${0}: ${1}: invalid option" >&2 |
| 329 | USAGEscip-shell shell shell-project 0.0.0 USAGE(). >& 2 |
| 330 | exit 2 ;; |
| 331 | *) break ;; |
| 332 | esac |
| 333 | done |
| 334 | |
| 335 | # |
| 336 | check_if_root |
| 337 | |
| 338 | # |
| 339 | ask_and_load_lang_set $specified_lang |
| 340 | |
| 341 | # |
| 342 | if [scip-shell system . . `[`. "$install_client_kernel" = "yes" -a \ |
| 343 | "$only_show_required_pkgs" = "no" ]; then |
| 344 | check_input_kernel_paramscip-shell shell shell-project 0.0.0 check_input_kernel_param(). |
| 345 | fi |
| 346 | |
| 347 | # get the distribution name and type: OS_Version and OS_type |
| 348 | check_distribution_name |
| 349 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 350 | echoscip-shell system . . echo. "$msg_OS_version: $FULL_OS_Version" |
| 351 | |
| 352 | |
| 353 | # 0. |
| 354 | if [scip-shell system . . `[`. "$required_pkgs_check" = "yes" ]; then |
| 355 | check_required_pkgsscip-shell shell shell-project 0.0.0 check_required_pkgs(). |
| 356 | fi |
| 357 | |
| 358 | # 1. |
| 359 | if [scip-shell system . . `[`. "$prompt_different_arch_pkgs" = "yes" ]; then |
| 360 | check_installed_pkgs_archscip-shell shell shell-project 0.0.0 check_installed_pkgs_arch(). |
| 361 | fi |
| 362 | |
| 363 | # 2021/9/27. Comment this since all the packages are installed by users. If not, then drblsrv should have taken care of that. Hence there is no need to run drbl-deb-preconf actually. |
| 364 | # # 2. Prepare some config to avoid some delay when installing packages. If user already install them, we will overwrite those setting when running drblpush. |
| 365 | # if [ "$OS_type" = "DBN" ]; then |
| 366 | # # We need to preconfig some packages, such as dhcp3-server, tftpd-hpa, nis so |
| 367 | # # it will not ask user to config. We will configure later in drblpush. |
| 368 | # drbl-deb-preconf |
| 369 | # fi |
| 370 | |
| 371 | # 3. |
| 372 | [scip-shell system . . `[`. ! -d $pxecfg_pd ] && mkdirscip-shell system . . mkdir. -p $pxecfg_pd |
| 373 | [scip-shell system . . `[`. ! -d $drbl_common_root ] && mkdirscip-shell system . . mkdir. -p $drbl_common_root |
| 374 | [scip-shell system . . `[`. ! -d $drblroot ] && mkdirscip-shell system . . mkdir. -p -m 700 $drblroot |
| 375 | [scip-shell system . . `[`. ! -d $drbl_pkgdir ] && mkdirscip-shell system . . mkdir. -p $drbl_pkgdir |
| 376 | |
| 377 | # do some tunning. |
| 378 | if [scip-shell system . . `[`. "$OS_type" = "DBN" ]; then |
| 379 | check_debian_dev_for_clientscip-shell shell shell-project 0.0.0 check_debian_dev_for_client(). |
| 380 | fi |
| 381 | |
| 382 | # 4. |
| 383 | if [scip-shell system . . `[`. "$install_client_kernel" = "yes" ]; then |
| 384 | install_kernel_for_client_funcscip-shell shell shell-project 0.0.0 install_kernel_for_client_func(). |
| 385 | else |
| 386 | # the kernel for clients existed |
| 387 | client_krn_mode="existed" |
| 388 | echoscip-shell system . . echo. "[-p|--skip-client-kernel-install] is assigned, assume the kernel for client already existed! Skip installing kernel for client!" |
| 389 | fi |
| 390 | |
| 391 | # 5. |
| 392 | # Before running this function, we first check if memtest86+ and pxelinux exist in the drbl package repository ($memtest86_dir and $pxelinux_file) |
| 393 | if [scip-shell system . . `[`. -z "$(lsscip-shell system . . ls. -l $memtest86_dir/mt86+x* 2>/dev/nullscip-shell filesystem . . `/dev/null`.)" ]; then |
| 394 | drbl-prepare-memtest |
| 395 | fi |
| 396 | # Here we check both pxelinux.0, gpxelinux.0 and lpxelinux.0. Since if older version of syslinux is installed (e.g. 3.7 in CentOS 5), no gpxelinux.0. However, if the user upgrade syslinux as 4.x after drblsrv-offline is run, drbl-prepare-pxelinux won't be run if not checking gpxelinux.0. |
| 397 | if [scip-shell system . . `[`. ! -e "$pxelinux_file" -o ! -e "$gpxelinux_file" -o ! -e "$lpxelinux_file" ]; then |
| 398 | drbl-prepare-pxelinux |
| 399 | fi |
| 400 | |
| 401 | # 6. |
| 402 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 403 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_WARNING |
| 404 | echoscip-shell system . . echo. "$msg_create_files_for_PXELINUX" |
| 405 | [scip-shell system . . `[`. "$BOOTUP" = "color" ] && $SETCOLOR_NORMAL |
| 406 | if [scip-shell system . . `[`. -n "$CONSOLE_OUTPUT" ]; then |
| 407 | console_opt1="--console-output" |
| 408 | console_opt2="$CONSOLE_OUTPUT" |
| 409 | fi |
| 410 | if [scip-shell system . . `[`. -n "$PXE_SERIAL_OUTPUT" ]; then |
| 411 | pxe_serial_opt1="--pxe-serial-output" |
| 412 | pxe_serial_opt2="$PXE_SERIAL_OUTPUT" |
| 413 | fi |
| 414 | prepare-files-for-PXE-client -l $lang $console_opt1 "$console_opt2" $pxe_serial_opt1 "$pxe_serial_opt2" |
| 415 | |
| 416 | # 7. |
| 417 | # make the nbi/pxe files |
| 418 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 419 | case "$client_krn_mode" in |
| 420 | "from_pkg") |
| 421 | if [scip-shell system . . `[`. -n "$(filescip-shell system . . file. $client_kernel_pkg | grepscip-shell system . . grep. -i RPM)" ]; then |
| 422 | client_kernel_ver="$(rpm -qpl $client_kernel_pkg | grepscip-shell system . . grep. -E "^/boot/vmlinuz-" | sedscip-shell system . . sed. -e "s|/boot/vmlinuz-||g")" |
| 423 | if [scip-shell system . . `[`. -z "$client_kernel_ver" ]; then |
| 424 | # For OpenSuSE 11.1, kernel-default or kernel-pae, there is no vmlinuz-* file, try another method, i.e. use the path: |
| 425 | # /usr/lib/modules/2.6.27.7-9-default/... |
| 426 | client_kernel_ver="$(rpm -qpl $client_kernel_pkg | awkscip-shell system . . awk. -F" " '{print $NF}' | awkscip-shell system . . awk. -F"/" '/\/usr\/lib\/modules/ {print $4}scip-shell filesystem . . `/\/usr\/lib\/modules/ {print $4}`.' | sortscip-shell system . . sort. | uniqscip-shell system . . uniq.)" |
| 427 | fi |
| 428 | elif [scip-shell system . . `[`. -n "$(filescip-shell system . . file. $client_kernel_pkg | grepscip-shell system . . grep. -i "Debian binary package")" ]; then |
| 429 | client_kernel_ver="$(dpkgscip-shell system . . dpkg. --contents $client_kernel_pkg | awkscip-shell system . . awk. -F" " '{print $NF}' | grepscip-shell system . . grep. -E "./boot/vmlinuz-" | sedscip-shell system . . sed. -e "s|\./boot/vmlinuz-||g")" |
| 430 | if [scip-shell system . . `[`. -z "$client_kernel_ver" ]; then |
| 431 | # For deb linux-modules-*, there is no vmlinuz-* file, try another method, i.e. from dpkg-deb -f: |
| 432 | client_kernel_ver="$(dpkg-debscip-shell system . . dpkg-deb. -f $client_kernel_pkg Package | sedscip-shell system . . sed. 's/^linux-modules-//')" |
| 433 | fi |
| 434 | fi |
| 435 | drbl-gen-pxe-nbi -l $lang -k $client_kernel_ver |
| 436 | # |
| 437 | if [scip-shell system . . `[`. -x /etc/init.d/linux-restricted-modules-commonscip-shell filesystem . . `/etc/init.d/linux-restricted-modules-common`. ]; then |
| 438 | # Create mount point $drbl_common_root/usr/lib/modules/$KERNEL_VER/volatile so that in Ubuntu with linux-restricted-modules, linux-restricted-modules-common service (which we will modify in drblpush so that it will use tmpfs otherwise it is Read-Only NFS filesystem) will need this. |
| 439 | mkdirscip-shell system . . mkdir. -p $drbl_common_root/usr/lib/modules/$client_kernel_ver/volatile |
| 440 | fi |
| 441 | ;; |
| 442 | "from_server") |
| 443 | drbl-gen-pxe-nbi -l $lang -k $client_kernel_ver_from_server |
| 444 | ;; |
| 445 | "existed") |
| 446 | # not from server, not from pkg, kernel must already exists for client |
| 447 | drbl-gen-pxe-nbi -l $lang |
| 448 | ;; |
| 449 | esac |
| 450 | |
| 451 | echoscip-shell system . . echo. "$msg_delimiter_star_line" |
| 452 | echoscip-shell system . . echo. "$msg_Done!" |