From 8be2835d3de8ff65fcd5aa5a09a50f7060f69f23 Mon Sep 17 00:00:00 2001 From: xengineering Date: Sat, 14 Dec 2019 16:41:26 +0100 Subject: Created util files and moved stages. --- README.md | 4 +- archinstall.sh | 26 +++--- bin/first_stage.sh | 174 ---------------------------------------- bin/second_stage.sh | 74 ----------------- stages/first_stage.sh | 172 +++++++++++++++++++++++++++++++++++++++ stages/second_stage.sh | 74 +++++++++++++++++ util/check_bootmode.sh | 0 util/configure_bootloader.sh | 0 util/configure_desktop.sh | 0 util/configure_keyboard.sh | 0 util/configure_locales.sh | 0 util/configure_network.sh | 0 util/configure_timezone.sh | 0 util/configure_users.sh | 0 util/copy_archinstall_config.sh | 0 util/copy_archinstall_log.sh | 0 util/create_filesystems.sh | 0 util/install_archinstall.sh | 0 util/install_packages.sh | 0 util/mount_filesystems.sh | 0 util/partition_disk.sh | 0 util/print_final_message.sh | 0 util/unmount_filesystems.sh | 0 util/write_config.py | 0 util/write_fstab.sh | 0 25 files changed, 261 insertions(+), 263 deletions(-) delete mode 100644 bin/first_stage.sh delete mode 100644 bin/second_stage.sh create mode 100644 stages/first_stage.sh create mode 100644 stages/second_stage.sh create mode 100644 util/check_bootmode.sh create mode 100644 util/configure_bootloader.sh create mode 100644 util/configure_desktop.sh create mode 100644 util/configure_keyboard.sh create mode 100644 util/configure_locales.sh create mode 100644 util/configure_network.sh create mode 100644 util/configure_timezone.sh create mode 100644 util/configure_users.sh create mode 100644 util/copy_archinstall_config.sh create mode 100644 util/copy_archinstall_log.sh create mode 100644 util/create_filesystems.sh create mode 100644 util/install_archinstall.sh create mode 100644 util/install_packages.sh create mode 100644 util/mount_filesystems.sh create mode 100644 util/partition_disk.sh create mode 100644 util/print_final_message.sh create mode 100644 util/unmount_filesystems.sh create mode 100644 util/write_config.py create mode 100644 util/write_fstab.sh diff --git a/README.md b/README.md index c46fcb7..c210373 100644 --- a/README.md +++ b/README.md @@ -30,12 +30,12 @@ Execute 'loadkeys de-latin1' after booting to live environment, if you want to s ## To Do - [ ] Create a main User with sudo Permissions -- [ ] Support BIOS Systems -- [ ] Support English Localization - [ ] Provide LUKS Encryption - [ ] Support Installation with WiFi (instead of cable connection) - [ ] Provide recommended Package Lists - [ ] Modify Mirrorlist +- [ ] Support BIOS Systems +- [ ] Support English Localization - [ ] Packaged for the AUR - [x] Provide Installation of Desktop Environment - [x] Provide reusable Configuration File (json) diff --git a/archinstall.sh b/archinstall.sh index f205409..ce3b8e8 100644 --- a/archinstall.sh +++ b/archinstall.sh @@ -28,6 +28,18 @@ ################################################################# +# Settings + +TESTSERVER="8.8.8.8" # hostnames will not work properly +NETWORK_DEADLINE=1 # in seconds +REPOSITORY_URL="https://github.com/xengineering/archinstall/" +REPOSITORY_PATH="/opt/archinstall" +BRANCH_OR_COMMIT="master" # select another branch name or commit hash if needed +LOG_FILE_PATH="/var/log/archinstall.log" +CONFIG_FILE_PATH="/etc/archinstall/config.json" +DELAY=0.5 # delay for reading messages in seconds + + # Greetings cat << EOF @@ -47,18 +59,6 @@ cat << EOF EOF -# Settings - -TESTSERVER="8.8.8.8" # hostnames will not work properly -NETWORK_DEADLINE=1 # in seconds -REPOSITORY_URL="https://github.com/xengineering/archinstall/" -REPOSITORY_PATH="/opt/archinstall" -BRANCH_OR_COMMIT="master" # select another branch name or commit hash if needed -LOG_FILE_PATH="/var/log/archinstall.log" -CONFIG_FILE_PATH="/etc/archinstall/config.json" -DELAY=0.5 # delay for reading messages in seconds - - # Check internet connection if ping -w $NETWORK_DEADLINE -c 1 $TESTSERVER; then @@ -104,5 +104,5 @@ sleep $DELAY # Launching first stage -bash $REPOSITORY_PATH/bin/first_stage.sh \ +bash $REPOSITORY_PATH/stages/first_stage.sh \ $DELAY $REPOSITORY_PATH $LOG_FILE_PATH $CONFIG_FILE_PATH | tee -a $LOG_FILE_PATH diff --git a/bin/first_stage.sh b/bin/first_stage.sh deleted file mode 100644 index 858e251..0000000 --- a/bin/first_stage.sh +++ /dev/null @@ -1,174 +0,0 @@ -#!/bin/bash - - -# archinstall - A minimal Installation Script for Arch Linux -# Copyright (C) 2019 xengineering - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -#################### -# first_stage.sh # -#################### - - -# Argument Processing - -DELAY=$1 -REPOSITORY_PATH=$2 -LOG_FILE_PATH=$3 -CONFIG_FILE_PATH=$4 - - -mkdir $(dirname "$CONFIG_FILE_PATH") -touch $CONFIG_FILE_PATH -python $2/bin/write_config.py $CONFIG_FILE_PATH -disk=$(python $REPOSITORY_PATH/bin/get_config_string.py $CONFIG_FILE_PATH "disk") -disk_path=/dev/$disk -hostname=$(python $REPOSITORY_PATH/bin/get_config_string.py $CONFIG_FILE_PATH "hostname") -desktop=$(python $REPOSITORY_PATH/bin/get_config_string.py $CONFIG_FILE_PATH "desktop") - - -echo "All data on disk '$disk' will be finally lost!" -echo "Are you SURE that you want to install Arch Linux to '$disk'?!" -echo "Type 'Yes' for installation and 'No' for abort." -read answer -if [ $answer == "Yes" ]; then - echo "" - echo "Starting installation process - OK" - echo "" -else - echo "" - echo "Abort of installation process!" - exit -fi - - -# Check if booted with UEFI - -if [ -d "/sys/firmware/efi/efivars" ]; then - echo "Booted with UEFI - OK" - echo "" - sleep $DELAY -else - echo "Not booted with UEFI. Please enable it in your mainboard settings. - FAILED" - exit -fi - - -# Partitioning - -wipefs -a $disk_path # make sure that fdisk does not ask for removing - # signatures which breaks the script -fdisk $disk_path << EOF -g -n -1 - -+512M -n -2 - - -p -w -EOF -boot_partition_path="${disk_path}1" -root_partition_path="${disk_path}2" -echo "Partitioning finished - OK" -sleep $DELAY -echo "" - - -# Create Filesystems - -mkfs.fat -F32 $boot_partition_path -mkfs.ext4 $root_partition_path -fatlabel $boot_partition_path "BOOT" -e2label $root_partition_path "ROOT" -echo "Created filesystems - OK" -sleep $DELAY -echo "" - - -# Mount Root Filesystem - -mount $root_partition_path /mnt -echo "Mounted root partition - OK" -sleep $DELAY -echo "" - - -# Install basic Packages - -echo "Going to install packages ..." -sleep $DELAY -echo "" -pacstrap /mnt base linux linux-firmware dhcpcd nano sudo grub efibootmgr -if [ "$desktop" = "yes" ]; then - pacstrap /mnt xorg lightdm lightdm-gtk-greeter xfce4 mousepad -fi -echo "" -echo "Installed packages - OK" -sleep $DELAY -echo "" - - -# Copy repository from live image to root partition - -cp -r $REPOSITORY_PATH /mnt$REPOSITORY_PATH - - -# Generate /etc/fstab file - -genfstab -U /mnt >> /mnt/etc/fstab -echo "Generated /etc/fstab - OK" -sleep $DELAY -echo "" - - -# Launch second stage in chroot - -echo "bash $REPOSITORY_PATH/bin/second_stage.sh $hostname \ -${disk_path}1 $REPOSITORY_PATH $CONFIG_FILE_PATH $desktop" | arch-chroot /mnt - - -# Copy log and config from live image to root partition - -cp $LOG_FILE_PATH /mnt$LOG_FILE_PATH -mkdir /mnt$(dirname "$CONFIG_FILE_PATH") -cp $CONFIG_FILE_PATH /mnt$CONFIG_FILE_PATH - - -# Unmount root partition - -cd /root && umount $root_partition_path -echo "Unmounted root partition - OK" -sleep $DELAY -echo "" - - -# Final Messages - -cat << EOF -################################################################# -# # -# The default login is user root with password 'root'. # -# You can now power off your machine with 'poweroff', # -# remove the installation media and boot your new # -# Arch Linux machine! # -# # -################################################################# - -EOF diff --git a/bin/second_stage.sh b/bin/second_stage.sh deleted file mode 100644 index bd6ddf9..0000000 --- a/bin/second_stage.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash - - -# archinstall - A minimal Installation Script for Arch Linux -# Copyright (C) 2019 xengineering - -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - - -##################### -# second_stage.sh # -##################### - - -# Argument Processing - -hostname=$1 -boot_partition_path=$2 -REPOSITORY_PATH=$3 -CONFIG_FILE_PATH=$4 -desktop=$5 - - -# Localization - -bash $REPOSITORY_PATH/bin/localization.sh - - -# Network Configuration - -bash $REPOSITORY_PATH/bin/network_configuration.sh $hostname - - -# Initramfs - -# implement if needed ... - - -# Set default Password - -echo "root:root" | chpasswd -echo "Default password for user root set - OK" -echo "" -sleep 1 - - -# Bootloader Installation - -bash $REPOSITORY_PATH/bin/install_bootloader.sh $boot_partition_path - - -# Desktop Installation - -if [ "$desktop" = "yes" ]; then - bash $REPOSITORY_PATH/bin/configure_desktop.sh -fi - - -# Good bye chroot - -echo "Leaving chroot environment - OK" -echo "" -sleep 1 diff --git a/stages/first_stage.sh b/stages/first_stage.sh new file mode 100644 index 0000000..6799d50 --- /dev/null +++ b/stages/first_stage.sh @@ -0,0 +1,172 @@ +#!/bin/bash + + +# archinstall - A minimal Installation Script for Arch Linux +# Copyright (C) 2019 xengineering + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +#################### +# first_stage.sh # +#################### + + +DELAY=$1 +REPOSITORY_PATH=$2 +LOG_FILE_PATH=$3 +CONFIG_FILE_PATH=$4 + + +mkdir $(dirname "$CONFIG_FILE_PATH") +touch $CONFIG_FILE_PATH +python $REPOSITORY_PATH/bin/write_config.py $CONFIG_FILE_PATH +disk=$(python $REPOSITORY_PATH/bin/get_config_string.py $CONFIG_FILE_PATH "disk") +disk_path=/dev/$disk +hostname=$(python $REPOSITORY_PATH/bin/get_config_string.py $CONFIG_FILE_PATH "hostname") +desktop=$(python $REPOSITORY_PATH/bin/get_config_string.py $CONFIG_FILE_PATH "desktop") + + +echo "All data on disk '$disk' will be finally lost!" +echo "Are you SURE that you want to install Arch Linux to '$disk'?!" +echo "Type 'Yes' for installation and 'No' for abort." +read answer +if [ $answer == "Yes" ]; then + echo "" + echo "Starting installation process - OK" + echo "" +else + echo "" + echo "Abort of installation process!" + exit +fi + + +# Check if booted with UEFI + +if [ -d "/sys/firmware/efi/efivars" ]; then + echo "Booted with UEFI - OK" + echo "" + sleep $DELAY +else + echo "Not booted with UEFI. Please enable it in your mainboard settings. - FAILED" + exit +fi + + +# Partitioning + +wipefs -a $disk_path # make sure that fdisk does not ask for removing + # signatures which breaks the script +fdisk $disk_path << EOF +g +n +1 + ++512M +n +2 + + +p +w +EOF +boot_partition_path="${disk_path}1" +root_partition_path="${disk_path}2" +echo "Partitioning finished - OK" +sleep $DELAY +echo "" + + +# Create Filesystems + +mkfs.fat -F32 $boot_partition_path +mkfs.ext4 $root_partition_path +fatlabel $boot_partition_path "BOOT" +e2label $root_partition_path "ROOT" +echo "Created filesystems - OK" +sleep $DELAY +echo "" + + +# Mount Root Filesystem + +mount $root_partition_path /mnt +echo "Mounted root partition - OK" +sleep $DELAY +echo "" + + +# Install basic Packages + +echo "Going to install packages ..." +sleep $DELAY +echo "" +pacstrap /mnt base linux linux-firmware dhcpcd nano sudo grub efibootmgr +if [ "$desktop" = "yes" ]; then + pacstrap /mnt xorg lightdm lightdm-gtk-greeter xfce4 mousepad +fi +echo "" +echo "Installed packages - OK" +sleep $DELAY +echo "" + + +# Copy repository from live image to root partition + +cp -r $REPOSITORY_PATH /mnt$REPOSITORY_PATH + + +# Generate /etc/fstab file + +genfstab -U /mnt >> /mnt/etc/fstab +echo "Generated /etc/fstab - OK" +sleep $DELAY +echo "" + + +# Launch second stage in chroot + +echo "bash $REPOSITORY_PATH/stages/second_stage.sh $hostname \ +${disk_path}1 $REPOSITORY_PATH $CONFIG_FILE_PATH $desktop" | arch-chroot /mnt + + +# Copy log and config from live image to root partition + +cp $LOG_FILE_PATH /mnt$LOG_FILE_PATH +mkdir /mnt$(dirname "$CONFIG_FILE_PATH") +cp $CONFIG_FILE_PATH /mnt$CONFIG_FILE_PATH + + +# Unmount root partition + +cd /root && umount $root_partition_path +echo "Unmounted root partition - OK" +sleep $DELAY +echo "" + + +# Final Messages + +cat << EOF +################################################################# +# # +# The default login is user root with password 'root'. # +# You can now power off your machine with 'poweroff', # +# remove the installation media and boot your new # +# Arch Linux machine! # +# # +################################################################# + +EOF diff --git a/stages/second_stage.sh b/stages/second_stage.sh new file mode 100644 index 0000000..bd6ddf9 --- /dev/null +++ b/stages/second_stage.sh @@ -0,0 +1,74 @@ +#!/bin/bash + + +# archinstall - A minimal Installation Script for Arch Linux +# Copyright (C) 2019 xengineering + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +##################### +# second_stage.sh # +##################### + + +# Argument Processing + +hostname=$1 +boot_partition_path=$2 +REPOSITORY_PATH=$3 +CONFIG_FILE_PATH=$4 +desktop=$5 + + +# Localization + +bash $REPOSITORY_PATH/bin/localization.sh + + +# Network Configuration + +bash $REPOSITORY_PATH/bin/network_configuration.sh $hostname + + +# Initramfs + +# implement if needed ... + + +# Set default Password + +echo "root:root" | chpasswd +echo "Default password for user root set - OK" +echo "" +sleep 1 + + +# Bootloader Installation + +bash $REPOSITORY_PATH/bin/install_bootloader.sh $boot_partition_path + + +# Desktop Installation + +if [ "$desktop" = "yes" ]; then + bash $REPOSITORY_PATH/bin/configure_desktop.sh +fi + + +# Good bye chroot + +echo "Leaving chroot environment - OK" +echo "" +sleep 1 diff --git a/util/check_bootmode.sh b/util/check_bootmode.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/configure_bootloader.sh b/util/configure_bootloader.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/configure_desktop.sh b/util/configure_desktop.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/configure_keyboard.sh b/util/configure_keyboard.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/configure_locales.sh b/util/configure_locales.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/configure_network.sh b/util/configure_network.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/configure_timezone.sh b/util/configure_timezone.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/configure_users.sh b/util/configure_users.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/copy_archinstall_config.sh b/util/copy_archinstall_config.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/copy_archinstall_log.sh b/util/copy_archinstall_log.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/create_filesystems.sh b/util/create_filesystems.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/install_archinstall.sh b/util/install_archinstall.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/install_packages.sh b/util/install_packages.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/mount_filesystems.sh b/util/mount_filesystems.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/partition_disk.sh b/util/partition_disk.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/print_final_message.sh b/util/print_final_message.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/unmount_filesystems.sh b/util/unmount_filesystems.sh new file mode 100644 index 0000000..e69de29 diff --git a/util/write_config.py b/util/write_config.py new file mode 100644 index 0000000..e69de29 diff --git a/util/write_fstab.sh b/util/write_fstab.sh new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3-70-g09d2