Last active
July 1, 2018 09:28
-
-
Save wRadion/a73fd395213eae3d3c6ce6ac1c51caee to your computer and use it in GitHub Desktop.
Automatically install ArchLinux for a VirtualBox virtual machine.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /bin/sh | |
| # Download this file easily: | |
| # wget -O install.sh https://tinyurl.com/wralvm12 | |
| # chmod +x install.sh | |
| C_RESET="\e[0;0m" | |
| B_BLACK="\e[1;30m" | |
| B_YELLOW="\e[1;33m" | |
| B_CYAN="\e[1;36m" | |
| B_WHITE="\e[1;37m" | |
| wait_user () { | |
| printf "${B_YELLOW}On the next command, you will have to do something.${C_RESET}\n" | |
| if [ "$1" ]; then | |
| echo | |
| printf " ${B_BLACK}$1${C_RESET}\n" | |
| echo | |
| fi | |
| printf "${B_YELLOW}Press ${B_WHITE}enter ${B_YELLOW}to continue.${C_RESET}" | |
| read | |
| } | |
| write_info () { | |
| printf "${B_BLACK}:: ${B_CYAN}$@${C_RESET}\n" | |
| } | |
| # Source for all the following commands: | |
| # https://wiki.archlinux.org/index.php/installation_guide | |
| write_info "Updating the system clock" | |
| timedatectl set-ntp true | |
| write_info "Partitioning the disks" | |
| wait_user "For a Single Root Partition, follow these steps | |
| > Select dos | |
| > Press enter [ New ] | |
| > Press enter (full size partition) | |
| > Press enter [ primary ] | |
| > Select [Bootable] the presse enter | |
| > Select [ Write ] then press enter, then type yes, then press enter | |
| > Select [ Quit ] then press enter" | |
| cfdisk | |
| # For some partition scheme examples, see | |
| # https://wiki.archlinux.org/index.php/partitioning#Example_layouts | |
| write_info "Formatting the partition" | |
| mkfs.ext4 /dev/sda1 | |
| write_info "Mounting the new file system" | |
| mount /dev/sda1 /mnt | |
| write_info "Installing the base and base-devel packages" | |
| pacstrap /mnt base base-devel | |
| write_info "Generating the fstab" | |
| genfstab -U /mnt >> /mnt/etc/fstab | |
| # Write all the next commands into another file because | |
| # we need to log as root into the new system | |
| write_info "Creating the next install.sh script" | |
| echo '#! /bin/sh | |
| C_RESET="\e[0;0m" | |
| B_BLACK="\e[1;30m" | |
| B_YELLOW="\e[1;33m" | |
| B_CYAN="\e[1;36m" | |
| B_WHITE="\e[1;37m" | |
| wait_user () { | |
| printf "${B_YELLOW}On the next command, you will have to do something.${C_RESET}\n" | |
| if [ "$1" ]; then | |
| echo | |
| printf " ${B_BLACK}$1${C_RESET}\n" | |
| echo | |
| fi | |
| printf "${B_YELLOW}Press ${B_WHITE}enter ${B_YELLOW}to continue.${C_RESET}" | |
| read | |
| } | |
| write_info () { | |
| printf "${B_BLACK}:: ${B_CYAN}$@${C_RESET}\n" | |
| } | |
| write_info "Setting the timezone" | |
| ln -sf /usr/share/zoneinfo/Europe/Paris /etc/localtime | |
| write_info "Generating /etc/adjtime" | |
| hwclock --systohc | |
| write_info "Setting current locale" | |
| wait_user "Uncomment en_US.UTF-8 UTF-8 (line 175, if commented)" | |
| vi +175 /etc/locale.gen | |
| write_info "Generating locale file" | |
| locale-gen | |
| write_info "Setting the LANG variable" | |
| echo "LANG=en_US.UTF-8" > /etc/locale.conf | |
| write_info "Creating the hostname file" | |
| wait_user "Write your hostname in the file. Ex: wradion-archlinux" | |
| vi /etc/hostname | |
| write_info "Adding standard entries to hosts file" | |
| echo -e " | |
| 127.0.0.1\tlocalhost | |
| ::1\t\tlocalhost" >> /etc/hosts | |
| write_info "Setting the root password" | |
| wait_user "You will need to type the password yourself :)" | |
| passwd | |
| write_info "Downloading the grub package" | |
| pacman -S grub --noconfirm | |
| write_info "Installing GRUB Bootloader" | |
| grub-install /dev/sda | |
| write_info "Generating grub config file" | |
| grub-mkconfig -o /boot/grub/grub.cfg | |
| write_info "Enabling dhcpcd service" | |
| systemctl enable dhcpcd | |
| write_info "Creating the wradion user" | |
| useradd -m wradion | |
| write_info "Setting the password for wradion" | |
| passwd wradion | |
| write_info "Installation done! Next steps:" | |
| write_info "- Logout: exit or CTRL+D" | |
| write_info "- Remove this file: rm /mnt/install.sh" | |
| write_info "- Unmount partition: umount -R /mnt" | |
| echo | |
| write_info "Then, you can:" | |
| write_info "- Shutdown the machine: poweroff" | |
| write_info "- Remove the ISO file from the IDE disk input" | |
| write_info "- Restart the VM" | |
| exit 0' >> /mnt/install.sh | |
| write_info "Giving execution right to the script" | |
| chmod +x /mnt/install.sh | |
| write_info "Login to root into the new system" | |
| wait_user "You will need to continue the installation by running | |
| the next part of the script: ./install.sh" | |
| arch-chroot /mnt | |
| write_info "Done!" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment