Ich habe einmal ein kleines Bash-Skript geschrieben, das eine Arch Linux-ISO verwendet und eine neue ISO mit einem modifizierten Root-Image generiert, die eine vollautomatische Installation durchführt. Dies umfasst das Partitionieren sowie das Einrichten und Konfigurieren des Systems mit Xorg, FVWM und Chromium. Das installierte System meldet sich automatisch an und startet Chromium. Legen Sie einfach die neue ISO auf einen USB-Stick und lehnen Sie sich zurück. ;-)
Haftungsausschluss: Das Skript wird ohne Gewähr zur Verfügung gestellt. Ich habe es eine Weile nicht mehr benutzt, daher könnte es hier oder da eine Optimierung erfordern. Ändern Sie nach Bedarf.
#!/bin/bash
# Helpful pages:
#
# * [ArchWiki topic][1] that explains the options of an AIF configuration
# file.
#
# * [Status of automated installation][2], a topic in the Arch Linux Forums
# that contains the original basic install script by *mhertz*.
#
# [1]: https://wiki.archlinux.org/index.php/AIF_Configuration_File
# [2]: https://bbs.archlinux.org/viewtopic.php?id=111925
TMP_DIR=/tmp/arch-install
# Read command line parameters for input and output ISO files.
if [ -z "$1" ]; then
echo 'No input file specified, aborting.'
exit 1
elif [ ! -f "$1" ]; then
echo 'Input file "'$INPUT_ISO'" not found, aborting.'
exit 1
elif [ -z "$2" ]; then
echo 'No output file specified, aborting.'
exit 1
elif [ -f "$2" ]; then
echo 'Output file "'$OUTPUT_ISO'" already exists, aborting.'
exit 1
fi
# Determine full paths to input and output ISO files.
INPUT_ISO=$(readlink -f "$1")
OUTPUT_ISO=$(readlink -f "$2")
# Set some variables for convenience.
SOURCE_DIR=$TMP_DIR/source
DEST_DIR=$TMP_DIR/dest
ROOT_DIR=$TMP_DIR/squashfs-root
BOOT_CFG=$DEST_DIR/boot/isolinux/isolinux.cfg
# Extract ISO image and root image.
mkdir -p $SOURCE_DIR
mount -o loop "$INPUT_ISO" $SOURCE_DIR
cp -a $SOURCE_DIR $DEST_DIR
umount $SOURCE_DIR
rmdir $SOURCE_DIR
unsquashfs -d $ROOT_DIR $DEST_DIR/root-image.sqfs
rm $DEST_DIR/root-image.sqfs
# Modify the root image as needed.
cat >> $ROOT_DIR/etc/aif.conf <<EOF
SOURCE=cd
FILE_URL=file:///src/core/pkg
SYNC_URL=http://ftp.tu-chemnitz.de/pub/linux/archlinux/\$repo/os/\$arch
HARDWARECLOCK=UpTC
TIMEZONE=Europe/Vienna
RUNTIME_REPOSITORIES=
RUNTIME_PACKAGES=
TARGET_GROUPS=base
TARGET_PACKAGES_EXCLUDE=
TARGET_PACKAGES='openssh xorg xcursor-vanilla-dmz-aa'
worker_runtime_network () {
dhcpcd eth0
}
worker_configure_system () {
prefill_configs
sed -i '/^HOSTNAME/ s/"myhost"/"arch"/' \$var_TARGET_DIR/etc/rc.conf
sed -i '/^password/ s/pam_permit\.so/pam_unix.so md5 shadow/' \$var_TARGET_DIR/etc/pam.d/chpasswd
sed -i '\|Server = http://ftp\.tu-chemnitz\.de/| s/^#//' \$var_TARGET_DIR/etc/pacman.d/mirrorlist
sed -i '/id:3:initdefault:/ s/^/#/' \$var_TARGET_DIR/etc/inittab
sed -i '/id:5:initdefault:/ s/^#//' \$var_TARGET_DIR/etc/inittab
sed -i '\|x:5:respawn:/usr/bin/xdm| s/^/#/' \$var_TARGET_DIR/etc/inittab
echo "x:5:respawn:/bin/su -l -c '/usr/bin/startx </dev/null >/dev/null 2>&1' myuser" >> \$var_TARGET_DIR/etc/inittab
sed -i 's/^timeout .*$/timeout 0/' \$var_TARGET_DIR/boot/grub/menu.lst
cp /etc/rc.local.firstboot \$var_TARGET_DIR/etc/rc.local
}
# Mandatory variables.
GRUB_DEVICE=/dev/sda
PARTITIONS='/dev/sda 20:ext2:+ 512:swap 2500:xfs *:xfs'
BLOCKDATA='/dev/sda1 raw no_label ext2;yes;/boot;target;no_opts;no_label;no_params
/dev/sda2 raw no_label swap;yes;no_mountpoint;target;no_opts;no_label;no_params
/dev/sda3 raw no_label xfs;yes;/;target;no_opts;no_label;no_params
/dev/sda4 raw no_label xfs;yes;/home;target;no_opts;no_label;no_params'
EOF
cat >> $ROOT_DIR/etc/rc.local <<EOF
aif -p automatic -c /etc/aif.conf
reboot
EOF
cat >> $ROOT_DIR/etc/rc.local.firstboot <<EOF
echo root:rootpassword | chpasswd
useradd -m myuser
echo myuser:myuser | chpasswd
cat >> /home/myuser/.xinitrc <<EOT
#!/bin/sh
exec fvwm2
EOT
cat >> /home/myuser/.Xdefaults <<EOT
Xcursor.theme: Vanilla-DMZ-AA
EOT
mkdir -p /home/myuser/.fvwm
cat >> /home/myuser/.fvwm/config <<EOT
DeskTopSize 1x1
DesktopName 0 Main
DestroyFunc StartFunction
AddToFunc StartFunction
+ I Test (Init) Exec exec xsetroot -solid '#303030'
+ I Test (Init) Exec exec chromium 'http://www.stackoverflow.com'
DestroyMenu RootMenu
AddToMenu RootMenu "Menu" Title
+ "Terminal" Exec exec xterm
+ "Browser" Exec exec chromium 'https://www.stackoverflow.com'
+ "" Nop
+ "Log off" Quit
+ "Reboot" Exec exec sudo /sbin/reboot
+ "Shutdown" Exec exec sudo /sbin/halt
OpaqueMoveSize unlimited
Style * ClickToFocus, ResizeOpaque
Style chromium !Title, !Border, !Handles
CursorStyle root top_left_arrow
CursorStyle stroke hand2
IgnoreModifiers L25
Key Help R A -
Key F1 R A -
Key Tab A M -
Key Escape A MC -
Mouse 1 R A -
Mouse 1 T A Move
Mouse 1 FS A Resize
Mouse 1 I A Iconify Off
Mouse 2 FST A -
Mouse 3 R A Menu RootMenu Nop
EOT
mkdir -p /home/myuser/.config/chromium/Default
touch /home/myuser/.config/chromium/First\ Run
cat >> /home/myuser/.config/chromium/Default/Preferences <<EOT
{
"alternate_error_pages": {
"enabled": false
},
"autofill": {
"enabled": false
},
"browser": {
"custom_chrome_frame": true,
"enable_spellchecking": false
},
"default_search_provider": {
"enabled": true,
"encodings": "UTF-8",
"icon_url": "about:blank",
"id": "2",
"instant_url": "",
"keyword": "google.com",
"name": "Google",
"prepopulate_id": "1",
"search_url": "{google:baseURL}search?ie={inputEncoding}&q={searchTerms}",
"suggest_url": ""
},
"devtools": {
"disabled": true
},
"dns_prefetching": {
"enabled": false
},
"download": {
"directory_upgrade": true
},
"extensions": {
"chrome_url_overrides": {
"bookmarks": [ "chrome-extension://eemcgdkfndhakfknompkggombfjjjeno/main.html" ]
}
},
"geolocation": {
"default_content_setting": 2
},
"google": {
"services": {
"username": ""
}
},
"homepage": "https://www.stackoverflow.com",
"homepage_is_newtabpage": false,
"intl": {
"accept_languages": "en",
"charset_default": "ISO-8859-1"
},
"ntp": {
"pref_version": 3
},
"profile": {
"clear_site_data_on_exit": true,
"content_settings": {
"pref_version": 1
},
"default_content_settings": {
"plugins": 1
},
"exited_cleanly": true,
"notifications_default_content_setting": 2,
"password_manager_enabled": false
},
"safebrowsing": {
"enabled": false
},
"search": {
"suggest_enabled": false
},
"tabs": {
"use_vertical_tabs": false
},
"translate": {
"enabled": false
}
}
EOT
chown -R myuser:myuser /home/myuser
pacman -Sy
pacman -S --noconfirm pacman
pacman -S --noconfirm fvwm-devel chromium sudo
echo 'myuser arch=NOPASSWD: /sbin/halt,/sbin/reboot' > /etc/sudoers.d/start_stop
chmod 0440 /etc/sudoers.d/start_stop
rm /etc/rc.local
EOF
# Create the new root image.
mksquashfs $TMP_DIR/squashfs-root $TMP_DIR/dest/root-image.sqfs
rm -rf $TMP_DIR/squashfs-root
# Configure the boot loader.
sed -i 's/TIMEOUT 3000/TIMEOUT 100/' $BOOT_CFG
sed -i '/APPEND hd0 0/d' $BOOT_CFG
sed -i 's/archisolabel=[^ ]*/archisolabel=ARCH/' $BOOT_CFG
# Create the new ISO image.
genisoimage -l -R -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table -V ARCH \
-o "$OUTPUT_ISO" $DEST_DIR
rm -rf $TMP_DIR
isohybrid "$OUTPUT_ISO"