summaryrefslogtreecommitdiff
path: root/backend/modules/install_configure
blob: c0eb95b91e69156da24e9fa7697c8c29dd6847ce (plain)
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/bin/bash

# Synopsis: configure_target_update_files
#
# This function is adapted from the Knoppix-Installer
function configure_target_update_files()
{
	send install_step configure_target_update_files
	# set up hostname
	cat <<EOF >$TARGET/etc/hosts
127.0.0.1	localhost
127.0.1.1	$cfg_hostname

# The following lines are desirable for IPv6 capable hosts
# (added automatically by netbase upgrade)

::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts
EOF
	echo "$cfg_hostname" > $TARGET/etc/hostname
	echo "$cfg_hostname" > $TARGET/etc/mailname
	
	# remove LiveCD-user from /etc/sudoers
	cat > "$TARGET/etc/sudoers" <<EOF
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#

Defaults	env_reset

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root	ALL=(ALL) ALL
EOF
	chown root:root "$TARGET/etc/sudoers"
	chmod 0440 "$TARGET/etc/sudoers"
	
	# "normalize" /etc/inittab
	rm -f "$TARGET/etc/inittab"
	sed 's/id\:[0-6]\:initdefault\:/id\:5\:initdefault\:/;s/\([1-6]:23\):/\145:/' "$TARGET/usr/share/sysvinit/inittab" > "$TARGET/etc/inittab"
	
	# create "real" /tmp with mode 1777
	rm -f $TARGET/tmp 2>/dev/null
	mkdir -p $TARGET/tmp
	chmod 1777 $TARGET/tmp
	
	# create file to mount efivars (needed since bullseye)
	cat <<EOF >$TARGET/tmp/fixmount
#!/bin/sh
modprobe efivarfs
mount -t efivarfs efivarfs /sys/firmware/efi/efivars
EOF
	chmod ugo+x $TARGET/tmp/fixmount

	# create /etc/mtab as a regular file
	rm -f $TARGET/etc/mtab
	touch $TARGET/etc/mtab

	# configure /etc/kernel-pkg.conf
	if [ -f "$TARGET/etc/kernel-pkg.conf" ]; then
		perl -pi -e "s/^maintainer.*\=.*/maintainer \:\= $cfg_realname/;s/^email.*\=.*/email \:\= $cfg_username\@$cfg_hostname\.local/" "$TARGET/etc/kernel-pkg.conf"
		NUMCPUS=$(grep -c "model name" /proc/cpuinfo)
		[ $NUMCPUS -ge 2 ] && echo CONCURRENCY_LEVEL := $NUMCPUS >> $TARGET/etc/kernel-pkg.conf
	fi
	
	# enable KDE sounds
	rm -f "$TARGET/home/$cfg_username/.kde/share/config/knotifyrc"
		
	# profile
	cat "$TARGET/usr/share/base-files/profile" > "$TARGET/etc/profile"
	
	# For us users use an us-mirror
	case "$LANGUAGE" in
		us*)
			#perl -pi -e "s/ftp2.de.debian.org/ftp.uk.debian.org/" $TARGET/etc/apt/sources.list
			:
		;;
	esac
	
	# install hooks
	if [ "$(ls $TARGET/usr/share/acritoxinstaller/target-config)" ]; then
		for hook in $TARGET/usr/share/acritoxinstaller/target-config/*
		do
			chroot_it "${hook#$TARGET}"
		done
	fi
	
	# install overlay
	if [ "$(ls $TARGET/usr/share/acritoxinstaller/target-overlay)" ]; then
		cp -a --target-directory=$TARGET $TARGET/usr/share/acritoxinstaller/target-overlay/*
	fi

	# add correct keymap
	[ -f /etc/sysconfig/keyboard ] && . /etc/sysconfig/keyboard

	[ -n "$KEYTABLE" ] && chroot_it install-keymap "$KEYTABLE" 2>/dev/null

        # remove live-repo from sources.list and delete key
        sed -i -e '/^# Live Media$/{N;\|\ndeb file:/live/image/debian |{N;/\n$/d}}' $TARGET/etc/apt/sources.list
        sed -i -e '/^# Live Media$/{N;\|\ndeb file:/run/live/medium/debian |{N;/\n$/d}}' $TARGET/etc/apt/sources.list
        sed -i -e '/^# Live Media$/{N;\|\ndeb \[signed-by=\/usr\/share\/keyrings\/live-media.gpg\] file:/run/live/medium/debian |{N;/\n$/d}}' $TARGET/etc/apt/sources.list
        rm -f $TARGET/etc/apt/trusted.gpg.d/live-media.asc $TARGET/usr/share/keyrings/live-media.gpg
        # remove acritoxinstaller-qt4 repo
        sed -i '/[Aa]critoxinstaller-qt4/d' $TARGET/etc/apt/sources.list
        # remove double empty lines
        sed -i 'N;/^\n$/D;P;D;'g $TARGET/etc/apt/sources.list
}

# Synopsis: configure_target_purge_live_only_stuff
#
# This function removes everything that is only useful on live-systems
function configure_target_purge_live_only_stuff()
{
	send install_step configure_target_purge_live_only_stuff
	# remove live-only-packages
	chroot_it dpkg --purge \
			acritoxinstaller \
			acritoxinstaller-icons \
			acritoxinstaller-kanotix \
			kanotix-enable-persistent-live \
			calamares \
			calamares-settings-kanotix \
			live-boot-initramfs-tools \
			live-boot \
			live-initramfs \
			live-build-cgi \
			live-build \
			live-helper \
			live-config-runit \
			live-config-sysvinit \
			live-config-upstart \
			live-config-systemd \
			live-config \
			live-magic \
			live-manual-epub \
			live-manual-html \
			live-manual-odf \
			live-manual-pdf \
			live-manual-txt \
			live-manual \
			gfxoverlay \
			zram	 	&> /dev/null

	# remove unused stuff
	chroot_it apt-get autoremove --purge --yes	&> /dev/null
	
	# execute above configured fix for efi (new since bullseye)
	if [ -d /sys/firmware/efi/efivars ]; then
	chroot_it /tmp/fixmount
	fi

        # remove kde-config-touchpad if no touchpad is available
        [ "$(su "$FLL_LIVE_USER" -c "qdbus org.kde.synaptiks /modules/synaptiks org.kde.Synaptiks.isTouchpadAvailable")" = true ] && \
                chroot_it dpkg --purge kde-config-touchpad
	
	#  disable live config
	[ -f "$TARGET/etc/default/distro" ] && \
		perl -pi -e "s/^FLL_DISTRO_MODE\=.*/FLL_DISTRO_MODE\=\"installed\"/" "$TARGET/etc/default/distro"
	
	# remove temporary kde- user files
	rm -f "$TARGET/home/$cfg_username/.DCOPserver_*_*"
	rm -f "$TARGET/home/$cfg_username/.kde/cache-*"
	rm -f "$TARGET/home/$cfg_username/.kde/socket-*"
	rm -f "$TARGET/home/$cfg_username/.kde/tmp-*"
	rm -f "$TARGET/home/$cfg_username/.*uthority"
	
	rm -rf "$TARGET/etc/sysconfig"
	rm -f "$TARGET/home/$cfg_username/Desktop/install-gui.desktop"

	# remove kdm live shutdown hack
	rm -f "$TARGET/home/$cfg_username/.kde/shutdown/kdm-force-shutdown-hack"

	# remove with live-boot created powermanagementprofilesrc ,will be automatically recreated at plasma5 session-startup
	rm -f "$TARGET/home/$cfg_username/.config/powermanagementprofilesrc"

        # remove live-only hooks
        rm -rf $TARGET/lib/live
        rm -f $TARGET/etc/profile.d/zz-live.sh
        rm -f $TARGET/usr/local/bin/enable_persistent_live.bash
	rm -f "$TARGET/home/$cfg_username/Desktop/enable_persistent.desktop"

	#remove appimage desktop files
	if [ -e /run/live/medium/appimages ]; then
	for appimages in /run/live/medium/appimages/*
	do
	appimage=$(basename $appimages)
	rm -f "$TARGET/home/$cfg_username/Desktop/$appimage.desktop"
	done
	fi
}