-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathconfig.sh
186 lines (161 loc) · 7.34 KB
/
config.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/bin/bash
# Optional configuration script while creating the unpacked image. This script
# is called at the end of the installation, but before the package scripts
# have run. It is designed to configure the image system, such as the
# activation or deactivation of certain services (insserv). The call is not
# made until after the switch to the image has been made with chroot.
# https://osinside.github.io/kiwi/working_with_kiwi/shell_scripts.html
# Functions...
#--------------------------------------
test -f /.kconfig && . /.kconfig
test -f /.profile && . /.profile
#======================================
# Greeting...
#--------------------------------------
echo "Configure image: [$kiwi_iname]..."
#======================================
# Setup baseproduct link
#--------------------------------------
suseSetupProduct
#======================================
# Add missing gpg keys to rpm
#--------------------------------------
suseImportBuildKey
#======================================
# Import Rockstor GPG Key
# https://raw.githubusercontent.com/rockstor/rockstor-core/master/conf/ROCKSTOR-GPG-KEY
# N.B. Expires 2025-05-29
#--------------------------------------
t=$(mktemp)
cat - <<EOF > $t
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBF7SoJkBCADTKeUnVek8p8bXlDF3vhABCCq9FFYf6NN5ZrtDoZUa2Zysazij
lqusMdpdswuqxsre7fjsGtMS9sGf16Yp0PUpqCel/fH/vN/foV38ur939gXswa3E
+ZbVtltSnzSJZxqVGpgK8Lih3jFoyC8abhEfnCLXKBTEdpZPOgyDtanM1h9EHsZG
wjzw2vi/CgCiPJwdIeNrrBp3IO69t4PfgHWCAfeHAuVscOecfJ4u0PZWLchE8tsH
UUj5ijXoA1yPMSR8v5lLJfB5ElIYHP+Uqs4RhX2cVFVJN2IlaR+O9b2EAWjylwk4
b9SxJe3aTGkMESc3XVSrtyMAntNivIjqDt6nABEBAAG0QlRoZSBSb2Nrc3RvciBQ
cm9qZWN0IChSb2Nrc3RvciBEZXZlbG9wbWVudCkgPHN1cHBvcnRAcm9ja3N0b3Iu
Y29tPokBVAQTAQgAPhYhBBXrUqcB5WwRYHPuURxCYvJfBDGHBQJe0qCZAhsDBQkJ
ZgGABQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEBxCYvJfBDGH/OMH/2l5yd3W
SONhuXVwFjpY70iE8IM+Y6PPGUz5pFTCKJ8EpSznnuqFzlCr7Pgi9OFLoWoX6CAt
h6dH/E+22ktZ0Mgi7Z8zkyyc5265iyk2liW49GLpeC2PIjkEzKv/7oNOpLg6sXH8
i9Z9q+3RXPGUOw8I5uR1kYDwDtMNBxnWaTsL5qHRSDxR0WgOFgilMQVeE1uoxd3m
SeLW4cnzw/2MGYKsniHCePB70WSEYZaX8kLOXVsskBn0/LnVICB2cSo7cKz4YmUe
MTqgCQwMURIn8eSz/8gxl4rONal4CGZTb899VLIqgqr5IEEqas3o8WJbRf/I6akJ
I9yXyz+yWhBlTTU=
=8Urm
-----END PGP PUBLIC KEY BLOCK-----
EOF
rpm --import $t
rm -f $t
#======================================
# Auto import all repo GPG keys
#--------------------------------------
zypper --non-interactive --gpg-auto-import-keys refresh
#======================================
# Deactivate services
#--------------------------------------
baseRemoveService wicked
baseRemoveService apparmor
#======================================
# Activate services
#--------------------------------------
baseInsertService sshd
baseInsertService grub_config
baseInsertService dracut_hostonly
baseInsertService jeos-firstboot
baseInsertService NetworkManager
#======================================
# Setup default target, multi-user
#--------------------------------------
baseSetRunlevel 3
#==========================================
# remove package docs
#------------------------------------------
rm -rf /usr/share/doc/packages/*
rm -rf /usr/share/doc/manual/*
#=====================================
# Configure snapper
#-------------------------------------
if [ "$kiwi_btrfs_root_is_snapshot" = 'true' ]; then
echo "creating initial snapper config ..."
# we can't call snapper here as the .snapshots subvolume
# already exists and snapper create-config doens't like
# 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
#=====================================
# Edit the base distro openSUSE license files in accordance with the following:
# https://en.opensuse.org/Archive:Making_an_openSUSE_based_distribution
# Files to edit /usr/share/licenses/openSUSE-release/*.txt
#-------------------------------------
shopt -s nullglob
for license_file in /usr/share/licenses/openSUSE-release/*.txt
do
sed -i 's/openSUSE®/Rockstor "Built on openSUSE"/g' "${license_file}"
sed -i 's/The openSUSE Project/The Rockstor Project/g' "${license_file}"
sed -i 's/openSUSE Leap /Rockstor "Built on openSUSE" Leap /g' "${license_file}"
sed -i 's/OPENSUSE Leap /Rockstor "Built on openSUSE" Leap /g' "${license_file}"
sed -i 's/openSUSE Tumbleweed /Rockstor "Built on openSUSE" Tumbleweed /g' "${license_file}"
sed -i 's/OPENSUSE Tumbleweed /Rockstor "Built on openSUSE" Tumbleweed /g' "${license_file}"
sed -i 's/OPENSUSE/ROCKSTOR/g' "${license_file}"
sed -i 's/$50US/1ST STABLE UPDATES SUBSCRIPTION PAYED/g' "${license_file}"
sed -i 's/$50/1ST STABLE UPDATES SUBSCRIPTION PAYED/g' "${license_file}"
sed -i 's/50 USD/1ST STABLE UPDATES SUBSCRIPTION PAYED/g' "${license_file}"
sed -i 's/(50 $)/(1ST STABLE UPDATES STABLE UPDATES SUBSCRIPTION PAYED)/g' "${license_file}"
sed -i 's/(US \$ 50)/(1ST STABLE UPDATES SUBSCRIPTION PAYED)/g' "${license_file}"
sed -i 's/50 $/1ST STABLE UPDATES SUBSCRIPTION PAYED/g' "${license_file}"
sed -i 's/50/1ST STABLE UPDATES SUBSCRIPTION PAYED/g' "${license_file}"
sed -i 's/US-DOLLAR//g' "${license_file}"
sed -i 's/US\$//g' "${license_file}"
sed -i 's/2008-..../2024/g' "${license_file}"
done
# Alter the distro display name to add the suggested "Rockstor built on ..." prefix.
sed -i 's/PRETTY_NAME="openSUSE/PRETTY_NAME="Rockstor built on openSUSE/g' /usr/lib/os-release
# Alter BUG_REPORT_URL
sed -i 's/https:\/\/bugs.opensuse.org/https:\/\/forum.rockstor.com/g' /usr/lib/os-release
# Alter HOME_URL
sed -i 's/https:\/\/www.opensuse.org/https:\/\/rockstor.com/g' /usr/lib/os-release
# Alter DOCUMENTATION_URL
sed -i 's/^DOCUMENTATION_URL.*/DOCUMENTATION_URL="https:\/\/rockstor.com\/docs"/' /usr/lib/os-release
#======================================
# Configure Raspberry Pi specifics
# from: https://build.opensuse.org/package/view_file/openSUSE:Factory:ToTest/kiwi-templates-JeOS/config.sh
#--------------------------------------
if [[ "$kiwi_profiles" == *"Leap15.3.RaspberryPi4"* ]]; then
# Also show WLAN interfaces in /etc/issue
baseUpdateSysConfig /etc/sysconfig/issue-generator NETWORK_INTERFACE_REGEX '^[bew]'
# Add necessary kernel modules to initrd (will disappear with bsc#1084272)
echo 'add_drivers+=" bcm2835_dma dwc2 "' > /etc/dracut.conf.d/raspberrypi_modules.conf
# Work around network issues
# Use tabs, "<<-" strips tabs, but no other whitespace!
cat > /etc/modprobe.d/50-rpi3.conf <<-EOF
# Prevent too many page allocations (bsc#1012449)
options smsc95xx turbo_mode=N
EOF
# Use tabs, "<<-" strips tabs, but no other whitespace!
cat > /usr/lib/sysctl.d/50-rpi3.conf <<-EOF
# Avoid running out of DMA pages for smsc95xx (bsc#1012449)
vm.min_free_kbytes = 2048
EOF
fi
#======================================
# Apply grub config
# Setup Grub Distributor option
#--------------------------------------
echo >> /etc/default/grub
echo "# Set distributor for custom menu text" >> /etc/default/grub
echo 'GRUB_DISTRIBUTOR="Rockstor NAS"' >> /etc/default/grub
echo >> /etc/default/grub
exit 0