I am writing my own script to install my Arch Linux.
I would like to have few options to change/configure every time I reinstall the system or use my script in another device.
I would like to configure the script so that: If I choose BTRFS, the relevent commands of formating, subvolume creation as well as mounting will be executed.
Likewise, if I choose Gnome for Desktop environment, the script should install Gnome AND the relevant display manager.
I can partially achieve this by writing the variables at the top of my script. I will then comment or uncomment as required before I run the script. However, if I want the script to have more options, there will be too many variables to define.
Currently the script looks like the below:
DISK="nvme0n1"
#DISK="sda"
UEFIPARTITION="nvme0n1p1"
#UEFIPARTITION="sda1"
SYSTEMPARTITION="nvme0n1p2"
#SYSTEMPARTITION="sda2"
and then somewhere in the script there will be:
gdisk /dev/$DISK
.
.
.
mkfs.vfat -n BOOT /dev/$UEFIPARTITION
mkfs.btrfs -L SYSTEM /dev/$SYSTEMPARTITION
It would be easier to just set one variable which is the DISK
to either sdX
or nvme0n1
. Then accordingly I can have the relevant commands to be executed for each.
I am a beginner in writing scripts.
What is the easiest way to achieve what I explained.
I am happy if someone can explain another/better way of achieving the above.