Blame kickstarts/centos-7-EasyDocker.cfg

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