-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLIVE-ISO-CREATOR
More file actions
521 lines (442 loc) · 15 KB
/
LIVE-ISO-CREATOR
File metadata and controls
521 lines (442 loc) · 15 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
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
#!/bin/bash
# Nano ISO Creator - Minimal Live System ISO Builder
# Auto-chainloads from ISOLINUX to GRUB2 instantly
# Color codes
RED='\033[0;31m'
GREEN='\033[1;32m'
YELLOW='\033[1;35m'
BLUE='\033[1;35m'
NC='\033[0m'
# Install minimal dependencies
install_dependencies() {
local missing_deps=()
for cmd in xorriso wget lzma tar; do
if ! command -v "$cmd" &>/dev/null; then
missing_deps+=("$cmd")
fi
done
if [ ${#missing_deps[@]} -gt 0 ]; then
echo -e "${BLUE}Installing required packages: ${missing_deps[*]}${NC}"
if [ -x "$(command -v apt-get)" ]; then
sudo apt-get update && sudo apt-get install -y xorriso wget lzma tar
elif [ -x "$(command -v dnf)" ]; then
sudo dnf install -y xorriso wget lzma tar
elif [ -x "$(command -v pacman)" ]; then
sudo pacman -S --noconfirm xorriso wget lzma tar
else
echo -e "${RED}Error: Cannot install dependencies automatically${NC}"
exit 1
fi
fi
}
# Download hybrid bootfiles
download_bootfiles() {
local target_dir="$1"
local temp_dir="/tmp/nano_bootfiles_$$"
echo -e "${NC} ->${GREEN} Downloading Bootfiles${NC}"
mkdir -p "$temp_dir"
if ! wget --quiet \
"https://github.com/GlitchLinux/gLiTcH-ISO-Creator/raw/refs/heads/main/ISO-Hybrid-Base-2.tar.lzma" \
-O "$temp_dir/bootfiles.tar.lzma" 2>/dev/null; then
echo -e "${RED}Error: Failed to download bootfiles${NC}"
rm -rf "$temp_dir"
exit 1
fi
echo -e "${NC} ->${GREEN} Extracting bootfiles${NC}"
unlzma "$temp_dir/bootfiles.tar.lzma" 2>/dev/null
tar -xf "$temp_dir/bootfiles.tar" -C "$target_dir" --strip-components=1 2>/dev/null
rm -rf "$temp_dir"
chmod -R 755 "$target_dir" 2>/dev/null
}
# Create minimal GRUB config with proven theme approach
create_grub_config() {
local iso_dir="$1"
local name="$2"
local vmlinuz="$3"
local initrd="$4"
local live_dir="$5"
mkdir -p "$iso_dir/boot/grub"
# Copy splash.png to boot/grub directory
if [ -f "$iso_dir/isolinux/splash.png" ]; then
echo -e "${NC} ->${GREEN}Copying splash screen for GRUB ${NC}"
cp "/boot/grub/splash.png" "$iso_dir/boot/grub/splash.png" 2>/dev/null
cp "$iso_dir/isolinux/splash.png" "$iso_dir/isolinux/grub.png" 2>/dev/null
fi
# Create theme configuration
cat > "$iso_dir/boot/grub/theme.cfg" <<'EOF'
title-text: ""
title-font: "Sans Bold 28"
title-color: "#FFFFFF"
desktop-color: "#111111"
desktop-image: "/boot/grub/splash.png"
message-font: "Sans Regular 20"
message-color: "#FFFFFF"
message-bg-color: "#303030"
terminal-font: "Sans Regular 20"
+ boot_menu {
left = 10%
top = 20%
width = 70%
height = 80%
item_font = "DejaVu Sans Bold 14"
item_color = "grey"
item_height = 32
item_icon_space = 8
item_spacing = 2
selected_item_font = "DejaVu Sans Bold 14"
selected_item_color= "#ffffff"
# selected_item_pixmap_style = "select_*.png"
icon_height = 32
icon_width = 32
scrollbar = false
scrollbar_width = 20
scrollbar_thumb = "slider_*.png"
}
+ progress_bar {
id = "__timeout__"
left = 15%
top = 85%
height = 5
width = 70%
# font = "DejaVu Sans Regular 14"
# text_color = "#"
fg_color = "grey"
bg_color = "#303030"
border_color = "#303030"
# instead of the above colors, use pixmaps
# bar_style = "progress_bar_*.png"
# highlight_style = "progress_highlight_*.png"
# text = "@TIMEOUT_NOTIFICATION_LONG@"
}
# Footer information
+ vbox {
top = 95%
left = 2%
+ label {
text = ""
font = "DejaVu Sans Regular 14"
color = "#242424"
}
}
EOF
# Create main GRUB configuration using proven approach
cat > "$iso_dir/boot/grub/grub.cfg" <<EOF
# GRUB2 Configuration - Proven Theme Approach
# Font path and graphics setup
if loadfont \$prefix/fonts/font.pf2 ; then
set gfxmode=800x600
set gfxpayload=keep
insmod efi_gop
insmod efi_uga
insmod video_bochs
insmod video_cirrus
insmod gfxterm
insmod png
terminal_output gfxterm
fi
# Background and color setup
if background_image "/boot/grub/splash.png"; then
set color_normal=light-gray/black
set color_highlight=white/black
elif background_image "/splash.png"; then
set color_normal=light-gray/black
set color_highlight=white/black
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi
# Load theme if available
if [ -s \$prefix/theme.cfg ]; then
set theme=\$prefix/theme.cfg
fi
# Basic settings
set default=0
set timeout=10
# Live System Entries
EOF
if [ "$live_dir" = "casper" ]; then
# Ubuntu/Casper configuration
cat >> "$iso_dir/boot/grub/grub.cfg" <<EOF
menuentry "$name - LIVE" {
linux /casper/$vmlinuz boot=casper quiet splash
initrd /casper/$initrd
}
menuentry "$name - Boot to RAM" {
linux /casper/$vmlinuz boot=casper quiet splash toram
initrd /casper/$initrd
}
menuentry "$name - Encrypted Persistence" {
linux /casper/$vmlinuz boot=casper components quiet splash persistent=cryptsetup persistence-encryption=luks persistence
initrd /casper/$initrd
}
if [ -f /boot/grub/custom.cfg ]; then
menuentry "Custom Options" {
configfile /boot/grub/custom.cfg
}
fi
EOF
else
# Debian Live configuration
cat >> "$iso_dir/boot/grub/grub.cfg" <<EOF
menuentry "$name - LIVE" {
linux /live/$vmlinuz boot=live config quiet splash
initrd /live/$initrd
}
menuentry "$name - Boot to RAM" {
linux /live/$vmlinuz boot=live config quiet splash toram
initrd /live/$initrd
}
menuentry "$name - Encrypted Persistence" {
linux /live/$vmlinuz boot=live components quiet splash persistent=cryptsetup persistence-encryption=luks persistence
initrd /live/$initrd
}
menuentry "$name - Unencrypted Persistence" {
linux /live/$vmlinuz boot=live components quiet splash components quiet splash persistence
initrd /live/$initrd
}
if [ -f /boot/grub/custom.cfg ]; then
menuentry "Custom Options" {
configfile /boot/grub/custom.cfg
}
fi
EOF
fi
cat >> "$iso_dir/boot/grub/grub.cfg" <<'EOF'
EOF
#echo -e "${GREEN}Created GRUB configuration with proven theme approach${NC}"
}
# Create auto-chainloading ISOLINUX config
create_isolinux_config() {
local iso_dir="$1"
cat > "$iso_dir/isolinux/isolinux.cfg" <<'EOF'
default grub2_chainload
timeout 1
prompt 0
label grub2_chainload
linux /boot/grub/lnxboot.img
initrd /boot/grub/core.img
EOF
}
# Create autorun.inf
create_autorun() {
local iso_dir="$1"
local name="$2"
cat > "$iso_dir/autorun.inf" <<EOF
[Autorun]
icon=iso.ico
label=$name
EOF
}
# Create ISO
create_iso() {
local source_dir="$1"
local output_file="$2"
local volume_label="$3"
#clear
echo ""
echo -e "${GREEN} ╭─────────────────────────────────────────────╮${NC}"
echo -e "${GREEN} │${NC} You can now add custom files include in ISO ${GREEN}│${NC}"
echo -e "${GREEN} │${NC} press ENTER to complete the ISO build ${GREEN}│${NC}"
echo -e "${GREEN} ╰─────────────────────────────────────────────╯${NC}"
echo ""
read -p " "
#echo -e "${NC} -> ${NC}${GREEN} Output File:${NC} $output_file${NC}"
# Use isohdpfx.bin from bootfiles if available
local mbr_file="$source_dir/isolinux/isohdpfx.bin"
if [ ! -f "$mbr_file" ]; then
mbr_file="/usr/lib/ISOLINUX/isohdpfx.bin"
fi
xorriso -as mkisofs \
-iso-level 3 \
-volid "$volume_label" \
-full-iso9660-filenames \
-R -J -joliet-long \
-isohybrid-mbr "$mbr_file" \
-b isolinux/isolinux.bin \
-c isolinux/boot.cat \
-no-emul-boot \
-boot-load-size 4 \
-boot-info-table \
-eltorito-alt-boot \
-e boot/grub/efi.img \
-no-emul-boot \
-isohybrid-gpt-basdat \
-append_partition 2 0xEF "$source_dir/boot/grub/efi.img" \
-o "$output_file" \
"$source_dir" 2>/dev/null
if [ $? -eq 0 ]; then
local size=$(du -h "$output_file" | cut -f1)
echo -e "${NC} ${GREEN} ISO Created Successfully!${NC}${GREEN} ✅ ${NC}"
echo ""
echo -e "${NC} ${YELLOW} Path: ${NC}$output_file${NC}"
echo -e "${NC} ${YELLOW} Size: ${NC}$size${NC}"
#sleep 2
return 0
else
echo -e "${RED}❌ ISO creation failed${NC}"
return 1
fi
}
# Main creation function
create_live_iso() {
local parent_dir="$1"
# Validate parent directory
if [ ! -d "$parent_dir" ]; then
echo -e "${RED}Error: Directory not found: $parent_dir${NC}"
return 1
fi
# Auto-detect live system type and directory
local live_dir=""
local live_path=""
local system_type=""
# First determine which live system type we have
if [ -d "$parent_dir/live" ]; then
live_dir="live"
live_path="$parent_dir/live"
system_type="Debian Live"
elif [ -d "$parent_dir/casper" ]; then
live_dir="casper"
live_path="$parent_dir/casper"
system_type="Ubuntu/Casper"
else
echo -e "${RED}Error: No live system found in $parent_dir${NC}"
echo -e "${NC}Expected: $parent_dir/live or $parent_dir/casper${NC}"
return 1
fi
# Now find kernel and initrd files in the correct live path
local vmlinuz=""
local initrd=""
# Find vmlinuz (kernel) file
for file in "$live_path"/vmlinuz*; do
if [ -f "$file" ]; then
vmlinuz=$(basename "$file")
break
fi
done
# Find initrd file - handle different naming conventions
if [ "$live_dir" = "casper" ]; then
# Ubuntu/Casper: Look for initrd files
for file in "$live_path"/initrd* "$live_path"/initrd.img* "$live_path"/initramfs*; do
if [ -f "$file" ]; then
initrd=$(basename "$file")
break
fi
done
else
# Debian Live: Look for initrd files
for file in "$live_path"/initrd* "$live_path"/initramfs*; do
if [ -f "$file" ]; then
initrd=$(basename "$file")
break
fi
done
fi
# Verify we found both files
if [ -z "$vmlinuz" ] || [ -z "$initrd" ]; then
echo -e "${RED}Error: Missing kernel or initrd in $live_path${NC}"
echo -e "${YELLOW}Found files in $live_path:${NC}"
ls -la "$live_path"/ | grep -E 'vmlinuz|initrd|initramfs'
echo -e "${YELLOW}Expected: vmlinuz* and initrd*/initramfs* files${NC}"
return 1
fi
echo -e "${GREEN} Identified Bootfiles & Distro ${NC}"
echo ""
echo -e "${NC} $vmlinuz ${GREEN}✅${NC}"
echo -e "${NC} $initrd ${GREEN}✅${NC}"
echo -e "${NC} Distro: $system_type ${NC}${GREEN}✅${NC}"
# Get grandparent directory for output and customization
local grandparent_dir=$(dirname "$parent_dir")
local dir_name=$(basename "$parent_dir")
local customize_dir="$grandparent_dir/ISO_CUSTOMIZE"
# Get filenames from user
echo ""
echo -e "${GREEN} ISO Naming:${NC}"
echo ""
echo -e "${GREEN} ENTER${NC} to use ${YELLOW}\"${dir_name}.iso\"${NC} as iso name${NC}"
read -p " -> Or enter new name: " iso_name
echo ""
iso_name=${iso_name:-"${dir_name}.iso"}
[[ "$iso_name" != *.iso ]] && iso_name="${iso_name}.iso"
echo -e "${GREEN} ENTER${NC} to use ${YELLOW}\"${dir_name}\"${NC} as system name${NC}"
read -p " -> Or enter new name: " system_name
echo ""
system_name=${system_name:-"$dir_name"}
local volume_default=$(echo "$dir_name" | tr '[:lower:]' '[:upper:]' | tr -cd '[:alnum:]_-' | cut -c1-32)
echo -e "${GREEN} ENTER${NC} to use ${YELLOW}\"${volume_default}\"${NC} as volume name${NC}"
read -p " -> Or enter new name: " volume_name
echo ""
volume_name=${volume_name:-"$volume_default"}
volume_name=$(echo "$volume_name" | tr '[:lower:]' '[:upper:]' | tr -cd '[:alnum:]_-' | cut -c1-32)
echo ""
# Set output path in grandparent directory
local output_file="$grandparent_dir/$iso_name"
# Create working directory
rm -r -f /tmp/nano_iso/
local work_dir="/tmp/nano_iso"
mkdir -p "$work_dir"
clear
echo ""
echo -e "${NC} ${YELLOW} Starting ISO Build! ${NC}"
echo -e "${NC} ->${GREEN} Output File:${NC}${NC} $output_file${NC}"
# Copy entire parent directory structure
echo -e "${NC} ->${GREEN} Copying system files ${NC}"
cp -r "$parent_dir"/* "$work_dir/"
# Download and setup bootfiles
download_bootfiles "$work_dir"
# Create configurations
create_grub_config "$work_dir" "$system_name" "$vmlinuz" "$initrd" "$live_dir"
create_isolinux_config "$work_dir"
create_autorun "$work_dir" "$system_name"
# Create ISO
if create_iso "$work_dir" "$output_file" "$volume_name"; then
rm -rf "$work_dir"
return 0
else
rm -rf "$work_dir"
return 1
fi
}
# Main loop
main() {
echo ""
echo -e "${YELLOW} ╭──── gLiTcH ISO Compiler ────╮${NC}"
echo -e "${YELLOW} │${NC} BY: ${GREEN}https://glitchlinux.wtf${NC} ${YELLOW}│${NC}"
echo -e "${YELLOW} │${NC} BIOS & EFI live ISO builder ${YELLOW}│${NC}"
echo -e "${YELLOW} │${NC} grub2 syslinux chainloading ${YELLOW}│${NC}"
echo -e "${YELLOW} │${NC} For Debian & Ubuntu distros ${YELLOW}│${NC}"
echo -e "${YELLOW} ╰─────────────────────────────╯${NC}"
#echo ""
# Check dependencies
install_dependencies
while true; do
echo -e "${GREEN} ╭──────────────────────────╮ ${NC}"
echo -e "${GREEN} │${NC} Prepare: /mydistro/live/ ${GREEN}│${NC}"
echo -e "${GREEN} │${NC} live dir must contain -> ${GREEN}│${NC}"
echo -e "${GREEN} │${NC} initrd vmlinuz .squashfs ${GREEN}│${NC}"
echo -e "${GREEN} ╰──────────────────────────╯${NC}"
echo ""
echo -e "${GREEN} Enter parent dir of ${NC}live${NC}"
echo ""
read -p " -> " parent_dir
echo ""
if [ -z "$parent_dir" ]; then
echo -e "${YELLOW}Empty path. Exiting.${NC}"
break
fi
# Expand tilde and resolve path
parent_dir="${parent_dir/#\~/$HOME}"
parent_dir=$(realpath "$parent_dir" 2>/dev/null)
if create_live_iso "$parent_dir"; then
echo ""
else
echo -e "\n${RED} ISO project failed!${NC}"
fi
read -p " Create another ISO? (y/n): " continue_choice
if [[ ! "$continue_choice" =~ ^[Yy]$ ]]; then
echo -e "${GREEN}Thanks for using Nano ISO Creator!${NC}"
break
fi
done
}
# Run main function
main "$@"