-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathconfigure.sh
More file actions
executable file
·461 lines (383 loc) · 13.2 KB
/
configure.sh
File metadata and controls
executable file
·461 lines (383 loc) · 13.2 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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
#!/bin/bash
# CodeVerse Linux Installer - Configure Module
# System configuration functions
# Configure the installed system
configure_system() {
step_header "Configuring System"
local tasks=(
"Setting timezone"
"Generating locales"
"Setting hostname"
"Enabling services"
"Installing bootloader"
"Creating user account"
"Setting up shell"
"Configuring desktop"
)
local total=${#tasks[@]}
# Copy CVH packages and configure repos
copy_cvh_packages
create_mirrorlist
configure_pacman_repos
# Copy skel configs from live ISO to installed system
copy_skel_configs
# Write the chroot configuration script
write_chroot_script
chmod +x /mnt/root/configure.sh
# Verify script was created
if [[ ! -f /mnt/root/configure.sh ]]; then
gum style --foreground 196 " ✗ Failed to create configuration script!"
exit 1
fi
# Run configuration with progress
for ((i=0; i<total; i++)); do
gum spin --spinner dot --title "${tasks[$i]}..." -- sleep 0.5
done
gum style --foreground 6 " ● Running system configuration..."
arch-chroot /mnt /bin/bash /root/configure.sh
rm -f /mnt/root/configure.sh
# Install GRUB bootloader
install_grub
gum style --foreground 82 " ✓ System configured"
}
# Copy skel configs from live ISO to installed system
copy_skel_configs() {
gum style --foreground 6 " ● Copying configuration files from ISO..."
# The live ISO's /etc/skel contains all the setup configs synced during ISO build
# Copy them to the installed system's /etc/skel so the chroot script can use them
if [[ -d /etc/skel/.config ]]; then
mkdir -p /mnt/etc/skel/.config
cp -r /etc/skel/.config/* /mnt/etc/skel/.config/ 2>/dev/null || true
gum style --foreground 82 " ✓ Config files copied (.config)"
fi
# Copy icons
if [[ -d /etc/skel/.icons ]]; then
mkdir -p /mnt/etc/skel/.icons
cp -r /etc/skel/.icons/* /mnt/etc/skel/.icons/ 2>/dev/null || true
gum style --foreground 82 " ✓ Icons copied"
fi
# Copy themes
if [[ -d /etc/skel/.themes ]]; then
mkdir -p /mnt/etc/skel/.themes
cp -r /etc/skel/.themes/* /mnt/etc/skel/.themes/ 2>/dev/null || true
gum style --foreground 82 " ✓ Themes copied"
fi
}
# Write the chroot configuration script
write_chroot_script() {
# Write base configuration
cat > /mnt/root/configure.sh << CONFIGURE_SCRIPT
#!/bin/bash
# Don't use set -e as some commands may fail non-fatally
# Timezone
ln -sf /usr/share/zoneinfo/$TIMEZONE /etc/localtime
hwclock --systohc
# Locale
echo "$LOCALE UTF-8" > /etc/locale.gen
locale-gen >/dev/null 2>&1
echo "LANG=$LOCALE" > /etc/locale.conf
# Keymap
echo "KEYMAP=$KEYMAP" > /etc/vconsole.conf
# Hostname
echo "$HOSTNAME" > /etc/hostname
cat > /etc/hosts << EOF
127.0.0.1 localhost
::1 localhost
127.0.1.1 $HOSTNAME.localdomain $HOSTNAME
EOF
# Configure Ly display manager
mkdir -p /etc/ly
cat > /etc/ly/config.ini << 'LY_EOF'
# CodeVerse Linux Ly Configuration
# Disable the doom-fire background animation
animate = false
# Clean minimal appearance
hide_borders = true
# Run on tty1 (default boot experience)
tty = 1
waylandsessions = /usr/share/wayland-sessions
# Save last session and user
save = true
save_file = /var/cache/ly/save
# Clear password on wrong input
clear_password = true
LY_EOF
mkdir -p /var/cache/ly
chmod 777 /var/cache/ly
# Enable services
systemctl enable NetworkManager >/dev/null 2>&1
systemctl enable systemd-timesyncd >/dev/null 2>&1
systemctl enable seatd >/dev/null 2>&1
# Disable getty on tty1 to prevent conflict with Ly
systemctl disable [email protected] >/dev/null 2>&1
# Enable Ly display manager on tty1
systemctl enable [email protected] >/dev/null 2>&1
# Install CVH custom packages from local cache
echo "Installing CVH custom packages..."
if ls /var/cache/pacman/cvh-packages/*.pkg.tar.zst >/dev/null 2>&1; then
pacman -U --noconfirm /var/cache/pacman/cvh-packages/*.pkg.tar.zst >/dev/null 2>&1 || true
# Verify installation
echo "Verifying CVH packages:"
for pkg in cvh-fuzzy cvh-icons cvh-branding mpvpaper; do
if pacman -Q \$pkg >/dev/null 2>&1; then
echo " ✓ \$pkg installed"
else
echo " ✗ \$pkg not installed (optional)"
fi
done
else
echo " ⚠ CVH packages not found, skipping"
fi
# Create os-release for proper branding (GRUB uses this)
cat > /etc/os-release << EOF
NAME="CodeVerse Linux"
PRETTY_NAME="CodeVerse Linux"
ID=cvh
ID_LIKE=arch
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
HOME_URL="https://cvhlinux.org"
DOCUMENTATION_URL="https://wiki.cvhlinux.org"
LOGO=cvh-logo
EOF
# Set GRUB distributor name
sed -i 's/^GRUB_DISTRIBUTOR=.*/GRUB_DISTRIBUTOR="CodeVerse Linux"/' /etc/default/grub 2>/dev/null || \
echo 'GRUB_DISTRIBUTOR="CodeVerse Linux"' >> /etc/default/grub
# Install Tela GRUB theme
if [[ -d /usr/share/cvh-linux/grub-theme/tela ]]; then
echo "Installing GRUB theme..."
mkdir -p /boot/grub/themes
cp -r /usr/share/cvh-linux/grub-theme/tela /boot/grub/themes/
# Configure GRUB to use the theme
sed -i 's|^#*GRUB_THEME=.*|GRUB_THEME="/boot/grub/themes/tela/theme.txt"|' /etc/default/grub 2>/dev/null
grep -q '^GRUB_THEME=' /etc/default/grub || \
echo 'GRUB_THEME="/boot/grub/themes/tela/theme.txt"' >> /etc/default/grub
echo " ✓ GRUB theme installed"
else
echo " ⚠ GRUB theme not found, skipping"
fi
# Ensure zsh is in /etc/shells
echo "/usr/bin/zsh" >> /etc/shells
echo "/bin/zsh" >> /etc/shells
# Create seat group if it doesn't exist (for seatd)
getent group seat >/dev/null || groupadd seat
# Create user
useradd -m -G wheel,audio,video,input,seat -s /usr/bin/zsh $USERNAME
# Force set shell using usermod (more reliable than chsh)
usermod -s /usr/bin/zsh $USERNAME
# Also set root's shell to zsh
usermod -s /usr/bin/zsh root
# Verify shell was set
echo "User shell set to: \$(getent passwd $USERNAME | cut -d: -f7)"
echo "Root shell set to: \$(getent passwd root | cut -d: -f7)"
# Configure sudo
echo "%wheel ALL=(ALL:ALL) ALL" > /etc/sudoers.d/wheel
chmod 440 /etc/sudoers.d/wheel
# Set up Oh My Zsh
su - $USERNAME -c 'git clone --depth=1 https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh 2>/dev/null' || true
su - $USERNAME -c 'cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc 2>/dev/null' || true
# Copy all config directories from /etc/skel to user home
echo "Setting up user configurations..."
if [[ -d /etc/skel/.config ]]; then
mkdir -p /home/$USERNAME/.config
cp -r /etc/skel/.config/* /home/$USERNAME/.config/ 2>/dev/null || true
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config
echo " ✓ Config directories copied"
fi
# Copy icons from /etc/skel
if [[ -d /etc/skel/.icons ]]; then
mkdir -p /home/$USERNAME/.icons
cp -r /etc/skel/.icons/* /home/$USERNAME/.icons/ 2>/dev/null || true
chown -R $USERNAME:$USERNAME /home/$USERNAME/.icons
echo " ✓ Icons copied"
fi
# Copy themes from /etc/skel
if [[ -d /etc/skel/.themes ]]; then
mkdir -p /home/$USERNAME/.themes
cp -r /etc/skel/.themes/* /home/$USERNAME/.themes/ 2>/dev/null || true
chown -R $USERNAME:$USERNAME /home/$USERNAME/.themes
echo " ✓ Themes copied"
fi
# Make niri scripts executable
chmod +x /home/$USERNAME/.config/niri/scripts/*.sh 2>/dev/null || true
# Make rofi scripts executable
chmod +x /home/$USERNAME/.config/rofi/scripts/*.sh 2>/dev/null || true
# Create Wayland session file for Ly display manager
mkdir -p /usr/share/wayland-sessions
cat > /usr/share/wayland-sessions/niri.desktop << 'SESSION_EOF'
[Desktop Entry]
Name=Niri
Comment=Scrollable-tiling Wayland compositor
Exec=niri-session
Type=Application
SESSION_EOF
# Create .zshrc
cat > /home/$USERNAME/.zshrc << 'ZSHRC_EOF'
export ZSH="\$HOME/.oh-my-zsh"
ZSH_THEME="robbyrussell"
plugins=(git sudo history)
[[ -f \$ZSH/oh-my-zsh.sh ]] && source \$ZSH/oh-my-zsh.sh
export EDITOR="nano"
export QT_QPA_PLATFORM="wayland"
export MOZ_ENABLE_WAYLAND="1"
# ZSH History Configuration
export HISTFILE="\$HOME/.zsh_history"
export HISTSIZE=10000
export SAVEHIST=10000
setopt APPEND_HISTORY
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
setopt HIST_IGNORE_ALL_DUPS
setopt HIST_REDUCE_BLANKS
setopt HIST_SAVE_NO_DUPS
setopt INC_APPEND_HISTORY
alias ls='ls --color=auto'
alias ll='ls -la'
# Fallback compositor auto-start on tty2+ (Ly runs on tty1)
# This triggers if user switches to another TTY or Ly is not running
if [[ -z "\$WAYLAND_DISPLAY" ]] && [[ "\$XDG_VTNR" -ne 1 ]]; then
exec COMPOSITOR_SESSION
fi
ZSHRC_EOF
# Create initial history file with proper permissions
su - $USERNAME -c 'touch ~/.zsh_history'
su - $USERNAME -c 'chmod 600 ~/.zsh_history'
# Set niri session in zshrc
sed -i 's/COMPOSITOR_SESSION/niri-session/g' /home/$USERNAME/.zshrc
chown $USERNAME:$USERNAME /home/$USERNAME/.zshrc
# Create fastfetch config with custom ASCII art support
su - $USERNAME -c 'mkdir -p ~/.config/fastfetch'
cat > /home/$USERNAME/.config/fastfetch/config.jsonc << 'FASTFETCH_EOF'
{
"\$schema": "https://github.com/fastfetch-cli/fastfetch/raw/dev/doc/json_schema.json",
"logo": {
"type": "file",
"source": "~/.config/fastfetch/ascii_art.txt",
"color": {
"1": "cyan",
"2": "blue",
"3": "white"
}
},
"display": {
"separator": " -> ",
"color": {
"separator": "blue"
}
},
"modules": [
{
"type": "title",
"format": "{user-name}@{host-name}"
},
{
"type": "separator",
"string": "─────────────────────────────"
},
{
"type": "os",
"key": "OS",
"format": "{3}"
},
{
"type": "kernel",
"key": "Kernel"
},
{
"type": "packages",
"key": "Packages"
},
{
"type": "shell",
"key": "Shell"
},
{
"type": "display",
"key": "Display (WM)"
},
{
"type": "terminal",
"key": "Terminal"
},
{
"type": "cpu",
"key": "CPU"
},
{
"type": "gpu",
"key": "GPU"
},
{
"type": "memory",
"key": "Memory"
},
{
"type": "uptime",
"key": "Uptime"
},
{
"type": "colors",
"symbol": "circle"
}
]
}
FASTFETCH_EOF
# Create custom ASCII art template
cat > /home/$USERNAME/.config/fastfetch/ascii_art.txt << 'ASCII_EOF'
██████╗██╗ ██╗██╗ ██╗ ██╗ ██╗███╗ ██╗██╗ ██╗██╗ ██╗
██╔════╝██║ ██║██║ ██║ ██║ ██║████╗ ██║██║ ██║╚██╗██╔╝
██║ ██║ ██║███████║ ██║ ██║██╔██╗ ██║██║ ██║ ╚███╔╝
██║ ╚██╗ ██╔╝██╔══██║ ██║ ██║██║╚██╗██║██║ ██║ ██╔██╗
╚██████╗ ╚████╔╝ ██║ ██║ ███████╗██║██║ ╚████║╚██████╔╝██╔╝ ██╗
╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚══════╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚═╝ ╚═╝
CodeVerse Hub Linux
ASCII_EOF
# Create instructions file for custom ASCII art
cat > /home/$USERNAME/.config/fastfetch/README.md << 'README_EOF'
# Fastfetch Custom ASCII Art
## Using Your Own ASCII Art
To use custom ASCII art with fastfetch:
1. Edit \`ascii_art.txt\` with your custom ASCII art
2. Update \`config.jsonc\` to use your custom art:
Replace the \`logo\` section with:
\`\`\`json
"logo": {
"type": "file",
"source": "~/.config/fastfetch/ascii_art.txt",
"color": {
"1": "cyan",
"2": "blue",
"3": "white"
}
}
\`\`\`
## Color Options
Available colors: black, red, green, yellow, blue, magenta, cyan, white
## Built-in Logos
To use a built-in logo instead, change \`source\` to:
- \`arch_small\` - Small Arch logo (default)
- \`arch\` - Full Arch logo
- \`linux\` - Generic Linux logo
- \`none\` - No logo
## Run Fastfetch
Simply type:
\`\`\`bash
fastfetch
\`\`\`
Or add it to your \`.zshrc\` to run on terminal startup.
README_EOF
chown -R $USERNAME:$USERNAME /home/$USERNAME/.config/fastfetch
chown $USERNAME:$USERNAME /home/$USERNAME/.zshrc
CONFIGURE_SCRIPT
}
# Install GRUB bootloader
install_grub() {
gum style --foreground 6 " ● Installing GRUB bootloader..."
if [[ "$BOOT_MODE" == "uefi" ]]; then
arch-chroot /mnt grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=CVH
else
arch-chroot /mnt grub-install --target=i386-pc "$DISK"
fi
gum style --foreground 6 " ● Generating GRUB config..."
arch-chroot /mnt grub-mkconfig -o /boot/grub/grub.cfg
}