diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/external-net.xml | 7 | ||||
-rw-r--r-- | util/isolinux.cfg | 120 | ||||
-rw-r--r-- | util/ks.cfg | 228 | ||||
-rw-r--r-- | util/libvirt.xml | 64 | ||||
-rwxr-xr-x | util/log.sh | 24 |
5 files changed, 443 insertions, 0 deletions
diff --git a/util/external-net.xml b/util/external-net.xml new file mode 100644 index 0000000..40c2336 --- /dev/null +++ b/util/external-net.xml @@ -0,0 +1,7 @@ + <network ipv6='no'> + <name>external</name> + <bridge name='br-external'/> + <forward mode='bridge'/> + <virtualport type='openvswitch'/> + </network> + diff --git a/util/isolinux.cfg b/util/isolinux.cfg new file mode 100644 index 0000000..f468818 --- /dev/null +++ b/util/isolinux.cfg @@ -0,0 +1,120 @@ +default vesamenu.c32 +timeout 1 + +display boot.msg + +# Clear the screen when exiting the menu, instead of leaving the menu displayed. +# For vesamenu, this means the graphical background is still displayed without +# the menu itself for as long as the screen remains in graphics mode. +menu clear +menu background splash.png +menu title CentOS 7 +menu vshift 8 +menu rows 18 +menu margin 8 +#menu hidden +menu helpmsgrow 15 +menu tabmsgrow 13 + +# Border Area +menu color border * #00000000 #00000000 none + +# Selected item +menu color sel 0 #ffffffff #00000000 none + +# Title bar +menu color title 0 #ff7ba3d0 #00000000 none + +# Press [Tab] message +menu color tabmsg 0 #ff3a6496 #00000000 none + +# Unselected menu item +menu color unsel 0 #84b8ffff #00000000 none + +# Selected hotkey +menu color hotsel 0 #84b8ffff #00000000 none + +# Unselected hotkey +menu color hotkey 0 #ffffffff #00000000 none + +# Help text +menu color help 0 #ffffffff #00000000 none + +# A scrollbar of some type? Not sure. +menu color scrollbar 0 #ffffffff #ff355594 none + +# Timeout msg +menu color timeout 0 #ffffffff #00000000 none +menu color timeout_msg 0 #ffffffff #00000000 none + +# Command prompt text +menu color cmdmark 0 #84b8ffff #00000000 none +menu color cmdline 0 #ffffffff #00000000 none + +# Do not display the actual menu unless the user presses a key. All that is displayed is a timeout message. + +menu tabmsg Press Tab for full configuration options on menu items. + +menu separator # insert an empty line +menu separator # insert an empty line + +label linux + menu label ^Install CentOS 7 + menu default + kernel vmlinuz + append ks=cdrom:/isolinux/ks.cfg initrd=initrd.img external_ip=REPLACE_EXTERNAL_IP external_netmask=REPLACE_EXTERNAL_NETMASK external_gw=REPLACE_EXTERNAL_GW dns1=8.8.8.8 + +label check + menu label Test this ^media & install CentOS 7 + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rd.live.check quiet + +menu separator # insert an empty line + +# utilities submenu +menu begin ^Troubleshooting + menu title Troubleshooting + +label vesa + menu indent count 5 + menu label Install CentOS 7 in ^basic graphics mode + text help + Try this option out if you're having trouble installing + CentOS 7. + endtext + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 xdriver=vesa nomodeset quiet + +label rescue + menu indent count 5 + menu label ^Rescue a CentOS system + text help + If the system will not boot, this lets you access files + and edit config files to try to get it booting again. + endtext + kernel vmlinuz + append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 rescue quiet + +label memtest + menu label Run a ^memory test + text help + If your system is having issues, a problem with your + system's memory may be the cause. Use this utility to + see if the memory is working correctly. + endtext + kernel memtest + +menu separator # insert an empty line + +label local + menu label Boot from ^local drive + localboot 0xffff + +menu separator # insert an empty line +menu separator # insert an empty line + +label returntomain + menu label Return to ^main menu + menu exit + +menu end diff --git a/util/ks.cfg b/util/ks.cfg new file mode 100644 index 0000000..8955e0c --- /dev/null +++ b/util/ks.cfg @@ -0,0 +1,228 @@ +############################################################################## +# Copyright (c) 2016-2017 HUAWEI TECHNOLOGIES CO.,LTD and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +#version=DEVEL +# System authorization information +auth --useshadow --enablemd5 +# Install OS instead of upgrade +install +# License agreement +eula --agreed +# Use text mode install +text +# Firewall configuration +firewall --disabled +firstboot --disable +# Keyboard layouts +# old format: keyboard us +# new format: +keyboard --vckeymap=us --xlayouts='us' +network --onboot no --device eth0 --bootproto dhcp --noipv6 +network --onboot no --device eth1 --bootproto dhcp --noipv6 +network --onboot no --device eth2 --bootproto dhcp --noipv6 +# System language +lang en_US.UTF-8 +# Installation logging level +logging --level=info +# Reboot after installation +reboot +# Root password +rootpw root +# SELinux configuration +selinux --disabled +# System services +services --enabled="NetworkManager,sshd" +# Do not configure the X Window System +skipx +# System timezone +timezone America/Los_Angeles --isUtc + +# System bootloader configuration +%include /tmp/bootloader.ks + +# Clear the Master Boot Record +zerombr +# Partition clearing information +clearpart --all --initlabel + +# Disk partitioning information +%include /tmp/partition.ks + +%pre +#!/bin/sh + +set -x -v +exec 1>/tmp/ks-pre.log 2>&1 +# Once root's homedir is there, copy over the log. +while : ; do + sleep 10 + if [ -d /mnt/sysimage/root ]; then + cp /tmp/ks-pre.log /mnt/sysimage/root/ + logger "Copied %pre section log to system" + break + fi +done & + +# hard drivedd +drives=(`ls -1 /sys/block | grep "sd\|hd\|vd\|cciss"`) +default_drive=${drives[0]} + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +tgtdrive=$default_drive +format_confirmed="no" + +if [ ${#drives[@]} -lt 1 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* There is no suitable media available for installation. *' + echo '* Please attach a drive and try again. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to shut down the system: " _ + poweroff +fi + +# verify tgtdrive is at least 30GB +tgtdrivesize=$(( $(cat "/sys/class/block/${tgtdrive}/size") / 2 / 1024 )) +if [ $tgtdrivesize -lt 30720 ]; then + exec < /dev/tty3 > /dev/tty3 2>&1 + chvt 3 + clear + echo + echo '********************************************************************' + echo '* E R R O R *' + echo '* *' + echo '* Your disk is under 30GB in size. Installation cannot continue. *' + echo '* Restart installation with a larger disk. *' + echo '* *' + echo '********************************************************************' + echo + read -p "Press Enter to restart: " _ + reboot +fi + +vgremove -ff os +dd if=/dev/zero of=/dev/${tgtdrive} bs=10M count=10 +sleep 3 + +hdparm -z /dev/${tgtdrive} +parted -s /dev/${tgtdrive} mklabel gpt +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 0 24 +parted -s /dev/${tgtdrive} set 1 bios_grub on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary fat16 24 224 +parted -s /dev/${tgtdrive} set 2 boot on +parted -a none -s /dev/${tgtdrive} unit MiB mkpart primary 224 424 +sleep 3 +hdparm -z /dev/${tgtdrive} + +# partition +cat << EOF > /tmp/partition.ks +part swap --asprimary --fstype="swap" --ondisk=sda --size=4096 +part /boot --asprimary --fstype="ext3" --ondisk=sda --size=500 +part pv.64 --fstype="lvmpv" --ondisk=sda --grow +volgroup os --pesize=4096 pv.64 +logvol /var --fstype="ext3" --grow --percent=40 --name=varvol --vgname=os +logvol /tmp --fstype="ext3" --grow --percent=5 --name=tmpvol --vgname=os +logvol / --fstype="ext3" --grow --percent=50 --name=rootvol --vgname=os +logvol /home --fstype="ext3" --grow --percent=5 --name=homevol --vgname=os +EOF + +# bootloader setting +echo "bootloader --location=mbr --driveorder=${tgtdrive} --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks +%end + +%post +echo -e "modprobe nf_conntrack_ipv4\nmodprobe nf_conntrack_ipv6\nmodprobe nf_conntrack_tftp\nmodprobe nf_nat_tftp" >> /etc/rc.modules +chmod +x /etc/rc.modules +echo -e "net.nf_conntrack_max=1048576" >> /etc/sysctl.conf +mkdir -p /var/log/coredump +echo -e "kernel.core_pattern=/var/log/coredump/core.%e.%p.%h.%t" >> /etc/sysctl.conf + +chmod 777 /var/log/coredump +echo -e "* soft core unlimited\n* hard core unlimited" >> /etc/security/limits.conf +%end + +%post --nochroot --log=/root/anaconda-post-before-chroot.log +#!/bin/sh +set -x +SOURCE="/mnt/sysimage/tmp/source" +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done + +mkdir -p "${SOURCE}" +mount -o bind "/mnt/install/source" "${SOURCE}" +%end + +%post --logfile /var/log/post_install.log +set -x -v +exec 1>/root/ks-post.log 2>&1 + +function save_nic_cfg() { + scrFile="/etc/sysconfig/network-scripts/ifcfg-$1" + sed -i -e 's#^\(HOSTNAME=\).*$#\1'"$hostname"'#' /etc/sysconfig/network + grep -q "^\s*$2\s+$hostname" /etc/hosts || echo "$2 $hostname" >> /etc/hosts + + echo DEVICE=$1> $scrFile + echo ONBOOT=yes >> $scrFile + echo NM_CONTROLLED=no >> $scrFile + echo HWADDR=$4 >> $scrFile + echo USERCTL=no >> $scrFile + echo PEERDNS=no >> $scrFile + echo BOOTPROTO=static >> $scrFile + echo IPADDR=$2 >> $scrFile + echo NETMASK=$3 >> $scrFile +} + +function save_gateway() { + echo GATEWAY=$external_gw >> /etc/sysconfig/network + search="domain $domain\nsearch $domain" + echo -e "${search}\nnameserver 127.0.0.1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/resolv.conf + [ $dns1 ] && echo -e "${search}\nnameserver $dns1" > /etc/dnsmasq.upstream + [ $dns2 ] && echo "nameserver $dns2" >> /etc/resolv.conf + [ $dns2 ] && echo "nameserver $dns2" >> /etc/dnsmasq.upstream + + if [[ -z "$dns1" && -z "$dns2" ]]; then + if [[ -z $external_gw ]]; then + echo "nameserver $gw" >> /etc/resolv.conf + else + echo "nameserver $external_gw" >> /etc/resolv.conf + fi + fi +} +# Default FQDN +hostname="open-o" + +for I in `cat /proc/cmdline`; do case "$I" in *=*) eval $I;; esac ; done +domain=$hostname + +external_ip=$external_ip +external_netmask=$external_mask +external_intf="eth0" +#external_hwaddr=`ifconfig $external_intf | grep -i hwaddr | sed -e 's#^.*hwaddr[[:space:]]*##I'` + +save_nic_cfg $external_intf $external_ip $external_netmask $external_hwaddr + +save_gateway + +SOURCE=/tmp/source +mkdir -p /root/.ssh +chmod 700 /root/.ssh +cat ${SOURCE}/bootstrap/boot.rsa.pub >> /root/.ssh/authorized_keys + +%end + +%packages --nobase +@core +%end diff --git a/util/libvirt.xml b/util/libvirt.xml new file mode 100644 index 0000000..e208223 --- /dev/null +++ b/util/libvirt.xml @@ -0,0 +1,64 @@ +<domain type='kvm'> + <name>open-o</name> + <memory unit='MiB'>REPLACE_MEM</memory> + <currentMemory unit='MiB'>REPLACE_MEM</currentMemory> + <vcpu placement='static'>REPLACE_CPU</vcpu> + <os> + <type arch='x86_64' machine='pc-i440fx-trusty'>hvm</type> + <boot dev='hd'/> + <boot dev='cdrom'/> + </os> + <features> + <acpi/> + <apic/> + <pae/> + </features> + <cpu mode='host-model'> + <model fallback='allow'/> + <feature policy='optional' name='vmx'/> + <feature policy='optional' name='svm'/> + </cpu> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <emulator>/usr/bin/kvm-spice</emulator> + <disk type='file' device='disk'> + <driver name='qemu' type='qcow2'/> + <source file='REPLACE_IMAGE'/> + <target dev='vda' bus='ide'/> + </disk> + <disk type='file' device='cdrom'> + <driver name='qemu' type='raw'/> + <source file='REPLACE_ISO'/> + <target dev='hdc' bus='ide'/> + <readonly/> + </disk> + <controller type='pci' index='0' model='pci-root'/> + <interface type='network'> + <source network='REPLACE_NET_EXTERNAL'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/> + </interface> + <interface type='network'> + <source network='default'/> + <model type='virtio'/> + <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/> + </interface> + <serial type='pty'> + <target port='0'/> + </serial> + <console type='pty'> + <target type='serial' port='0'/> + </console> + <input type='mouse' bus='ps2'/> + <input type='keyboard' bus='ps2'/> + <graphics type='vnc' port='-1' autoport='yes' listen='0.0.0.0' keymap='en-us'> + <listen type='address' address='0.0.0.0'/> + </graphics> + <video> + <model type='cirrus' vram='9216' heads='1'/> + </video> + </devices> +</domain> diff --git a/util/log.sh b/util/log.sh new file mode 100755 index 0000000..c19f563 --- /dev/null +++ b/util/log.sh @@ -0,0 +1,24 @@ +#!/bin/bash +############################################################################## +# Copyright (c) 2016-2017 HUAWEI TECHNOLOGIES CO.,LTD and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## +function log_info() { + echo -e "\033[32m$*\033[0m" +} + +function log_warn() { + echo -e "\033[33m$*\033[0m" +} + +function log_error() { + echo -e "\033[31m$*\033[0m" +} + +function log_progress() { + echo -en "\033[33m$*\r\033[0m" +} |