2019-09-26 11:31:34 +02:00
|
|
|
#!/bin/bash
|
2020-03-13 12:01:59 +01:00
|
|
|
# Copyright (c) 2020 SUSE LLC
|
2019-09-26 11:31:34 +02:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal
|
|
|
|
# in the Software without restriction, including without limitation the rights
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
# SOFTWARE.
|
|
|
|
#
|
|
|
|
#======================================
|
|
|
|
# Functions...
|
|
|
|
#--------------------------------------
|
|
|
|
test -f /.kconfig && . /.kconfig
|
|
|
|
test -f /.profile && . /.profile
|
|
|
|
|
|
|
|
set -euxo pipefail
|
|
|
|
|
|
|
|
#======================================
|
|
|
|
# Greeting...
|
|
|
|
#--------------------------------------
|
|
|
|
echo "Configure image: [$kiwi_iname]-[$kiwi_profiles]..."
|
|
|
|
|
|
|
|
#======================================
|
|
|
|
# add missing fonts
|
|
|
|
#--------------------------------------
|
2020-03-13 12:01:59 +01:00
|
|
|
# Systemd controls the console font now
|
|
|
|
echo FONT="eurlatgr.psfu" >> /etc/vconsole.conf
|
2019-09-26 11:31:34 +02:00
|
|
|
|
|
|
|
#======================================
|
|
|
|
# prepare for setting root pw, timezone
|
|
|
|
#--------------------------------------
|
|
|
|
echo ** "reset machine settings"
|
|
|
|
sed -i 's/^root:[^:]*:/root:*:/' /etc/shadow
|
|
|
|
rm -f /etc/machine-id \
|
|
|
|
/var/lib/zypp/AnonymousUniqueId \
|
|
|
|
/var/lib/systemd/random-seed \
|
|
|
|
/var/lib/dbus/machine-id
|
|
|
|
|
|
|
|
#======================================
|
2020-03-13 12:01:59 +01:00
|
|
|
# Specify default systemd target
|
2019-09-26 11:31:34 +02:00
|
|
|
#--------------------------------------
|
2020-03-13 12:01:59 +01:00
|
|
|
baseSetRunlevel multi-user.target
|
2019-09-26 11:31:34 +02:00
|
|
|
|
|
|
|
#======================================
|
2020-03-13 12:01:59 +01:00
|
|
|
# Import trusted rpm keys
|
2019-09-26 11:31:34 +02:00
|
|
|
#--------------------------------------
|
|
|
|
suseImportBuildKey
|
|
|
|
|
|
|
|
#======================================
|
|
|
|
# Enable sshd
|
|
|
|
#--------------------------------------
|
2020-02-04 09:56:07 +01:00
|
|
|
systemctl enable sshd.service
|
2019-09-26 11:31:34 +02:00
|
|
|
|
|
|
|
if [ -e /etc/cloud/cloud.cfg ]; then
|
|
|
|
# not useful for cloud
|
|
|
|
systemctl mask systemd-firstboot.service
|
|
|
|
|
|
|
|
suseInsertService cloud-init-local
|
|
|
|
suseInsertService cloud-init
|
|
|
|
suseInsertService cloud-config
|
|
|
|
suseInsertService cloud-final
|
|
|
|
else
|
|
|
|
# Enable jeos-firstboot
|
|
|
|
mkdir -p /var/lib/YaST2
|
|
|
|
touch /var/lib/YaST2/reconfig_system
|
|
|
|
|
|
|
|
systemctl mask systemd-firstboot.service
|
|
|
|
systemctl enable jeos-firstboot.service
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Enable firewalld if installed
|
|
|
|
if [ -x /usr/sbin/firewalld ]; then
|
2020-02-04 09:56:07 +01:00
|
|
|
systemctl enable firewalld.service
|
2019-09-26 11:31:34 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
#======================================
|
|
|
|
# Add repos from control.xml
|
|
|
|
#--------------------------------------
|
2020-03-13 12:01:59 +01:00
|
|
|
if grep -q opensuse /usr/lib/os-release; then
|
|
|
|
add-yast-repos
|
|
|
|
zypper --non-interactive rm -u live-add-yast-repos
|
|
|
|
fi
|
2019-09-26 11:31:34 +02:00
|
|
|
|
|
|
|
#=====================================
|
|
|
|
# Configure snapper
|
|
|
|
#-------------------------------------
|
|
|
|
if [ "${kiwi_btrfs_root_is_snapshot-false}" = 'true' ]; then
|
|
|
|
echo "creating initial snapper config ..."
|
|
|
|
# we can't call snapper here as the .snapshots subvolume
|
2020-03-13 12:01:59 +01:00
|
|
|
# already exists and snapper create-config doesn't like
|
2019-09-26 11:31:34 +02:00
|
|
|
# that.
|
|
|
|
cp /etc/snapper/config-templates/default /etc/snapper/configs/root
|
|
|
|
# Change configuration to match SLES12-SP1 values
|
|
|
|
sed -i -e '/^TIMELINE_CREATE=/s/yes/no/' /etc/snapper/configs/root
|
|
|
|
sed -i -e '/^NUMBER_LIMIT=/s/50/10/' /etc/snapper/configs/root
|
|
|
|
|
|
|
|
baseUpdateSysConfig /etc/sysconfig/snapper SNAPPER_CONFIGS root
|
|
|
|
fi
|
|
|
|
|
|
|
|
#=====================================
|
|
|
|
# Enable chrony if installed
|
|
|
|
#-------------------------------------
|
|
|
|
if [ -f /etc/chrony.conf ]; then
|
|
|
|
suseInsertService chronyd
|
|
|
|
fi
|
|
|
|
|
|
|
|
#======================================
|
|
|
|
# Disable recommends on virtual images (keep hardware supplements, see bsc#1089498)
|
|
|
|
#--------------------------------------
|
|
|
|
sed -i 's/.*solver.onlyRequires.*/solver.onlyRequires = true/g' /etc/zypp/zypp.conf
|
|
|
|
|
|
|
|
#======================================
|
|
|
|
# Disable installing documentation
|
|
|
|
#--------------------------------------
|
|
|
|
sed -i 's/.*rpm.install.excludedocs.*/rpm.install.excludedocs = yes/g' /etc/zypp/zypp.conf
|
|
|
|
|
|
|
|
#======================================
|
|
|
|
# Configure Raspberry Pi specifics
|
|
|
|
#--------------------------------------
|
|
|
|
if [[ "$kiwi_profiles" == *"RaspberryPi"* ]]; then
|
2020-07-01 13:57:22 +02:00
|
|
|
# Also show WLAN interfaces in /etc/issue. Remove once https://github.com/thkukuk/issue-generator/pull/4 accepted
|
2020-04-16 12:23:49 +02:00
|
|
|
baseUpdateSysConfig /etc/sysconfig/issue-generator NETWORK_INTERFACE_REGEX '^[bew]'
|
2019-09-26 11:31:34 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Not compatible with set -e
|
|
|
|
baseCleanMount || true
|
|
|
|
|
|
|
|
exit 0
|