Blame kickstarts/centos-7-livedocker.cfg

7a1a7c
7a1a7c
lang en_GB.UTF-8
7a1a7c
keyboard us
7a1a7c
timezone Europe/Brussels --isUtc
7a1a7c
auth --useshadow --enablemd5
7a1a7c
selinux --enforcing
7a1a7c
#firewall --enabled --service=cockpit
7a1a7c
firewall --disabled
7a1a7c
#xconfig --startxonboot
7a1a7c
part / --size 8192 --fstype ext4
7a1a7c
services --enabled=NetworkManager --disabled=network
7a1a7c
7a1a7c
7a1a7c
# Root password
7a1a7c
rootpw --plaintext centos
7a1a7c
7a1a7c
repo --name=base --baseurl=http://mirror.centos.org/centos/7/os/x86_64/
7a1a7c
repo --name=updates --baseurl=http://mirror.centos.org/centos/7/updates/x86_64/
7a1a7c
repo --name=extras --baseurl=http://mirror.centos.org/centos/7/extras/x86_64/
7a1a7c
7a1a7c
%packages 
7a1a7c
@core
7a1a7c
kernel
7a1a7c
dracut
7a1a7c
bash
7a1a7c
firewalld
7a1a7c
NetworkManager
7a1a7c
e2fsprogs
7a1a7c
rootfiles
7a1a7c
docker
7a1a7c
7a1a7c
# For UEFI/Secureboot support
7a1a7c
grub2
7a1a7c
grub2-efi
7a1a7c
efibootmgr
7a1a7c
shim
7a1a7c
7a1a7c
7a1a7c
7a1a7c
%end
7a1a7c
7a1a7c
%post
7a1a7c
7a1a7c
systemctl enable docker
7a1a7c
7a1a7c
# FIXME: it'd be better to get this installed from a package
7a1a7c
cat > /etc/rc.d/init.d/livesys << EOF
7a1a7c
#!/bin/bash
7a1a7c
#
7a1a7c
# live: Init script for live image
7a1a7c
#
7a1a7c
# chkconfig: 345 00 99
7a1a7c
# description: Init script for live image.
7a1a7c
### BEGIN INIT INFO
7a1a7c
# X-Start-Before: display-manager
7a1a7c
### END INIT INFO
7a1a7c
7a1a7c
. /etc/init.d/functions
7a1a7c
7a1a7c
if ! strstr "\`cat /proc/cmdline\`" rd.live.image || [ "\$1" != "start" ]; then
7a1a7c
    exit 0
7a1a7c
fi
7a1a7c
7a1a7c
if [ -e /.liveimg-configured ] ; then
7a1a7c
    configdone=1
