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