2018-11-14 09:33:47 +01:00
|
|
|
#!/bin/bash
|
|
|
|
#================
|
|
|
|
# FILE : config.sh
|
|
|
|
#----------------
|
|
|
|
# PROJECT : openSUSE KIWI Image System
|
|
|
|
# COPYRIGHT : (c) 2006,2007,2008,2017 SUSE Linux GmbH. All rights reserved
|
|
|
|
# :
|
|
|
|
# AUTHOR : Marcus Schaefer <ms@suse.de>, Stephan Kulow <coolo@suse.de>, Fabian Vogt <fvogt@suse.com>
|
|
|
|
# :
|
|
|
|
# LICENSE : BSD
|
|
|
|
#======================================
|
|
|
|
# Functions...
|
|
|
|
#--------------------------------------
|
|
|
|
test -f /.kconfig && . /.kconfig
|
|
|
|
test -f /.profile && . /.profile
|
|
|
|
|
2019-06-07 13:21:10 +02:00
|
|
|
set -euxo pipefail
|
2018-11-14 09:33:47 +01:00
|
|
|
|
2019-10-30 11:55:53 +01:00
|
|
|
pl=$(rpmqpack | grep release-livecd-)
|
2018-11-14 09:33:47 +01:00
|
|
|
|
2019-10-30 11:55:53 +01:00
|
|
|
# Get the flavor from the installed (openSUSE|Leap)-release-livecd- RPM
|
2018-11-14 09:33:47 +01:00
|
|
|
# as <censored> kiwi does not make the flavor accessible
|
|
|
|
desktop=$(echo "$pl" | awk -F- '{ print $4 }' | tr A-Z a-z)
|
|
|
|
|
2018-11-20 10:12:04 +01:00
|
|
|
# Not needed, but required by suse-module-tools (bsc#1116665)
|
|
|
|
rpm -q binutils && rpm -e --nodeps binutils
|
2018-11-14 09:33:47 +01:00
|
|
|
# Not needed, but required by dracut-kiwi-live -> cdrkit-cdrtools-compat
|
|
|
|
rpm -q wodim && rpm -e --nodeps wodim
|
|
|
|
# Actually a hack: xrdb requires this, but on livecds it's not used
|
|
|
|
rpm -qa | grep "^cpp" | xargs -r rpm -e --nodeps
|
|
|
|
|
2020-08-18 12:24:40 +02:00
|
|
|
# GTK 3 hard-requires this for some reason. The only GTK3 application is Firefox,
|
|
|
|
# which has its own icons and we have breeze for the rest.
|
2021-02-12 15:54:58 +01:00
|
|
|
[ "$desktop" = "kde" ] && rpm -e --nodeps adwaita-icon-theme
|
2020-08-18 12:24:40 +02:00
|
|
|
|
2020-11-04 11:23:54 +01:00
|
|
|
# Workaround until dropped from xfce4-branding-openSUSE
|
|
|
|
[ "$desktop" = "x11" -o "$desktop" = "xfce" ] && rpm -e --nodeps noto-coloremoji-fonts
|
|
|
|
|
2018-11-14 09:33:47 +01:00
|
|
|
#--------------------------------------
|
|
|
|
# enable and disable services
|
|
|
|
|
2020-11-27 15:45:35 +01:00
|
|
|
for i in langset NetworkManager firewalld; do
|
2018-11-14 09:33:47 +01:00
|
|
|
systemctl -f enable $i
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in sshd cron wicked purge-kernels; do
|
|
|
|
systemctl -f disable $i
|
|
|
|
done
|
|
|
|
|
2019-12-19 16:40:29 +01:00
|
|
|
echo '# multipath needs to be excluded from dracut as it breaks os-prober' > /etc/dracut.conf.d/no-multipath.conf
|
2018-11-14 09:33:47 +01:00
|
|
|
echo 'omit_dracutmodules+=" multipath "' >> /etc/dracut.conf.d/no-multipath.conf
|
|
|
|
|
2021-03-04 13:10:01 +01:00
|
|
|
if [ "$desktop" = "x11" ]; then
|
|
|
|
# Forcibly exclude networking support
|
|
|
|
sed -i 's/echo network rootfs-block/echo rootfs-block/' /usr/lib/dracut/modules.d/90kiwi-live/module-setup.sh
|
|
|
|
echo 'omit_dracutmodules+=" network "' >> /etc/dracut.conf.d/no-network.conf
|
|
|
|
|
2021-04-20 16:08:58 +02:00
|
|
|
# This only needs to be able to boot the live cd
|
|
|
|
echo 'omit_dracutmodules+=" bcache crypt lvm mdraid lunmask "' >> /etc/dracut.conf.d/less-storage.conf
|
|
|
|
|
2021-03-04 13:10:01 +01:00
|
|
|
# Work around https://github.com/OSInside/kiwi/issues/1751
|
|
|
|
sed -i '/omit_dracutmodules=/d' /usr/bin/dracut
|
2021-08-09 11:58:16 +02:00
|
|
|
|
|
|
|
# Only used for X11 acceleration on vmwgfx, saves ~47MiB
|
|
|
|
rpm -e --nodeps Mesa-gallium
|
|
|
|
|
|
|
|
# Generated on boot if missing
|
|
|
|
rm /etc/udev/hwdb.bin
|
2021-03-04 13:10:01 +01:00
|
|
|
fi
|
|
|
|
|
2018-11-14 09:33:47 +01:00
|
|
|
cd /
|
|
|
|
|
|
|
|
# Import keys for installation
|
|
|
|
touch /installkey.gpg
|
|
|
|
gpg --batch --homedir /root/.gnupg --no-default-keyring --ignore-time-conflict --ignore-valid-from --keyring /installkey.gpg --import /usr/lib/rpm/gnupg/keys/*
|
|
|
|
mkdir -p /pubkeys
|
|
|
|
for i in /usr/lib/rpm/gnupg/keys/*.asc ; do
|
|
|
|
rpm --import $i || true
|
|
|
|
ln -s "$i" "/pubkeys/${i##*/}.key"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Craft license.tar.gz used by YaST
|
2019-03-25 10:46:42 +01:00
|
|
|
EULA_DIR=/etc/YaST2/licenses/base
|
|
|
|
[ -d "${EULA_DIR}" ] || EULA_DIR=/usr/share/licenses/product/base
|
|
|
|
(cd "${EULA_DIR}"; tar -cvzf /license.tar.gz *)
|
2018-11-14 09:33:47 +01:00
|
|
|
|
|
|
|
# Remove some large locales to save space
|
2021-04-20 16:08:58 +02:00
|
|
|
rm -rf /usr/{lib,share}/locale/{ca,cs,da,ja,fi,hu,id,ko,nl,pl,tr,ru,sk,sr,sv,uk,vi,cmn_TW,zh}*
|
|
|
|
rm -rf /usr/share/qt5/translations/*_{ca,cs,da,ja,fi,hu,id,ko,nl,pl,tr,ru,sk,sr,sv,uk,vi,cmn_TW,zh}*
|
2018-11-14 09:33:47 +01:00
|
|
|
zypper --non-interactive rm yast2-trans-{uk,sv,ru,ja,da,cs,sr,vi} || :
|
|
|
|
|
|
|
|
# Some packages really exaggerate here
|
|
|
|
rm -rf /usr/share/doc/packages/*
|
|
|
|
|
2020-03-16 16:16:30 +01:00
|
|
|
# Save more than 200 MiB by removing this, not very useful for lives
|
2021-06-22 09:57:25 +02:00
|
|
|
rm -rf /lib/firmware/{liquidio,netronome,qed,mrvl,mellanox,qcom,cypress,dpaa2,bnx2x}
|
2018-11-14 09:33:47 +01:00
|
|
|
|
2021-03-04 13:10:01 +01:00
|
|
|
# Not needed, boo#1166406
|
2021-09-30 09:35:34 +02:00
|
|
|
rm -f /boot/vmlinux*.[gx]z
|
|
|
|
rm -f /usr/lib/modules/*/vmlinux*.[gx]z
|
2021-03-04 13:10:01 +01:00
|
|
|
|
2018-11-14 09:33:47 +01:00
|
|
|
# Add repos from /etc/YaST2/control.xml
|
|
|
|
add-yast-repos
|
|
|
|
zypper --non-interactive rm -u live-add-yast-repos
|
|
|
|
|
2018-11-14 16:42:55 +01:00
|
|
|
# Install README.BETA where expected by YaST
|
|
|
|
cp /usr/lib/skelcd/CD1/README.BETA / || :
|
|
|
|
zypper --non-interactive rm -u skelcd-openSUSE || :
|
|
|
|
|
2018-11-14 09:33:47 +01:00
|
|
|
# Remove the zypper locks needed for a slimmer system
|
|
|
|
zypper rl $(seq 1 $(zypper ll | wc -l))
|
|
|
|
|
|
|
|
#======================================
|
|
|
|
# /etc/sudoers hack to fix #297695
|
|
|
|
# (Installation Live CD: no need to ask for password of root)
|
|
|
|
#--------------------------------------
|
|
|
|
sed -i -e "s/ALL ALL=(ALL) ALL/ALL ALL=(ALL) NOPASSWD: ALL/" /etc/sudoers
|
|
|
|
chmod 0440 /etc/sudoers
|
|
|
|
|
|
|
|
/usr/sbin/useradd -m -u 1000 linux -c "Live-CD User" -p ""
|
|
|
|
|
|
|
|
# delete passwords
|
|
|
|
passwd -d root
|
|
|
|
passwd -d linux
|
|
|
|
# empty password is ok
|
|
|
|
pam-config -a --nullok
|
|
|
|
|
|
|
|
: > /var/log/zypper.log
|
|
|
|
|
2021-05-10 11:36:39 +02:00
|
|
|
# Create fstab if it doesn't exist (Work around boo#1185815)
|
|
|
|
>>/etc/fstab
|
|
|
|
|
2020-11-27 15:45:35 +01:00
|
|
|
# Add Installation and upgrade icons to the desktop
|
2018-11-14 09:33:47 +01:00
|
|
|
if [ "$desktop" = "kde" ]; then
|
|
|
|
# bug 989897, avoid creating desktop directory on KDE so that the default items are added on first login
|
2020-11-27 15:45:35 +01:00
|
|
|
cp /usr/share/applications/{installation,upgrade}.desktop /usr/share/kio_desktop/DesktopLinks/
|
2018-11-14 09:33:47 +01:00
|
|
|
# Set the application as being "trusted"
|
2020-11-27 15:45:35 +01:00
|
|
|
chmod a+x /usr/share/kio_desktop/DesktopLinks/{installation,upgrade}.desktop
|
2019-03-06 15:30:09 +01:00
|
|
|
elif [ "$desktop" = "xfce" ]; then
|
|
|
|
mkdir -p /home/linux/.config /home/linux/Desktop
|
|
|
|
echo 'XDG_DESKTOP_DIR="$HOME/Desktop"' > /home/linux/.config/user-dirs.dirs
|
2020-11-27 15:45:35 +01:00
|
|
|
cp /usr/share/applications/{installation,upgrade}.desktop /home/linux/Desktop/
|
2019-03-06 15:30:09 +01:00
|
|
|
# Set the application as being "trusted"
|
2020-11-27 15:45:35 +01:00
|
|
|
chmod a+x /home/linux/Desktop/{installation,upgrade}.desktop
|
2018-11-14 09:33:47 +01:00
|
|
|
fi
|
2020-11-27 15:45:35 +01:00
|
|
|
# 'x11' (rescue) does not contain the installer, GNOME Shell has no concept of 'desktop'
|
2018-11-14 09:33:47 +01:00
|
|
|
|
|
|
|
chown -R linux /home/linux
|
|
|
|
|
|
|
|
chkstat --system --set
|
|
|
|
|
|
|
|
ln -s /usr/lib/systemd/system/runlevel5.target /etc/systemd/system/default.target
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/displaymanager DISPLAYMANAGER_AUTOLOGIN linux
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/keyboard YAST_KEYBOARD "english-us,pc104"
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/keyboard COMPOSETABLE "clear latin1.add"
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/language RC_LANG ""
|
|
|
|
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/console CONSOLE_FONT "eurlatgr.psfu"
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/console CONSOLE_SCREENMAP trivial
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/console CONSOLE_MAGIC "(K"
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/console CONSOLE_ENCODING "UTF-8"
|
|
|
|
|
|
|
|
[ "$desktop" = "gnome" ] && displaymanager=gdm
|
|
|
|
[ "$desktop" = "kde" ] && displaymanager=sddm
|
2019-03-06 15:30:09 +01:00
|
|
|
[ "$desktop" = "xfce" ] && displaymanager=lightdm
|
2018-11-14 09:33:47 +01:00
|
|
|
[ "$desktop" = "x11" ] && displaymanager=lightdm
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/displaymanager DISPLAYMANAGER $displaymanager
|
|
|
|
|
|
|
|
# boo#1039756
|
|
|
|
[ "$desktop" = "gnome" ] && baseUpdateSysConfig /etc/sysconfig/windowmanager DEFAULT_WM gnome
|
|
|
|
|
2020-11-04 10:15:21 +01:00
|
|
|
# Disable journal write to disk in live mode, bug 950999
|
2018-11-14 09:33:47 +01:00
|
|
|
echo "Storage=volatile" >> /etc/systemd/journald.conf
|
|
|
|
|
|
|
|
# Remove generated files (boo#1098535)
|
|
|
|
rm -rf /var/cache/zypp/* /var/lib/zypp/AnonymousUniqueId /var/lib/systemd/random-seed
|
2019-02-13 10:05:43 +01:00
|
|
|
|
2019-12-19 16:40:29 +01:00
|
|
|
cat >/etc/systemd/system/fixupbootloader.service <<EOF
|
|
|
|
# boo#1155545 - LOADER_TYPE has to be nil for the upgrade to work properly.
|
|
|
|
# Kiwi does not allow changing the file directly, so do it in this ugly way.
|
|
|
|
[Unit]
|
|
|
|
Description=Remove LOADER_TYPE from /etc/sysconfig/bootloader
|
|
|
|
Before=systemd-user-sessions.service
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
ExecStart=/usr/bin/gawk -i inplace '!/^LOADER_TYPE=/' /etc/sysconfig/bootloader
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl -f enable fixupbootloader.service
|