7a1a7c
fi
7a1a7c
7a1a7c
exists() {
7a1a7c
    which \$1 >/dev/null 2>&1 || return
7a1a7c
    \$*
7a1a7c
}
7a1a7c
7a1a7c
# Make sure we don't mangle the hardware clock on shutdown
7a1a7c
ln -sf /dev/null /etc/systemd/system/hwclock-save.service
7a1a7c
7a1a7c
livedir="LiveOS"
7a1a7c
for arg in \`cat /proc/cmdline\` ; do
7a1a7c
  if [ "\${arg##rd.live.dir=}" != "\${arg}" ]; then
7a1a7c
    livedir=\${arg##rd.live.dir=}
7a1a7c
    return
7a1a7c
  fi
7a1a7c
  if [ "\${arg##live_dir=}" != "\${arg}" ]; then
7a1a7c
    livedir=\${arg##live_dir=}
7a1a7c
    return
7a1a7c
  fi
7a1a7c
done
7a1a7c
7a1a7c
# enable swaps unless requested otherwise
7a1a7c
swaps=\`blkid -t TYPE=swap -o device\`
7a1a7c
if ! strstr "\`cat /proc/cmdline\`" noswap && [ -n "\$swaps" ] ; then
7a1a7c
  for s in \$swaps ; do
7a1a7c
    action "Enabling swap partition \$s" swapon \$s
7a1a7c
  done
7a1a7c
fi
7a1a7c
if ! strstr "\`cat /proc/cmdline\`" noswap && [ -f /run/initramfs/live/\${livedir}/swap.img ] ; then
7a1a7c
  action "Enabling swap file" swapon /run/initramfs/live/\${livedir}/swap.img
7a1a7c
fi
7a1a7c
7a1a7c
mountDockerDisk() {
7a1a7c
  # support label/uuid
7a1a7c
  if [ "\${dockerdev##LABEL=}" != "\${dockerdev}" -o "\${dockerdev##UUID=}" != "\${dockerdev}" ]; then
7a1a7c
    dockerdev=\`/sbin/blkid -o device -t "\$dockerdev"\`
7a1a7c
  fi
7a1a7c
7a1a7c
  # if we're given a file rather than a blockdev, loopback it
7a1a7c
  if [ "\${dockerdev##mtd}" != "\${dockerdev}" ]; then
7a1a7c
    # mtd devs don't have a block device but get magic-mounted with -t jffs2
7a1a7c
    mountopts="-t jffs2"
7a1a7c
  elif [ ! -b "\$dockerdev" ]; then
7a1a7c
    loopdev=\`losetup -f\`
7a1a7c
    if [ "\${dockerdev##/run/initramfs/live}" != "\${dockerdev}" ]; then
7a1a7c
      action "Remounting live store r/w" mount -o remount,rw /run/initramfs/live
7a1a7c
    fi
7a1a7c
    losetup \$loopdev \$dockerdev
7a1a7c
    dockerdev=\$loopdev
7a1a7c
  fi
7a1a7c
7a1a7c
  # if it's encrypted, we need to unlock it
7a1a7c
  if [ "\$(/sbin/blkid -s TYPE -o value \$dockerdev 2>/dev/null)" = "crypto_LUKS" ]; then
7a1a7c
    echo
7a1a7c
    echo "Setting up encrypted Docker device"
7a1a7c
    plymouth ask-for-password --command="cryptsetup luksOpen \$dockerdev EncDocker"
7a1a7c
    dockerdev=/dev/mapper/EncDocker
7a1a7c
  fi
7a1a7c
7a1a7c
  # and finally do the mount
7a1a7c
  mount \$mountopts \$dockerdev /var/lib/docker
7a1a7c
  # if we have /home under what's passed for persistent home, then
7a1a7c
  # we should make that the real /home.  useful for mtd device on olpc
7a1a7c
  if [ -d /var/lib/docker/docker ]; then mount --bind /var/lib/docker/docker /var/lib/docker ; fi
7a1a7c
  [ -x /sbin/restorecon ] && /sbin/restorecon /var/lib/docker
7a1a7c
}
7a1a7c
7a1a7c
findDockerDisk() {
7a1a7c
  for arg in \`cat /proc/cmdline\` ; do
7a1a7c
    if [ "\${arg##dockerdisk=}" != "\${arg}" ]; then
7a1a7c
      dockerdev=\${arg##dockerdisk=}
7a1a7c
      return
7a1a7c
    fi
7a1a7c
  done
7a1a7c
}
7a1a7c
7a1a7c
if strstr "\`cat /proc/cmdline\`" dockerdisk= ; then
7a1a7c
  findDockerDisk
7a1a7c
elif [ -e /run/initramfs/live/\${livedir}/docker.img ]; then
7a1a7c
  dockerdev=/run/initramfs/live/\${livedir}/docker.img
7a1a7c
fi
7a1a7c
7a1a7c
# if we have a persistent /home, then we want to go ahead and mount it
7a1a7c
if ! strstr "\`cat /proc/cmdline\`" nodockerdisk && [ -n "\$dockerdev" ] ; then
7a1a7c
  action "Mounting persistent /var/lib/docker" mountDockerDisk
7a1a7c
fi
7a1a7c
7a1a7c
# make it so that we don't do writing to the overlay for things which
7a1a7c
# are just tmpdirs/caches
7a1a7c
mount -t tmpfs -o mode=0755 varcacheyum /var/cache/yum
7a1a7c
mount -t tmpfs vartmp /var/tmp
7a1a7c
[ -x /sbin/restorecon ] && /sbin/restorecon /var/cache/yum /var/tmp >/dev/null 2>&1
7a1a7c
7a1a7c
if [ -n "\$configdone" ]; then
7a1a7c
  exit 0
7a1a7c
fi
7a1a7c
7a1a7c
# add fedora user with no passwd
7a1a7c
action "Adding live user" useradd \$USERADDARGS -c "Live System User" liveuser
7a1a7c
passwd -d liveuser > /dev/null
7a1a7c
usermod -aG wheel,docker liveuser > /dev/null
7a1a7c
7a1a7c
# Remove root password lock
7a1a7c
passwd -d root > /dev/null
7a1a7c
(echo centos ; echo centos)|passwd root --stdin
7a1a7c
7a1a7c
# turn off firstboot for livecd boots
7a1a7c
systemctl --no-reload disable firstboot-text.service 2> /dev/null || :
7a1a7c
systemctl --no-reload disable firstboot-graphical.service 2> /dev/null || :
7a1a7c
systemctl stop firstboot-text.service 2> /dev/null || :
7a1a7c
systemctl stop firstboot-graphical.service 2> /dev/null || :
7a1a7c
7a1a7c
# don't use prelink on a running live image
7a1a7c
sed -i 's/PRELINKING=yes/PRELINKING=no/' /etc/sysconfig/prelink &>/dev/null || :
7a1a7c
7a1a7c
# turn off mdmonitor by default
7a1a7c
systemctl --no-reload disable mdmonitor.service 2> /dev/null || :
7a1a7c
systemctl --no-reload disable mdmonitor-takeover.service 2> /dev/null || :
7a1a7c
systemctl stop mdmonitor.service 2> /dev/null || :
7a1a7c
systemctl stop mdmonitor-takeover.service 2> /dev/null || :
7a1a7c
7a1a7c
# don't enable the gnome-settings-daemon packagekit plugin
7a1a7c
gsettings set org.gnome.settings-daemon.plugins.updates active 'false' || :
7a1a7c
7a1a7c
# don't start cron/at as they tend to spawn things which are
7a1a7c
# disk intensive that are painful on a live image
7a1a7c
systemctl --no-reload disable crond.service 2> /dev/null || :
7a1a7c
systemctl --no-reload disable atd.service 2> /dev/null || :
7a1a7c
systemctl stop crond.service 2> /dev/null || :
7a1a7c
systemctl stop atd.service 2> /dev/null || :
7a1a7c
7a1a7c
# Mark things as configured
7a1a7c
touch /.liveimg-configured
7a1a7c
7a1a7c
# add static hostname to work around xauth bug
7a1a7c
# https://bugzilla.redhat.com/show_bug.cgi?id=679486
7a1a7c
echo "localhost" > /etc/hostname
7a1a7c
7a1a7c
# Fixing the lang install issue when other lang than English is selected . See http://bugs.centos.org/view.php?id=7217
7a1a7c
/usr/bin/cp /usr/lib/python2.7/site-packages/blivet/size.py /usr/lib/python2.7/site-packages/blivet/size.py.orig
7a1a7c
/usr/bin/sed -i "s#return self.humanReadable()#return self.humanReadable().encode('utf-8')#g" /usr/lib/python2.7/site-packages/blivet/size.py
7a1a7c
7a1a7c
EOF
7a1a7c
7a1a7c
# bah, hal starts way too late
7a1a7c
cat > /etc/rc.d/init.d/livesys-late << EOF
7a1a7c
#!/bin/bash
7a1a7c
#
7a1a7c
# live: Late init script for live image
7a1a7c
#
7a1a7c
# chkconfig: 345 99 01
7a1a7c
# description: Late init script for live image.
7a1a7c
7a1a7c
. /etc/init.d/functions
7a1a7c
7a1a7c
if ! strstr "\`cat /proc/cmdline\`" rd.live.image || [ "\$1" != "start" ] || [ -e /.liveimg-late-configured ] ; then
7a1a7c
    exit 0
7a1a7c
fi
7a1a7c
7a1a7c
exists() {
7a1a7c
    which \$1 >/dev/null 2>&1 || return
7a1a7c
    \$*
7a1a7c
}
7a1a7c
7a1a7c
touch /.liveimg-late-configured
7a1a7c
7a1a7c
# read some variables out of /proc/cmdline
7a1a7c
for o in \`cat /proc/cmdline\` ; do
7a1a7c
    case \$o in
7a1a7c
    ks=*)
7a1a7c
        ks="--kickstart=\${o#ks=}"
7a1a7c
        ;;
7a1a7c
    xdriver=*)
7a1a7c
        xdriver="\${o#xdriver=}"
7a1a7c
        ;;
7a1a7c
    esac
7a1a7c
done
7a1a7c
7a1a7c
# if liveinst or textinst is given, start anaconda
7a1a7c
if strstr "\`cat /proc/cmdline\`" liveinst ; then
7a1a7c
   plymouth --quit
7a1a7c
   /usr/sbin/liveinst \$ks
7a1a7c
fi
7a1a7c
if strstr "\`cat /proc/cmdline\`" textinst ; then
7a1a7c
   plymouth --quit
7a1a7c
   /usr/sbin/liveinst --text \$ks
7a1a7c
fi
7a1a7c
7a1a7c
# configure X, allowing user to override xdriver
7a1a7c
if [ -n "\$xdriver" ]; then
7a1a7c
   cat > /etc/X11/xorg.conf.d/00-xdriver.conf <
7a1a7c
Section "Device"
7a1a7c
	Identifier	"Videocard0"
7a1a7c
	Driver	"\$xdriver"
7a1a7c
EndSection
7a1a7c
FOE
7a1a7c
fi
7a1a7c
7a1a7c
EOF
7a1a7c
7a1a7c
chmod 755 /etc/rc.d/init.d/livesys
7a1a7c
/sbin/restorecon /etc/rc.d/init.d/livesys
7a1a7c
/sbin/chkconfig --add livesys
7a1a7c
7a1a7c
chmod 755 /etc/rc.d/init.d/livesys-late
7a1a7c
/sbin/restorecon /etc/rc.d/init.d/livesys-late
7a1a7c
/sbin/chkconfig --add livesys-late
7a1a7c
7a1a7c
# enable tmpfs for /tmp
7a1a7c
systemctl enable tmp.mount
7a1a7c
7a1a7c
7a1a7c
# enable docker
7a1a7c
systemctl enable docker.service
7a1a7c
7a1a7c
# work around for poor key import UI in PackageKit
7a1a7c
rm -f /var/lib/rpm/__db*
7a1a7c
releasever=$(rpm -q --qf '%{version}\n' --whatprovides system-release)
7a1a7c
basearch=$(uname -i)
7a1a7c
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-$releasever-$basearch
7a1a7c
echo "Packages within this LiveCD"
7a1a7c
rpm -qa
7a1a7c
# Note that running rpm recreates the rpm db files which aren't needed or wanted
7a1a7c
rm -f /var/lib/rpm/__db*
7a1a7c
7a1a7c
# go ahead and pre-make the man -k cache (#455968)
7a1a7c
/usr/bin/mandb
7a1a7c
7a1a7c
# save a little bit of space at least...
7a1a7c
rm -f /boot/initramfs*
7a1a7c
# make sure there aren't core files lying around
7a1a7c
rm -f /core*
7a1a7c
7a1a7c
# convince readahead not to collect
7a1a7c
# FIXME: for systemd
7a1a7c
7a1a7c
cat >> /etc/rc.d/init.d/livesys << EOF
7a1a7c
7a1a7c
7a1a7c
# disable updates plugin
7a1a7c
cat >> /usr/share/glib-2.0/schemas/org.gnome.settings-daemon.plugins.updates.gschema.override << FOE
7a1a7c
[org.gnome.settings-daemon.plugins.updates]
7a1a7c
active=false
7a1a7c
FOE
7a1a7c
7a1a7c
# Show the system-config-keyboard tool on the desktop
7a1a7c
mkdir /home/liveuser/Desktop -p >/dev/null
7a1a7c
cat /usr/share/applications/system-config-keyboard.desktop | sed '/NotShowIn/d' |sed 's/Terminal=false/Terminal=true/' > /home/liveuser/Desktop/system-config-keyboard.desktop
7a1a7c
cat /usr/share/applications/liveinst.desktop | sed '/NoDisplay/d' > /home/liveuser/Desktop/liveinst.desktop 
7a1a7c
chmod +x /home/liveuser/Desktop/*.desktop
7a1a7c
chown -R liveuser:liveuser /home/liveuser
7a1a7c
7a1a7c
# Liveuser face
7a1a7c
if [ -e /usr/share/icons/hicolor/96x96/apps/fedora-logo-icon.png ] ; then
7a1a7c
    cp /usr/share/icons/hicolor/96x96/apps/fedora-logo-icon.png /home/liveuser/.face
7a1a7c
    chown liveuser:liveuser /home/liveuser/.face
7a1a7c
fi
7a1a7c
7a1a7c
# make the installer show up
7a1a7c
if [ -f /usr/share/applications/liveinst.desktop ]; then
7a1a7c
  # Show harddisk install in shell dash
7a1a7c
  sed -i -e 's/NoDisplay=true/NoDisplay=false/' /usr/share/applications/liveinst.desktop 
7a1a7c
  # need to move it to anaconda.desktop to make shell happy
7a1a7c
  #cp /usr/share/applications/liveinst.desktop /usr/share/applications/anaconda.desktop
7a1a7c
fi
7a1a7c
  cat >> /usr/share/glib-2.0/schemas/org.gnome.shell.gschema.override << FOE
7a1a7c
[org.gnome.shell]
7a1a7c
favorite-apps=['liveinst.desktop','firefox.desktop', 'evolution.desktop', 'empathy.desktop', 'rhythmbox.desktop', 'shotwell.desktop', 'libreoffice-writer.desktop', 'nautilus.desktop', 'gnome-documents.desktop', 'anaconda.desktop']
7a1a7c
FOE
7a1a7c
7a1a7c
7a1a7c
# set up auto-login
7a1a7c
cat > /etc/gdm/custom.conf << FOE
7a1a7c
[daemon]
7a1a7c
AutomaticLoginEnable=True
7a1a7c
AutomaticLogin=liveuser
7a1a7c
FOE
7a1a7c
7a1a7c
# Turn off PackageKit-command-not-found while uninstalled
7a1a7c
if [ -f /etc/PackageKit/CommandNotFound.conf ]; then
7a1a7c
  sed -i -e 's/^SoftwareSourceSearch=true/SoftwareSourceSearch=false/' /etc/PackageKit/CommandNotFound.conf
7a1a7c
fi
7a1a7c
7a1a7c
# make sure to set the right permissions and selinux contexts
7a1a7c
chown -R liveuser:liveuser /home/liveuser/
7a1a7c
restorecon -R /home/liveuser/
7a1a7c
7a1a7c
# Fixing default locale to us
7a1a7c
localectl set-keymap us
7a1a7c
localectl set-x11-keymap us
7a1a7c
EOF
7a1a7c
7a1a7c
# rebuild schema cache with any overrides we installed
7a1a7c
glib-compile-schemas /usr/share/glib-2.0/schemas
7a1a7c
7a1a7c
7a1a7c
%end