Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- make_kvm_virtual_machine_now_from_redhat_com ()
- {
- dependency::virtualization
- # Lookup specific binaries: use full path since they may just have been added and not in $PATH yet.
- : ${virt_net="$(system::find_vm_bridge)"}
- : "${BIN_VIRT_INSTALL:=$(type -p virt-install)}"
- : ${_os_version=$( $RTD_GUI --title "Select Release Version of RedHat" --inputbox "Please pick an available OS version by entering it below. \
- If you are not sure just let me choose for you... \n ${fedoralogo} " 25 110 "${_DEFAULT_REDHAT_VER}" 3>&1 1>&2 2>&3)}
- case $? in
- "$DIALOG_CANCEL") return ;;
- "$DIALOG_ESC") return ;;
- esac
- clear
- : ${_os_version:="${_DEFAULT_REDHAT_VER}"}
- : ${_mirrorlist_url="https://mirrors.almalinux.org/mirrorlist/${_os_version}/baseos"}
- : ${_source_url="https://repo.almalinux.org/almalinux/${_os_version}/BaseOS/x86_64/kickstart/"}
- : ${_preseed_file="$( mktemp ).cfg"}
- : ${_config="${1:-"workstation"}"}
- system::generate_ks_cfg_file -u "${_mirrorlist_url}" -c "${_config}" -p "${_preseed_file}" -e "@workstation-product-environment"
- _summary_message="The virtual machine (VDI_RedHat_"${_config}"_"${RANDOM}") \n
- 📋 - Using the instructions in PRESEED: ${_preseed_file} \n
- 🔧 - And Using this source for the packages and files to download: \n
- 🌎 - ${_source_url} \n
- 🌎 - ${_mirrorlist_url} \n
- ✅ - Using the network: ${virt_net:=default} \n
- ✅ - Memory: ${3:-2048} \n
- ✅ - CPU's: ${2:-2} \n
- ✅ - Disk Size: ${4:-40} \n You may attach to this server and see the progress at IP: $(hostname -I)"
- "${BIN_VIRT_INSTALL}" --connect qemu:///system --name VDI_RedHat_"${_config}"_"${RANDOM}" \
- --vcpus "${2:-2}" \
- --memory "${3:-2048}" \
- --network "$virt_net" \
- --disk size="${4:-40}" \
- --os-variant="fedora30" \
- --initrd-inject="${_preseed_file}" \
- --location="${_source_url}" \
- --extra-args "inst.ks=file:/$(basename $_preseed_file)" \
- --noautoconsole && dialog::display_summary_message "NOTICE!" \
- || ( read -p "💥 - An ERROR has occurred. Please press [ENTER] to continue..." && return 1 )
- for i in _preseed_file vm_kernel vm_initrd _source_url _config _mirrorlist_url _os_version ; do unset $i ; done
- }
- system::generate_ks_cfg_file ()
- {
- # Description: Function to generate an installation configuration file for Fedora/Red Hat.
- # Globals:
- # Arguments: [-p <filename> ] [-u URL ] [-c workstation|ssh-server|ansible-server ]
- # Outputs: One kick start configuration file.
- # Returns: 0/1
- # Usage: system::generate_ks_cfg_file [-p <filename> ] [-u URL ] [-c workstation|ssh-server|ansible-server ]
- # End of documentation
- echo "Function : ${FUNCNAME[0]}"
- echo "Called by: ${FUNCNAME[-1]}"
- local OPTIND o a
- while getopts ':u:c:p:e:' OPTION; do
- case "$OPTION" in
- u )
- local _repo_url="${OPTARG}"
- write_host --cyan "${FUNCNAME[0]}: Using URL: ${OPTARG}"
- ;;
- c )
- local _config="${OPTARG}"
- write_host --cyan "${FUNCNAME[0]}: Using Config for: ${OPTARG}"
- ;;
- p )
- local _ks_file="${OPTARG}"
- write_host --cyan "${FUNCNAME[0]}: Creating KS.CFG Instructions: ${_ks_file}"
- ;;
- e )
- local _wks_env="${OPTARG}"
- write_host --cyan "${FUNCNAME[0]}: Received optioinal option: ${_wks_env}"
- ;;
- ? )
- write_host --cyan "${FUNCNAME[0]}: Usage: $(FUNCNAME[0]) [-p <filename> ] [-u URL ] [-c workstation|ssh-server|ansible-server ]"
- return 1
- ;;
- esac
- done
- unset OPTIND
- [[ -v _repo_url && -v _config && -v _ks_file ]] || ( echo missing mandatory parameters! ; return 1 )
- case ${_config} in
- ssh-server )
- write_information "${FUNCNAME[0]}: Selected configuration is ssh-server..."
- cat >> "${_ks_file}" <<-KS_EOF
- # Generated by: system::generate_ks_cfg_file by RTD Power Tools
- # Choosing mode (graphical|text|cmdline [--non-interactive])
- text
- url --mirrorlist="${_repo_url}"
- firstboot --enable
- keyboard --vckeymap=us --xlayouts='us'
- lang en_US.UTF-8
- timezone Europe/London --isUtc --ntpservers=0.pool.ntp.org
- network --onboot=yes --bootproto=dhcp
- rootpw \$6\$Rn5/UTzjIs68MX\$9gz8vmshGlPqse3VoX8dzSfhWxRVoYv1MB6aGRD8xdvztOf.gD.SxxVWkxYrwwbShB9Q14flquK/apbdQJ65t1 --iscrypted
- user --groups=wheel --name=tangarora --password=\$6\$Rn5/UTzjIs68MX\$9gz8vmshGlPqse3VoX8dzSfhWxRVoYv1MB6aGRD8xdvztOf.gD.SxxVWkxYrwwbShB9Q14flquK/apbdQJ65t1 --iscrypted
- zerombr
- clearpart --all
- autopart --nohome
- reboot
- %packages --retries 5 --timeout 20
- openssh-server
- spice-vdagent
- git
- curl
- dialog
- %end
- KS_EOF
- return
- ;;
- ansible-server )
- write_information "${FUNCNAME[0]}: Selected configuration is ansible-server..."
- cat >> "${_ks_file}" <<-KS_EOF
- # Generated by: system::generate_ks_cfg_file by RTD Power Tools
- # Choosing mode (graphical|text|cmdline [--non-interactive])
- text
- url --mirrorlist="${_repo_url}"
- firstboot --enable
- keyboard --vckeymap=us --xlayouts='us'
- lang en_US.UTF-8
- timezone Europe/London --isUtc --ntpservers=0.pool.ntp.org
- network --onboot=yes --bootproto=dhcp --hostname=ansible.localdomain
- rootpw \$6\$Rn5/UTzjIs68MX\$9gz8vmshGlPqse3VoX8dzSfhWxRVoYv1MB6aGRD8xdvztOf.gD.SxxVWkxYrwwbShB9Q14flquK/apbdQJ65t1 --iscrypted
- user --groups=wheel --name=tangarora --password=\$6\$Rn5/UTzjIs68MX\$9gz8vmshGlPqse3VoX8dzSfhWxRVoYv1MB6aGRD8xdvztOf.gD.SxxVWkxYrwwbShB9Q14flquK/apbdQJ65t1 --iscrypted
- zerombr
- clearpart --all
- autopart --nohome
- reboot
- %packages --retries 5 --timeout 20
- openssh-server
- spice-vdagent
- git
- curl
- dialog
- ansible
- %end
- KS_EOF
- return
- ;;
- workstation )
- write_information "${FUNCNAME[0]}: Selected configuration is workstation..."
- cat >> "${_ks_file}" <<-KS_EOF
- # Generated by: system::generate_ks_cfg_file by RTD Power Tools
- # Choosing mode (graphical|text|cmdline [--non-interactive])
- graphical
- url --mirrorlist="${_repo_url}"
- firstboot --disable
- keyboard --xlayouts='se'
- lang en_US.UTF-8
- timezone Europe/London --isUtc --ntpservers=0.pool.ntp.org
- network --onboot=yes --bootproto=dhcp
- rootpw \$6\$Rn5/UTzjIs68MX\$9gz8vmshGlPqse3VoX8dzSfhWxRVoYv1MB6aGRD8xdvztOf.gD.SxxVWkxYrwwbShB9Q14flquK/apbdQJ65t1 --iscrypted
- user --groups=wheel --name=tangarora --password=\$6\$Rn5/UTzjIs68MX\$9gz8vmshGlPqse3VoX8dzSfhWxRVoYv1MB6aGRD8xdvztOf.gD.SxxVWkxYrwwbShB9Q14flquK/apbdQJ65t1 --iscrypted
- zerombr
- clearpart --all
- autopart --nohome --encrypted --passphrase letmein1234
- reboot
- %packages --retries 5 --timeout 20
- ${_wks_env}
- openssh-server
- spice-vdagent
- git
- curl
- dialog
- %end
- # Post-installation Script
- %post --interpreter=/bin/bash
- git clone https://github.com/vonschutter/RTD-Setup.git /opt/rtd
- chmod 755 /opt/rtd/core/rtd-oem-enable-config.sh
- bash /opt/rtd/core/rtd-oem-enable-config.sh
- %end
- KS_EOF
- return
- ;;
- * )
- write_information "${FUNCNAME[0]}: No valid OS configuration requested:
- Valid requests are: workstation, ssh-server, ansible-server
- skipping..."
- return 1
- ;;
- esac
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement