forked from endeavouros-team/EndeavourOS-ISO
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathrun_before_squashfs.sh
More file actions
executable file
·166 lines (131 loc) · 5.6 KB
/
run_before_squashfs.sh
File metadata and controls
executable file
·166 lines (131 loc) · 5.6 KB
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
#!/usr/bin/env bash
# Made by Fernando "maroto"
# Run anything in the filesystem right before being "mksquashed"
# ISO-NEXT specific cleanup removals and additions (08-2021 + 10-2021) @killajoe and @manuel
# refining and changes november 2021 @killajoe and @manuel
script_path=$(readlink -f "${0%/*}")
work_dir="work"
# Adapted from AIS. An excellent bit of code!
# all path must be in quotation marks "path/to/file/or/folder" for now.
arch_chroot() {
arch-chroot "${script_path}/${work_dir}/x86_64/airootfs" /bin/bash -c "${1}"
}
do_merge() {
arch_chroot "$(cat << EOF
echo "##############################"
echo "# start chrooted commandlist #"
echo "##############################"
cd "/root"
echo "---> Init & Populate keys --->"
pacman-key --init
pacman-key --populate archlinux endeavouros
pacman -Syy
echo "---> backup bash configs from skel to replace after liveuser creation --->"
mkdir -p "/root/filebackups/"
cp -af "/etc/skel/"{".bashrc",".bash_profile"} "/root/filebackups/"
echo "---> Install liveuser skel (in case of conflicts use overwrite) --->"
pacman -U --noconfirm --overwrite "/etc/skel/.bash_profile","/etc/skel/.bashrc" -- "/root/endeavouros-skel-liveuser/"*".pkg.tar.zst"
echo "---> start validate skel files --->"
ls /etc/skel/.*
ls /etc/skel/
echo "---> end validate skel files --->"
echo "---> Prepare livesession settings and user --->"
sed -i 's/#\(en_US\.UTF-8\)/\1/' "/etc/locale.gen"
locale-gen
ln -sf "/usr/share/zoneinfo/UTC" "/etc/localtime"
echo "---> Set root permission and shell --->"
usermod -s /usr/bin/bash root
echo "---> Create liveuser --->"
useradd -m -p "" -g 'liveuser' -G 'sys,rfkill,wheel,uucp,nopasswdlogin,adm,tty' -s /bin/bash liveuser
cp "/root/liveuser.png" "/var/lib/AccountsService/icons/liveuser"
rm "/root/liveuser.png"
echo "---> Remove liveuser skel to clean for target skel --"
pacman -Sy
pacman -Rns --noconfirm -- "endeavouros-skel-liveuser"
rm -rf "/root/endeavouros-skel-liveuser"
echo "---> setup theming for root user --->"
cp -a "/root/root-theme" "/root/.config"
rm -R "/root/root-theme"
echo "---> Add builddate to motd --->"
cat "/usr/lib/endeavouros-release" >> "/etc/motd"
echo "------------------" >> "/etc/motd"
echo "---> Install locally built packages on ISO (place packages under airootfs/root/packages) --->"
echo "--> content of /root/packages:"
ls "/root/packages/"
echo "end of content of /root/packages. <---"
echo "---> generating actual ranked mirrorlist to fetch packages for offline install---> "
echo "---> back up original to replace later---> "
cp "/etc/pacman.d/mirrorlist" "/etc/pacman.d/mirrorlist.later"
mkdir -p "/etc/pacman.d/"
echo "---> generate mirrorlist safely ---> "
get_country() {
for url in \
"https://ipapi.co/country_code" \
"https://ifconfig.co/country-iso" \
"https://ipinfo.io/country"; do
code="$(curl -fs "$url" 2>/dev/null | grep -oE '^[A-Z]{2}$')"
[[ -n "$code" ]] && echo "$code" && return
done
}
COUNTRY="$(get_country)"
if [[ -n "$COUNTRY" ]]; then
reflector \
--country "$COUNTRY" \
--protocol "https" \
--sort "rate" \
--latest "10" \
--save "/etc/pacman.d/mirrorlist"
else
reflector \
--protocol "https" \
--sort "rate" \
--latest "20" \
--save "/etc/pacman.d/mirrorlist"
fi
echo "---> generate mirrorlist done ---> "
pacman -Sy
pacman -U --noconfirm --needed -- "/root/packages/"*".pkg.tar.zst"
rm -rf "/root/packages/"
echo "---> Enable systemd services in case needed --->"
echo " --> per default now in airootfs/etc/systemd/system/multi-user.target.wants"
#systemctl enable NetworkManager.service systemd-timesyncd.service bluetooth.service firewalld.service
#systemctl enable vboxservice.service vmtoolsd.service vmware-vmblock-fuse.service
#systemctl enable intel.service
systemctl set-default multi-user.target
echo "---> Set wallpaper for live-session and original for installed system --->"
mv "/root/endeavouros-wallpaper.png" "/etc/calamares/files/endeavouros-wallpaper.png"
mv "/root/livewall.png" "/usr/share/endeavouros/backgrounds/endeavouros-wallpaper.png"
chmod 644 "/usr/share/endeavouros/backgrounds/"*".png"
echo "---> install bash configs back into /etc/skel for offline install target --->"
cp -af "/root/filebackups/"{".bashrc",".bash_profile"} "/etc/skel/"
echo "---> remove blacklisting nouveau out of ISO (nvidia-utls blacklist configs) --->"
rm "/usr/lib/modprobe.d/nvidia-utils.conf"
rm "/usr/lib/modules-load.d/nvidia-utils.conf"
echo "---> get needed packages for offline installs --->"
mkdir -p "/usr/share/packages"
pacman -Syy
pacman -Sw --noconfirm --cachedir "/usr/share/packages" grub eos-dracut kernel-install-for-dracut os-prober xf86-video-intel nvidia-open nvidia-hook nvidia-utils nvidia-inst broadcom-wl
echo "---> Clean pacman log and package cache --->"
rm "/var/log/pacman.log"
# pacman -Scc seem to fail so:
rm -rf "/var/cache/pacman/pkg/"
echo "---> replace mirrorlist with original again --->"
mv /etc/pacman.d/mirrorlist.later /etc/pacman.d/mirrorlist
echo "---> create package versions file --->"
pacman -Qs | grep "/calamares " | cut -c7- > iso_package_versions
pacman -Qs | grep "/firefox " | cut -c7- >> iso_package_versions
pacman -Qs | grep "/linux " | cut -c7- >> iso_package_versions
pacman -Qs | grep "/mesa " | cut -c7- >> iso_package_versions
pacman -Qs | grep "/xorg-server " | cut -c7- >> iso_package_versions
pacman -Qs | grep "/nvidia-utils " | cut -c7- >> iso_package_versions
mv "iso_package_versions" "/home/liveuser/"
echo "############################"
echo "# end chrooted commandlist #"
echo "############################"
EOF
)"
}
#################################
########## STARTS HERE ##########
#################################
do_merge