Skip to content

Seeking Help Scripting My Arch Linux installation

Hey all, so I'm attempting to script my Arch Linux insallation using bash. Essentially I'm trying to script this installation method. Problem is, I don't have much experience with bash scripting, so I've uploaded the draft for the script to github here.

The main thing I'm asking for help with scripting is:

  • Creating the user account, while adding it to the wheel group and creating that users' /home/user directory, all while accepting input for the username and password through something like the read command. Then setting the root password also with input whenever it's run.

  • Setting the repositories in /etc/pacman.conf

Anyone with bash scripting experience care to lend a hand?

Thanks in advance

1 points13 comments
Open on Reddit
About this post
Posted
Archived
Score
1 · 100% up
Kind
Text
ID
4itz5a

Author

6
posts
18
comments
3
media
View profile

13 comments

Creating the user account, while adding it to the wheel group and creating that users' /home/user directory, all while accepting input for the username and password through something like the read command.

read -p "Enter username: " USER
read -p "Enter password: " PASS

useradd $USER
chpasswd <<EOF
$USER:$PASS
EOF

mkdir /home/$USER
chown $USER /home/$USER

gpasswd -a wheel $USER

Setting the repositories in /etc/pacman.conf

cat <<EOF > /etc/pacman.conf
# Put whavever you want in your pacman.conf here
EOF
2 points
unknown author9 hidden

First I'd like to ask what the need for scripting this is?

1 points

Its a repetitive task that requires some attention to detail and is likely to be the same every time. A great candidate for scripting.

6 points

I find my self reinstalling often enough that I want to make the process quicker.

3 points

make the process quicker

In my experience, the most time, by far, is spent downloading packages. For any new install, I always use a USB full of packages I have saved. So, almost all download time is eliminated.

How an install goes for me:

  • 2 min - partition, create and mount filesystems.

  • 2 min - pacstrap in base, base-devel, vim, xorg, reflector, grub... (the basics)

  • 3 min - pacman (originally from usb) in the DE or WM as needed. I have these pretty memorized.

  • 3 min - post install config (adding users, setting passwords, configuring DE/WM. I now use i3wm and use the same .config file between all similar installs.

Using the -c option on pacman and pacstrap is a huge timesaver.

Just some thoughts.

1 points
unknown author1 hidden

Thats.. not a very good reason. Sure you can reinstall as soon as something breaks, but that way you'll have a system that works due to dumb luck until the next major update.

0 points

... Apparently he got inspired by two scripts I showed him which I constantly use to setup VMs for testing development stuff or updating managed packages (I'd like to have completely clean machines so I know the package dependencies haven't changed).

2 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.