Pidora-2014-kickStart

From CDOT Wiki
Revision as of 13:45, 13 August 2014 by Agreene (talk | contribs) (Pidora Kickstart)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Pidora-horizontal.png

Pidora Kickstart

# Build a Raspberry Pi - XFCE install using livemedia-creator

# Note this image will only boot if you reformat the boot partition to vfat
# you can manually reformat the boot partition after image creation or use the script provided below
#
# Reformat boot partition script:
# http://scotland.proximity.on.ca/raspberrypi/test-releases/rpfr18v6/latest/revfat  
 
lang en_US.UTF-8
keyboard us
timezone --utc US/Eastern
auth --useshadow --enablemd5
selinux --disabled
firewall --enabled --service=mdns,ssh
network --bootproto=dhcp --device=eth0 --onboot=on --activate --hostname=pidora.local
services --enabled=NetworkManager,sshd,ntpd --disabled=network

# Only use this with Anaconda for serial console installs, not with livemedia-creator.
# Use this for serial console-only installs
#skipx

# Set a default root password for Rasbberry Pi
rootpw --plaintext raspberrypi

# Repositories
# apparently we must use 'url' for the install repo for livemedia-creator
 
url --url="http://japan.proximity.on.ca/kojifiles/repos/f20-build/latest/armv6hl/"

repo --name=pidora --ignoregroups=true --baseurl="http://japan.proximity.on.ca/kojifiles/mash20/pidora-20-latest/pidora-20-updates/armhfp/"
#repo --name=pidora-updates --baseurl="http://japan.proximity.on.ca/repos/f20-updates-build/latest/armv6hl/"

repo --name=pidora-rpfr  --baseurl="http://japan.proximity.on.ca/kojifiles/mash20/pidora-20-latest/pidora-20-rpfr-updates/armhfp/"

#
# Define how large you want your rootfs to be
#

bootloader --location=boot
zerombr
clearpart --all
## Need to create logical volume groups first then partition

part /boot --size 50 --fstype ext4 --label=boot --asprimary
part swap --size 255 --label=swap
part / --size 3000 --fstype ext4 --label=rootfs --asprimary
#
# Add all the packages after the base packages
#
%packages --ignoremissing
%include packagelist.ks
%end

# more configuration
%post --log=ks-log-info.txt

echo "##### $(date) - Post-installation file configuration"

#mkdir -p /mnt/sysimage/boot/grub2/

# /etc/fstab
cat << EOF > /etc/fstab
LABEL="rootfs"          /                       ext4    defaults,noatime                 1 1
LABEL="BOOT"            /boot                   vfat    defaults			 1 2
EOF

# /etc/hosts
cat << EOF > ${fsdir}/etc/hosts
127.0.0.1       localhost localhost.localdomain pidora.local
EOF

# root password
sed -i 's|^root:.*|root:x:0:0:root:/root:/bin/bash|' /etc/passwd
sed -i 's|^SELINUX=enforcing|SELINUX=permissive|'    /etc/selinux/config

# hostname
cat << EOF > /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=pidora.local
NETWORKWAIT=1
EOF

# should be blacklisted, floods dmesg with logs
# /etc/modprobe.d/blacklist.conf
cat << EOF > /etc/modprobe.d/blacklist.conf
blacklist evbug
EOF

# create a releasever var
cat << EOF > /etc/yum/vars/releasever
20
EOF

#swapiness settings 
cat << EOF > /etc/sysctl.conf
vm.swappiness=1
EOF

# Boot optimizations
cat << EOF > /tmp/optimize-systemd

#!/bin/bash
echo "Optimizing systemd within chroot."
#fedora-storage-init-late.service fedora-storage-init.service plymouth-halt.service plymouth-kexec.service plymouth-poweroff.service plymouth-quit.service plymouth-quit-wait.service plymouth-read-write.service plymouth-reboot.service plymouth-start.service mdmonitor.service mdmonitor-takeover.service auditd.service avahi-daemon.service avahi-daemon.socket bluetooth.target dev-hugepages.mount dev-mqueue.mount fedora-configure.service fedora-loadmodules.service fedora-readonly.service ip6tables.service sys-kernel-config.mount sys-kernel-debug.mount systemd-readahead-collect.service systemd-readahead-done.service systemd-readahead-done.timer systemd-readahead-replay.service
EOF
chmod 0755 /tmp/optimize-systemd

