# Scripting Installation and clone setup from computer to computer

**URL:** <https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713>\
**Category:** Linux lounge\
**Created:** [July 30, 2022, 1:40am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713 "2022-07-30T01:40:26Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zircon34](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/zircon34/32/135623_2.png) [@Zircon34](https://forum.endeavouros.com/u/Zircon34)\
**Post date:** [July 30, 2022, 1:40am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/1 "2022-07-30T01:40:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sradjoker](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/sradjoker/32/64224_2.png) [@sradjoker](https://forum.endeavouros.com/u/sradjoker)\
**Post date:** [July 30, 2022, 1:45am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/2 "2022-07-30T01:45:45Z")

</div>

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.

> **[GitHub - sravanpannala/dotfiles](https://github.com/sravanpannala/dotfiles)**
>
> Contribute to sravanpannala/dotfiles development by creating an account on GitHub.

I just run this command on my new system

```auto
chezmoi init --apply sravanpannala

```

---

<div class="post-metadata">

**Author:** ![Zircon34](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/zircon34/32/135623_2.png) [@Zircon34](https://forum.endeavouros.com/u/Zircon34)\
**Post date:** [July 30, 2022, 1:49am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/3 "2022-07-30T01:49:11Z")

</div>

Cool thanks for sharing!

---

<div class="post-metadata">

**Author:** ![sradjoker](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/sradjoker/32/64224_2.png) [@sradjoker](https://forum.endeavouros.com/u/sradjoker)\
**Post date:** [July 30, 2022, 1:50am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/4 "2022-07-30T01:50:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Zircon34](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/zircon34/32/135623_2.png) [@Zircon34](https://forum.endeavouros.com/u/Zircon34)\
**Post date:** [July 30, 2022, 1:52am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/5 "2022-07-30T01:52:31Z")

</div>

> [@sradjoker](#):
>
> 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!

---

<div class="post-metadata">

**Author:** ![sradjoker](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/sradjoker/32/64224_2.png) [@sradjoker](https://forum.endeavouros.com/u/sradjoker)\
**Post date:** [July 30, 2022, 1:54am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/6 "2022-07-30T01:54:24Z")

</div>

> [@Zircon34](#):
>
> bash scripting, or really not that proficient but should be able to read and modify code

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.

---

<div class="post-metadata">

**Author:** ![MikeDelta42](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/mikedelta42/32/56575_2.png) [@MikeDelta42](https://forum.endeavouros.com/u/MikeDelta42)\
**Post date:** [July 30, 2022, 4:26am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/7 "2022-07-30T04:26:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zircon34](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/zircon34/32/135623_2.png) [@Zircon34](https://forum.endeavouros.com/u/Zircon34)\
**Post date:** [July 30, 2022, 5:57am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/8 "2022-07-30T05:57:00Z")

</div>

> [@MikeDelta42](#):
>
> use disk images

Sounds general, do you mean like clonezilla?

---

<div class="post-metadata">

**Author:** ![mrvictory](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mrvictory](https://forum.endeavouros.com/u/mrvictory)\
**Post date:** [July 30, 2022, 11:33am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/9 "2022-07-30T11:33:18Z")

</div>

> [@Zircon34](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![MikeDelta42](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/mikedelta42/32/56575_2.png) [@MikeDelta42](https://forum.endeavouros.com/u/MikeDelta42)\
**Post date:** [July 30, 2022, 11:53am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/10 "2022-07-30T11:53:35Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sradjoker](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/sradjoker/32/64224_2.png) [@sradjoker](https://forum.endeavouros.com/u/sradjoker)\
**Post date:** [July 30, 2022, 11:55am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/11 "2022-07-30T11:55:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MikeDelta42](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/mikedelta42/32/56575_2.png) [@MikeDelta42](https://forum.endeavouros.com/u/MikeDelta42)\
**Post date:** [July 30, 2022, 12:28pm UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/12 "2022-07-30T12:28:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Zircon34](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/zircon34/32/135623_2.png) [@Zircon34](https://forum.endeavouros.com/u/Zircon34)\
**Post date:** [July 30, 2022, 4:40pm UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/13 "2022-07-30T16:40:01Z")

</div>

> [@sradjoker](#):
>
> I just run this command on my new system
> 
> ```auto
> chezmoi init --apply sravanpannala
> 
> ```

I am reading the manual as we speak and just installed chezmoi (in French, at my place 😉)… 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/](https://christitus.com/chezmoi/), seems that it is tricky to explain in a couple of sentences.

---

<div class="post-metadata">

**Author:** ![sradjoker](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/sradjoker/32/64224_2.png) [@sradjoker](https://forum.endeavouros.com/u/sradjoker)\
**Post date:** [July 30, 2022, 4:43pm UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/14 "2022-07-30T16:43:19Z")

</div>

Yes, I use a git repo earlier to sync configs

> **[GitHub - sravanpannala/linux\_configs: Zsh Configuration](https://github.com/sravanpannala/linux_configs)**
>
> Zsh Configuration. Contribute to sravanpannala/linux\_configs development by creating an account on GitHub.

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

> **[GitHub - sravanpannala/dotfiles](https://github.com/sravanpannala/dotfiles)**
>
> Contribute to sravanpannala/dotfiles development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![Zircon34](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/zircon34/32/135623_2.png) [@Zircon34](https://forum.endeavouros.com/u/Zircon34)\
**Post date:** [July 31, 2022, 4:12am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/15 "2022-07-31T04:12:12Z")

</div>

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

```auto
#!/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.

---

<div class="post-metadata">

**Author:** ![Zircon34](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/zircon34/32/135623_2.png) [@Zircon34](https://forum.endeavouros.com/u/Zircon34)\
**Post date:** [August 3, 2022, 3:37am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/16 "2022-08-03T03:37:01Z")

</div>

> [@Zircon34](#):
>
> `#!/bin/sh`

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.

---

<div class="post-metadata">

**Author:** ![system](https://forum.endeavouros.com/uploads/default/original/2X/9/9ea52f9fd5ef8e609e593c362d61a36295f48be8.png) [@system](https://forum.endeavouros.com/u/system)\
**Post date:** [August 5, 2022, 3:37am UTC](https://forum.endeavouros.com/t/scripting-installation-and-clone-setup-from-computer-to-computer/29713/17 "2022-08-05T03:37:06Z")

</div>

Closed on August 5, 2022, 3:37am UTC

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