-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.sh
More file actions
210 lines (159 loc) · 6.57 KB
/
build.sh
File metadata and controls
210 lines (159 loc) · 6.57 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
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
204
205
206
207
208
#!/bin/bash
#===========================================
#Defining Variables
#===========================================
LOCALE="en_IN"
KEYMAP="in"
KEYMOD="pc104"
USERNAME="arch"
PASSWORD="arch"
ROOTPASSWORD="root"
HOSTNAME="ArchLinux"
#Functions
checkRoot () {
if [[ "$EUID" == 0 ]]; then
continue
else
echo "Run the file as root !"
sleep 2
exit
fi
}
errorHandle () {
clear
set -uo pipefail
trap 'Status Code=$?; echo "${0}: Error on line "${LINENO}: ${BASH_COMMAND}"; exit $s' ERR
}
cleanup () {
[[ -d ./ArchReleng ]] && rm -r ./ArchReleng
[[ -d ./work ]] && rm -r ./work
[[ -d ./out ]] && mv ./out ../
sleep 2
}
prerequisites () {
pacman -S --noconfirm archlinux-keyring
pacman -S --needed --noconfirm archiso mkinitcpio-archiso
}
copyArchReleng () {
cp -r /usr/share/archiso/configs/releng ./ArchReleng
rm -r ./ArchReleng/efiboot
rm -r ./ArchReleng/syslinux
}
copyXcalibRepo () {
cp -r ./opt/xcalibrepo /opt/
}
removeXcalibRepo () {
rm -r /opt/xcalibrepo
}
removeAutomaticLogin () {
[[ -d ./ArchReleng/airootfs/etc/systemd/system/getty@tty1.service.d ]] && rm -r ./ArchReleng/airootfs/etc/systemd/system/getty@tty1.service.d
}
addSLinks () {
[[ ! -d ./ArchReleng/airootfs/etc/systemd/system/bluetooth.target.wants ]] && mkdir -p ./ArchReleng/airootfs/etc/systemd/system/bluetooth.target.wants
[[ ! -d ./ArchReleng/airootfs/etc/systemd/system/network-online.target.wants ]] && mkdir -p ./ArchReleng/airootfs/etc/systemd/system/network-online.target.wants
[[ ! -d ./ArchReleng/airootfs/etc/systemd/system/multi-user.target.wants ]] && mkdir -p ./ArchReleng/airootfs/etc/systemd/system/multi-user.target.wants
[[ ! -d ./ArchReleng/airootfs/etc/systemd/system/printer.target.wants ]] && mkdir -p ./ArchReleng/airootfs/etc/systemd/system/printer.target.wants
[[ ! -d ./ArchReleng/airootfs/etc/systemd/system/sockets.target.wants ]] && mkdir -p ./ArchReleng/airootfs/etc/systemd/system/sockets.target.wants
[[ ! -d ./ArchReleng/airootfs/etc/systemd/system/sysinit.target.wants ]] && mkdir -p ./ArchReleng/airootfs/etc/systemd/system/sysinit.target.wants
[[ ! -d ./ArchReleng/airootfs/etc/systemd/system/timers.target.wants ]] && mkdir -p ./ArchReleng/airootfs/etc/systemd/system/timers.target.wants
ln -sf /usr/lib/systemd/system/bluetooth.service ./ArchReleng/airootfs/etc/systemd/system/bluetooth.target.wants/bluetooth.service
ln -sf /usr/lib/systemd/system/NetworkManager-wait-online.service ./ArchReleng/airootfs/etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service
ln -sf /usr/lib/systemd/system/NetworkManager.service ./ArchReleng/airootfs/etc/systemd/system/multi-user.target.wants/NetworkManager.service
ln -sf /usr/lib/systemd/system/vmtoolsd.service ./ArchReleng/airootfs/etc/systemd/system/multi-user.target.wants/vmtoolsd.service
ln -sf /usr/lib/systemd/system/vmware-vmblock-fuse.service ./ArchReleng/airootfs/etc/systemd/system/multi-user.target.wants/vmware-vmblock-fuse.service
ln -sf /usr/lib/systemd/system/NetworkManager-dispatcher.service ./ArchReleng/airootfs/etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service
ln -sf /usr/lib/systemd/system/bluetooth.service ./ArchReleng/airootfs/etc/systemd/system/dbus-org.bluez.service
ln -sf /usr/lib/systemd/system/sddm.service ./ArchReleng/airootfs/etc/systemd/system/display-manager.service
ln -sf /usr/lib/systemd/system/haveged.service ./ArchReleng/airootfs/etc/systemd/system/sysinit.target.wants/haveged.service
ln -sf /usr/lib/systemd/system/cups.service ./ArchReleng/airootfs/etc/systemd/system/printer.target.wants/cups.service
ln -sf /usr/lib/systemd/system/cups.socket ./ArchReleng/airootfs/etc/systemd/system/sockets.target.wants/cups.socket
ln -sf /usr/lib/systemd/system/cups.path ./ArchReleng/airootfs/etc/systemd/system/multi-user.target.wants/cups.path
ln -sf /usr/lib/systemd/system/pamac-cleancache.timer ./ArchReleng/airootfs/etc/systemd/system/timers.target.wants/pamac-cleancache.timer
ln -sf /usr/lib/systemd/system/pamac-mirrorlist.timer ./ArchReleng/airootfs/etc/systemd/system/timers.target.wants/pamac-mirrorlist.timer
}
copyCustomFiles () {
cp packages.x86_64 ./ArchReleng
cp pacman.conf ./ArchReleng
cp profiledef.sh ./ArchReleng
cp -r efiboot ./ArchReleng
cp -r syslinux ./ArchReleng
cp -r usr ./ArchReleng/airootfs
cp -r etc ./ArchReleng/airootfs
cp -r opt ./ArchReleng/airootfs
cp -r root ./ArchReleng/airootfs
}
setHostName () {
echo "${HOSTNAME}" > ./ArchReleng/airootfs/etc/hostname
}
createPasswordFile () {
echo "root:x:0:0:root:/root:/usr/bin/zsh
"${USERNAME}":x:1000:1000::/home/"${USERNAME}":/bin/zsh" > ./ArchReleng/airootfs/etc/passwd
}
createGroupFile () {
echo "root:x:0:root
sys:x:3:"${USERNAME}"
adm:x:4:"${USERNAME}"
wheel:x:10:"${USERNAME}"
log:x:19:"${USERNAME}"
network:x:90:"${USERNAME}"
floppy:x:94:"${USERNAME}"
scanner:x:96:"${USERNAME}"
power:x:98:"${USERNAME}"
rfkill:x:850:"${USERNAME}"
users:x:985:"${USERNAME}"
video:x:860:"${USERNAME}"
storage:x:870:"${USERNAME}"
optical:x:880:"${USERNAME}"
lp:x:840:"${USERNAME}"
audio:x:890:"${USERNAME}"
"${USERNAME}":x:1000:" > ./ArchReleng/airootfs/etc/group
}
createShadow () {
userPasswordHash=$(openssl passwd -6 "${PASSWORD}")
rootPasswordHash=$(openssl passwd -6 "${ROOTPASSWORD}")
echo "root:"${rootPasswordHash}":14871::::::
"${USERNAME}":"${userPasswordHash}":14871::::::" > ./ArchReleng/airootfs/etc/shadow
}
createGShadow () {
echo "root:!*::root
"${USERNAME}":!*::" > ./ArchReleng/airootfs/etc/gshadow
}
setKeyLayout () {
echo "KEYMAP="${KEYMAP}"" > ./ArchReleng/airootfs/etc/vconsole.conf
}
createKeyboard () {
mkdir -p ./ArchReleng/airootfs/etc/X11/xorg.conf.d
echo "Section \"InputClass\"
Identifier \"system-keyboard\"
MatchIsKeyboard \"on\"
Option \"XkbLayout\" \""${KEYMAP}"\"
Option \"XkbVariant\" \""${KEYMOD}"\"
EndSection" > ./ArchReleng/airootfs/etc/X11/xorg.conf.d/00-keyboard.conf
}
# Fix 40-locale-gen.hook and create locale.conf
createLocalec () {
sed -i "s/en_US/"${LOCALE}"/g" ./ArchReleng/airootfs/etc/pacman.d/hooks/40-locale-gen.hook
}
runMkArchIso () {
mkarchiso -v -w ./work -o ./out ./ArchReleng --f
}
#Run The Functions
checkRoot
errorHandle
prerequisites
cleanup
copyArchReleng
addSLinks
copyXcalibRepo
removeAutomaticLogin
copyCustomFiles
setHostName
createPasswordFile
createGroupFile
createShadow
createGShadow
setKeyLayout
createKeyboard
createLocalec
runMkArchIso
removeXcalibRepo