Scripting Installation and clone setup from computer to computer

This post is about system cloning, if possible via bash script. What is your trick to quickly get your systems up and running on several computers?

I am wondering how you folks deal with post eos installation and system setup. I know it is possible to install additional software during eos installation by adding them in the package list.

However, I install and do many setup tweak steps after eos install and like to reproduce/automate these steps and get kind of a clone on each of my computers instead of repeating that process over and over. My goal is to write a bash script to do that.

My first question is, how do you tell the terminal in a sequence to 1) install package 2) automatically decide yes if prompted, 3) install second package once first package finished, and so on follow other steps sequentially and wait for each package installation before starting the next. In my example, I have to download additional software via wget, then compile it, then go back to install software in pacman and so on. Any caveats I have to be aware of?

Am I better off to set up a system on one computer and clone the hardrive to my other computers with clonezilla or similar?

Or alternatively, setup a system on my local server and send it to all other computers, not sure what the tool is called. I guess I would create an image of my system and send it to other computers on the LAN.

For system and config replication I use chezmoi.
You can install it from arch repos.
Here is my config for reference.
You can combine both dotfiles and scripts in chezmoi. It’s a really powerful tool.

I just run this command on my new system

chezmoi init --apply sravanpannala
1 Like

Cool thanks for sharing!

I have already implemented most of things you are asking for.

For example:
I have the option for minimal and complete install for arch packages.
Additionally for AUR packages I have to chose yes or no.

Try copying and modifying my configs and ask me if you have any questions.
Also checkout the chezmoi docs, it’s very extensive.

Thanks. It will take me a couple of days, as I am also learning bash scripting, or really not that proficient but should be able to read and modify code. Really appreciate the input!

That’s how I started. Rest is websearch skills. I didn’t do much bash scripting before April as @Pudge can attest to (he taught me a lot), but am semi competent at it now.

2 Likes

Maybe I’m not getting the use case but why not just use disk images?

1 Like

Sounds general, do you mean like clonezilla?

For migration, I simply use rsync to transfer everything at once.
If I want to replicate a config, (ie. Sway, Waybar and Alacritty when I used them) I save them seperately and copy over.

1 Like

Yes, that or similar. Everything is there on one simple clone and you just need to do some post clone tweaks (change hostname and that sort) - perhaps a bit more depending on complexity of need.

1 Like

chezmoi helps you maintain identical configs after the install too.

You can just git push the configs from one computer and got pull them on the rest.
I have three computers running :enos: and that’s how I maintain identical configs on all 3 of them.

I got ya. In reading through my mind was on deploy, not maintain.

I am reading the manual as we speak and just installed chezmoi (in French, at my place :wink:)… I am just wondering, are you using chezmoi just to copy config files from system to system (then why not just use git pull/push), and are you actually using chezmoi to syc your dot files from github and automatically install packages from your scripts with one command on your terminal. Do I get that correctly?

Edit: also found a useful article here https://christitus.com/chezmoi/, seems that it is tricky to explain in a couple of sentences.

Yes, I use a git repo earlier to sync configs

But I later discovered chezmoi and found it better suits what I want to do

Ok, my script works more or less and I can chezmoi update. However, I run into trouble for the AUR package install script. It tries to start then says -> Could not find all required packages: (Target) chezmoi: exit status 1

My script modified from yours is here

#!/bin/sh

read -p "Do you want to install AUR packages (y/n) " yn

pkglist_aur="
veusz-git
zoom
mendeley-reference-manager 
ttf-ms-fonts
"

echo -e "$pkglist_aur" > pkglist_aur

mkdir -p ~/.build

yay --builddir ~/.build --save

case $yn in
	y )	yay -S --needed - < pkglist_aur;;
	* ) echo continue;;
esac

Perhaps these packages need to be installed sequentially and run one at a time.

I was wondering also, I need to do git add git commit, do you simply use chezmoi update after that or first git push. It seems that chezmoi does the push automatically once staged and committed upon update.

solved this part, had to use #!/bin/bash, such a dumb mistake… Looks like chezmoi works pretty well. At the beginning was difficult to grasp why it is useful or necessary if we have git or gitlab, but this makes sense. It makes it easy to update config files and install new packages on multiple systems. Will experiment more.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.