From 7261629359fc5bc860898c065ed0f87e5256ec35 Mon Sep 17 00:00:00 2001 From: TuDatTr Date: Sun, 24 May 2020 04:18:05 +0200 Subject: [PATCH] install.sh Finished up root/march-chroot.sh Fixed up arguments root/march-reboot.sh Fixed up arguments --- install.sh | 26 +++++++++++++------------- root/march-chroot.sh | 27 +++++++++++++++++++++++---- root/march-reboot.sh | 6 +++++- 3 files changed, 41 insertions(+), 18 deletions(-) diff --git a/install.sh b/install.sh index 03d5c36..f70f7ce 100755 --- a/install.sh +++ b/install.sh @@ -70,6 +70,7 @@ Mandatory arguments: --) shift break + ;; *) echo "Programming error" exit 3 @@ -80,16 +81,16 @@ Mandatory arguments: # partition 1: 1MiB -> 500MiB FAT32 # partition 2: 500MiB -> 3GiB swap # partition 3: 3GiB -> .. ext4 -parted $d mklabel gpt mkpart primary fat32 1MiB 512 mkpart primary linux-swap 500MiB 3GiB mkpart primary ext4 3GiB 100% set 1 esp on -s +parted $device mklabel gpt mkpart primary fat32 1MiB 512 mkpart primary linux-swap 500MiB 3GiB mkpart primary ext4 3GiB 100% set 1 esp on -s -if [ -b "$d\p1" ]; then - bootpart=$d\p1 - swappart=$d\p2 - rootpart=$d\p3 +if [ -b "$device\p1" ]; then + bootpart=$device\p1 + swappart=$device\p2 + rootpart=$device\p3 else - bootpart=$d\1 - swappart=$d\2 - rootpart=$d\3 + bootpart=$device\1 + swappart=$device\2 + rootpart=$device\3 fi mkfs.vfat $bootpart @@ -113,14 +114,13 @@ pacstrap /mnt base base-devel linux linux-firmware genfstab -U /mnt >> /mnt/etc/fstab -cp $CWD/etc/systemd/system/march.service /mnt/etc/systemd/system/march.service -cp $CWD/root/march-chroot.sh /mnt/root/arch-chroot.sh -cp $CWD/root/march-reboot.sh /mnt/root/arch-reboot.sh +cp $CWD/etc/systemd/system/march.service /mnt/etc/syslll/system/march.service +cp $CWD/root/march-chroot.sh /mnt/root/march-chroot.sh +cp $CWD/root/march-reboot.sh /mnt/root/march-reboot.sh chmod +x /mnt/root/arch-chroot.sh chmod +x /mnt/root/arch-reboot.sh -arch-chroot /mnt /root/march-chroot.sh -t $t-l $l-h $h-u $u-s $s -sed -i "s/arch-reboot.sh/\0 -u $u-s $s/" /mnt/etc/systemd/system/march.service +arch-chroot /mnt /root/march-chroot.sh -t $timezone -l $locale -h $hostname -u $username -s $sudogrp umount $bootpart swapoff $swappart diff --git a/root/march-chroot.sh b/root/march-chroot.sh index e493d72..cbe50f6 100644 --- a/root/march-chroot.sh +++ b/root/march-chroot.sh @@ -7,8 +7,8 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then exit 1 fi -OPTIONS=tlhus -LONGOPTS=timezone,locale,hostname,username,sudogrp +OPTIONS=t:l:h:u:s: +LONGOPTS=timezone:,locale:,hostname:,username:,sudogrp: ! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@") if [[ ${PIPESTATUS[0]} -ne 0 ]]; then @@ -46,9 +46,28 @@ while true; do sudogrp="$2" shift 2 ;; + --help) + echo " +Usage: ./install.sh -d [DEVICE] -t [/usr/share/zoneinfo/REGION/CITY] -l [LOCALE] -h [HOSTNAME] -u [USER] -s [SUDO] +A small script to automate my archlinux configuration. + +Mandatory arguments: +-t | --timezone Your timezone according to /usr/share/zoneinfo/ e.g. "/usr/share/zoneinfo/Europe/Berlin" +-l | --locale Your locale according to /etc/locale.gen e.g. "en_US.UTF-8 UTF-8" +-h | --hostname Name for your machine e.g. "ArchLinux" +-u | --username Your username e.g. "foo" +-s | --sudogrp Name of the sudogrp +-h | --help This here. + " + exit 0 + ;; + --) + shift + break + ;; *) echo "Programming error" - exit3 + exit 3 ;; esac done @@ -82,7 +101,7 @@ linux /vmlinuz-linux initrd /initramfs-linux.img options rw cryptdevice=$(blkid $rootpart | cut -d" " -f2 | tr -d \"):cryptroot root=$cryptroot i8042.noloop i8042.nomux i8042.nopnp i8042.reset" > /boot/loader/entries/arch.conf -sed -i "s/" +sed -i "s/arch-reboot.sh/\0 -u $u-s $s/" /etc/systemd/system/march.service systemctl enable march.service systemctl enable dhcpcd.service diff --git a/root/march-reboot.sh b/root/march-reboot.sh index 904e8c5..7561276 100644 --- a/root/march-reboot.sh +++ b/root/march-reboot.sh @@ -43,9 +43,13 @@ while true; do sudogrp="$2" shift 2 ;; + --) + shift + break + ;; *) echo "Programming error" - exit3 + exit 3 ;; esac done