summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorxengineering <mail2xengineering@protonmail.com>2020-03-22 14:10:42 +0100
committerxengineering <mail2xengineering@protonmail.com>2020-03-22 14:10:42 +0100
commit54861b025565f527a35ee0628365bf62769577d0 (patch)
tree595f6f717f4a30b7063c8bdca6bcadfbe5397496
parent430b6099046f6a2cfb09caf14c1e8e47ec9d0cfc (diff)
downloadarchinstall-54861b025565f527a35ee0628365bf62769577d0.tar
archinstall-54861b025565f527a35ee0628365bf62769577d0.tar.zst
archinstall-54861b025565f527a35ee0628365bf62769577d0.zip
First complete Version of Rewrite
-rw-r--r--README.md20
-rw-r--r--archinstall.sh8
-rw-r--r--stages/first_stage.sh12
-rw-r--r--stages/second_stage.sh67
4 files changed, 77 insertions, 30 deletions
diff --git a/README.md b/README.md
index 13fccb1..b078fee 100644
--- a/README.md
+++ b/README.md
@@ -10,29 +10,22 @@ Note: There are many Arch Install scripts out there but I wanted to create my ow
## Usage
1. Download the Arch Linux .iso file (maybe [here](http://ftp.halifax.rwth-aachen.de/archlinux/iso/latest/)) and verify it.
-2. Write the .iso to an USB stick (maybe with this [tool](https://www.balena.io/etcher/)) and boot the machine from this USB stick.
-3. Download the script with 'curl -L archinstall.xengineering.eu > archinstall.sh'.
-4. Edit the 'settings' section with 'nano archinstall.sh' and leave the nano editor.
-5. Run the script with 'bash archinstall.sh'.
+2. Write the .iso file to an USB stick (maybe with this [tool](https://www.balena.io/etcher/)) and boot the machine from this USB stick (you could also boot a virtual machine with this .iso file).
+3. Change your keyboard layout, if needed (mind the section below).
+4. Download the script with 'curl -L archinstall.xengineering.eu > archinstall.sh'.
+5. Edit the 'settings' section with 'nano archinstall.sh', save (CTRL + o) and leave (CTRL + x) the nano editor.
+6. Run the script with 'bash archinstall.sh'.
-### Hint for German Users
+### Change your Keyboard Layout
Execute 'loadkeys de-latin1' after booting to live environment, if you want to set a german keyboard layout. You have to type 'z' for 'y' in loadkeys and 'ß' for the '-' sign.
-### Usage with VirtualBox
-
-1. Create a VirtualBox virtual machine (VM) for 64-bit Arch Linux with the default or customized settings.
-2. Start the VM and provide the .iso file if you are asked to.
-3. You booted the Arch Linux live environment in VirtualBox. Proceed with the normal use of archinstall.
-
-
## To Do
(Highest priority first)
-- [ ] Optimize mirrorlist
- [ ] Launch archconfig project for post-installation tasks like desktop, user setup, etc.
- [ ] Support installation with WiFi (instead of cable connection)
- [ ] Automate testing
@@ -44,6 +37,7 @@ Execute 'loadkeys de-latin1' after booting to live environment, if you want to s
(Last finished task first)
+- [x] Optimize mirrorlist
- [x] Support coloured output
- [x] Support UEFI and BIOS systems
- [x] Automatic abort in case of errors
diff --git a/archinstall.sh b/archinstall.sh
index 4ce3687..6e9f2ee 100644
--- a/archinstall.sh
+++ b/archinstall.sh
@@ -65,7 +65,7 @@ export hostname="archlinux" # select the hostname for your installation
export pacman_mirror_region="DE" # select "all" for all regions
export luks_encryption="no" # "yes" for full disk encryption, "no" for normal installation
export path_to_timezone="/usr/share/zoneinfo/Europe/Berlin" # choose your timezone
-export locales_to_generate="de_DE.UTF-8 UTF-8" # currently just one option
+export locales_to_generate="de_DE.UTF-8 UTF-8" # currently just one option is allowed
export language="de_DE.UTF-8"
export keymap="de-latin1" # the keyboard layout for the installation
@@ -99,7 +99,7 @@ export -f print_ok
function print_failed () {
# ref. https://en.wikipedia.org/wiki/ANSI_escape_code
printf "\033[m[ \033[31mFAILED\033[m ] $1\n"
- exit 7
+ exit 1
}
export -f print_failed
@@ -121,6 +121,7 @@ print_ok "Updated system clock"
# download and run first stage
+print_ok "Downloading and launching first_stage.sh ..."
curl $FIRST_STAGE_LINK > /root/first_stage.sh
bash /root/first_stage.sh
print_ok "first_stage.sh finished"
@@ -128,7 +129,8 @@ print_ok "first_stage.sh finished"
# download, run and delete second stage
+print_ok "Downloading and launching second_stage.sh in chroot environment ..."
curl $SECOND_STAGE_LINK > /mnt/root/second_stage.sh
echo "bash /root/second_stage.sh" | arch-chroot /mnt
rm /mnt/root/second_stage.sh
-print_ok "second_stage.sh finished"
+print_ok "second_stage.sh finished and deleted"
diff --git a/stages/first_stage.sh b/stages/first_stage.sh
index 85b1119..e6ddc7f 100644
--- a/stages/first_stage.sh
+++ b/stages/first_stage.sh
@@ -23,11 +23,6 @@
set -e
-# debug output
-
-print_ok "Entering first_stage.sh"
-
-
# check bootmode
print_ok "Checking bootmode ..."
@@ -186,16 +181,21 @@ print_ok "Formatting done"
# optimize mirrorlist
-print_ok "Optimize pacman mirrorlist ..."
+print_ok "Optimize /etc/pacman.d/mirrorlist ..."
curl "https://www.archlinux.org/mirrorlist/?country=$pacman_mirror_region&protocol=http&protocol=https&ip_version=4" > /etc/pacman.d/mirrorlist
sed -i '/#Server = *./s/^#//g' /etc/pacman.d/mirrorlist
+print_ok "/etc/pacman.d/mirrorlist optimized"
+
# install packages with pacstrap
+print_ok "Installing Arch Linux packages with 'pacstrap' ..."
pacstrap /mnt $PACKAGE_LIST
print_ok "Installed packages"
# generate /etc/fstab
+print_ok "Generating /etc/fstab ..."
genfstab -U /mnt >> /mnt/etc/fstab
+print_ok "/etc/fstab generated"
diff --git a/stages/second_stage.sh b/stages/second_stage.sh
index 5800828..abf407a 100644
--- a/stages/second_stage.sh
+++ b/stages/second_stage.sh
@@ -23,47 +23,98 @@
set -e
-# debug output
-
-print_ok "Entering second_stage.sh"
-
-
# set timezone
+print_ok "Setting timezone ..."
ln -sf $path_to_timezone /etc/localtime
hwclock --systohc
+print_ok "Timezone set"
# localization
+print_ok "Generating locales ..."
echo "$locales_to_generate" >> /etc/locale.gen
locale-gen
touch /etc/locale.conf
echo "LANG=$language" >> /etc/locale.conf
touch /etc/vconsole.conf
echo "KEYMAP=$keymap" >> /etc/vconsole.conf
+print_ok "Locales generated"
# network configuration
+print_ok "Setting /etc/hostname and /etc/hosts file ..."
touch /etc/hostname
echo "$hostname" > /etc/hostname
touch /etc/hosts
echo "127.0.0.1 localhost" >> /etc/hosts
echo "::1 localhost" >> /etc/hosts
+print_ok "/etc/hostname and /etc/hosts configured"
# initramfs
-### to be implemented
+if [ "$luks_encryption" == "yes" ];then
+
+ print_ok "Re-generating initramfs ..."
+
+ old_hooks_config_line=$(cat /etc/mkinitcpio.conf | grep "^HOOKS=")
+ print_ok "Old 'HOOKS' line in /etc/mkinitcpio : $old_hooks_config_line"
+ new_hooks_config_line="HOOKS=(base udev autodetect keyboard keymap modconf block encrypt filesystems fsck)"
+ print_ok "New 'HOOKS' line in /etc/mkinitcpio : $new_hooks_config_line"
+
+ sed -i "s|$old_hooks_config_line|$new_hooks_config_line|" /etc/mkinitcpio.conf
+ mkinitcpio -P
+
+ print_ok "Initramfs re-generated"
+
+fi
# setting root password
+print_ok "Setting default password for user 'root' ..."
echo "root:${DEFAULT_PASSWORD}" | chpasswd
+print_ok "Default password for user 'root' set"
+
+
+# install and configure bootloader
+
+print_ok "Installing grub bootloader ..."
+if [ "$boot_mode" == "uefi" ]; then
+ grub-install --target=x86_64-efi --efi-directory=/mnt --bootloader-id=GRUB \
+ --removable
+else
+ grub-install --target=i386-pc $path_to_disk
+fi
+print_ok "Grub bootloader installed"
+
+if [ $luks_encryption == "yes" ];then
+
+ print_ok "Setup of /etc/default/grub for LUKS encryption ..."
+
+ if [ "$boot_mode" == "uefi" ]; then
+ crypto_partition=${path_to_disk}3
+ else
+ crypto_partition=${path_to_disk}2
+ fi
+
+ cryptdevice_uuid=$(lsblk --fs | grep "$(basename $crypto_partition)" | awk '{print $3}')
+ print_ok "cryptdevice_uuid: $cryptdevice_uuid"
+ old_kernel_param_line=$(cat /etc/default/grub | grep "GRUB_CMDLINE_LINUX_DEFAULT")
+ print_ok "old_kernel_param_line: $old_kernel_param_line"
+ new_kernal_param_line="GRUB_CMDLINE_LINUX_DEFAULT=\"loglevel=3 quiet cryptdevice=UUID=${cryptdevice_uuid}:main root=/dev/mapper/main\""
+ print_ok "new_kernel_param_line: $new_kernal_param_line"
+ print_ok "Adding kernel parameters to /etc/default/grub ..."
+ sed -i "s|$old_kernel_param_line|$new_kernal_param_line|" /etc/default/grub
+ print_ok "Kernel parameters added to /etc/default/grub"
+ print_ok "Setup of /etc/default/grub for LUKS encryption done"
-# install bootloader
+fi
-grub-install --target=i386-pc $path_to_disk
+print_ok "Generating /boot/grub/grub.cfg from /etc/default/grub ..."
grub-mkconfig -o /boot/grub/grub.cfg
+print_ok "/boot/grub/grub.cfg generated"