for i in gdm.service iprupdate.service iprdump.service iprinit.service firewalld.service auditd.service sendmail.service sm-client.service dmraid-activation.service bluetooth.service fedora-readonly.service sys-kerenl-debug.mount rtkit-daemon.service kmod-static-nodes.service
do
    systemctl disable $i
    systemctl mask $i
done

#modules loaded
for i in nf_conntrack_netbios_ns nf_conntrack_broadcast ipt_MASQUERADE ip6table_mangle bnep bluetooth rfkill ip6t_REJECT nf_conntrack_ipv6 nf_defrag_ipv6 iptable_nat nf_nat iptable_mangle nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack ebtable_filter ebtables ip6table_filter ip6_tables nls_ascii  autofs4
do  
	modprobe $i
done

# gtk icon theme 
mkdir -p /etc/gtk-3.0/
cat << EOF > /etc/gtk-3.0/settings.ini
[Settings]
gtk-icon-theme-name=gnome
EOF

# Headless service file fix
cat << EOF > /usr/lib/systemd/system/headless-mode.service
[Unit]
Description=Checking the status of headless mode
After=sound.target network.target
Before=firstboot-graphical.service 

[Service]
Type=simple
ExecStart=/usr/bin/headon
Restart=on-failure

[Install]
WantedBy=multi-user.target
EOF

# Pidora 2014 Mock config file
cat << EOF > /etc/mock/pidora-20-armv6hl.cfg
# Auto-generated by the Koji build system
config_opts['root'] = 'pidora-19-armv6hl'
config_opts['chroothome'] = '/builddir'
config_opts['use_host_resolv'] = False
config_opts['basedir'] = '/var/lib/mock'
config_opts['rpmbuild_timeout'] = 86400
config_opts['yum.conf'] = '[main]\ncachedir=/var/cache/yum\ndebuglevel=1\nlogfile=/var/log/yum.log\nreposdir=/dev/null\nretries=20\nobsoletes=1\ngpgcheck=0\nassumeyes=1\n\n# repos\n\n[build]\nname=build\nbaseurl=http://koji.pidora.ca//repos/f20-build/30395/armv6hl\n'
config_opts['chroot_setup_cmd'] = 'groupinstall build'
config_opts['target_arch'] = 'armv6hl'
config_opts['root'] = 'f20'

config_opts['plugin_conf']['root_cache_enable'] = False
config_opts['plugin_conf']['yum_cache_enable'] = False
config_opts['plugin_conf']['ccache_enable'] = False

config_opts['macros']['%_host'] = 'armv6hl-koji-linux-gnu'
config_opts['macros']['%_host_cpu'] = 'armv6hl'
config_opts['macros']['%vendor'] = 'Koji'
config_opts['macros']['%distribution'] = 'Koji Testing'
config_opts['macros']['%_topdir'] = '/builddir/build'
config_opts['macros']['%_rpmfilename'] = '%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'
config_opts['macros']['%packager'] = 'Koji'
EOF

# Enable needed services
for i in nortc.service lightdm.service firstboot-graphical.service polkit.service headless-mode.service
do
    systemctl enable $i
done

# Missing symlink for sendmail.pid 
ln -s /var/run /run

# run ld config for raspberrypi-vc-libs
ldconfig

# set graphical target
ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

echo "##### $(date) - Final configurations"

# Firstboot timezone bug fix
sed -i "s|self.priority = 99|self.priority = 98|" /usr/share/firstboot/modules/date.py

# Firstboot reboot fix
echo '        os.system("/sbin/reboot")' >> /usr/sbin/firstboot

# Use this if you would like to quiet mode off for testing purposes 
#sed -i "s|quiet||" /boot/cmdline.txt

# selinux disabled (memory requirements)
sed -i "s|SELINUX=.*|SELINUX=disabled|" /etc/selinux/config

for X in passwd shadow group gshadow
do
    echo "==================================== $X"
    ls -l /etc/$X
    echo "------------------------------------"
    cat /etc/$X
done
echo "===================================="

pwconv
grpconv

# password for root (password=raspberrypi, overwritten by firstboot)
sed -i 's|root:.*:|root:$6$KW0GGbE5$zlEB9.PbHVh8kmXj1WMFGLJGwwthhU4oXn2oNxHZllbUSzTsVhTZ9jts8RC7uicuUCWyrsZ1e2yEj4ErDLOHQ/:15525:0:99999:7:::|' /etc/shadow

# default network configuration (dhcp)
cat << EOF > /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
NM_CONTROLLED=yes
EOF

# force remove this package
yum remove -y gnome-session-xsession

%end