Fixed variable names for cli arguments
This commit is contained in:
52
install.sh
52
install.sh
@@ -7,7 +7,7 @@ if [[ ${PIPESTATUS[0]} -ne 4 ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
OPTIONS=dtlhush
|
||||
OPTIONS=dtlhus
|
||||
LONGOPTS=device,timezone,locale,hostname,username,sudogrp,help
|
||||
|
||||
! PARSED=$(getopt --options=$OPTIONS --longoptions=$LONGOPTS --name "$0" -- "$@")
|
||||
@@ -16,49 +16,49 @@ if [[ ${PIPESTATUS[0]} -ne 0 ]]; then
|
||||
fi
|
||||
eval set -- "$PARSED"
|
||||
|
||||
device="CHANGEME" # Device that shoud be partitioned e.g. "/dev/sda"
|
||||
timezone="CHANGEME" # Your timezone according to /usr/share/zoneinfo/ e.g. "/usr/share/zoneinfo/EUROPE/Berlin"
|
||||
locale="CHANGEME" # Your locale according to /etc/locale.gen e.g. "en_US.UTF-8 UTF-8"
|
||||
hostname="CHANGEME" # Name for your machine e.g. "ArchLinux"
|
||||
username="CHANGEME" # Your username e.g. "foo"
|
||||
sudogrp="CHANGEME" # Name of the sudogrp
|
||||
d="CHANGEME" # Device that shoud be partitioned e.g. "/dev/sda"
|
||||
t="CHANGEME" # Your timezone according to /usr/share/zoneinfo/ e.g. "/usr/share/zoneinfo/Europ/Berlin"
|
||||
l="CHANGEME" # Your locale according to /etc/locale.gen e.g. "en_US.UTF-8 UTF-8"
|
||||
h="CHANGEME" # Name for your machine e.g. "ArchLinux"
|
||||
u="CHANGEME" # Your username e.g. "foo"
|
||||
s="CHANGEME" # Name of the sudogrp
|
||||
|
||||
CWD="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||
|
||||
while true; do
|
||||
case "$1" in
|
||||
-d|--device)
|
||||
device="$2"
|
||||
d="$2"
|
||||
shift 2
|
||||
;;
|
||||
-t|--timezone)
|
||||
timezone="$2"
|
||||
t="$2"
|
||||
shift 2
|
||||
;;
|
||||
-l|--locale)
|
||||
locale="$2"
|
||||
l="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--hostname)
|
||||
hostname="$2"
|
||||
h="$2"
|
||||
shift 2
|
||||
;;
|
||||
-u|--username)
|
||||
username="$2"
|
||||
u="$2"
|
||||
shift 2
|
||||
;;
|
||||
-s|--sudogrp)
|
||||
sudogrp="$2"
|
||||
s="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
--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:
|
||||
-d | --device Device that shoud be partitioned e.g. "/dev/sda"
|
||||
-t | --timezone Your timezone according to /usr/share/zoneinfo/ e.g. "/usr/share/zoneinfo/EUROPE/Berlin"
|
||||
-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"
|
||||
@@ -77,16 +77,16 @@ Mandatory arguments:
|
||||
# partition 1: 1MiB -> 500MiB FAT32
|
||||
# partition 2: 500MiB -> 3GiB swap
|
||||
# partition 3: 3GiB -> .. ext4
|
||||
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
|
||||
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
|
||||
|
||||
if [ -b "$device\p1" ]; then
|
||||
bootpart=$device\p1
|
||||
swappart=$device\p2
|
||||
rootpart=$device\p3
|
||||
if [ -b "$d\p1" ]; then
|
||||
bootpart=$d\p1
|
||||
swappart=$d\p2
|
||||
rootpart=$d\p3
|
||||
else
|
||||
bootpart=$device\1
|
||||
swappart=$device\2
|
||||
rootpart=$device\3
|
||||
bootpart=$d\1
|
||||
swappart=$d\2
|
||||
rootpart=$d\3
|
||||
fi
|
||||
|
||||
mkfs.vfat $bootpart
|
||||
@@ -116,8 +116,8 @@ cp $CWD/root/march-reboot.sh /mnt/root/arch-reboot.sh
|
||||
chmod +x /mnt/root/arch-chroot.sh
|
||||
chmod +x /mnt/root/arch-reboot.sh
|
||||
|
||||
arch-chroot /mnt /root/march-chroot.sh -t $timezone -l $locale -h $hostname -u $username -s $sudogrp
|
||||
sed -i "s/arch-reboot.sh/\0 -u $username -s $sudogrp/" /mnt/etc/systemd/system/march.service
|
||||
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
|
||||
|
||||
umount $bootpart
|
||||
swapoff $swappart
|
||||
|
||||
Reference in New Issue
Block a user