You are not logged in.
Pages: 1
Hi, I was working with Arch and I might try my hand at scripting, and wanted to make a small script that would be able to update and copy files I wanted over to my an overlay. The larch iso I was building is basically a copy of this system as a backup, and I wanted all the important /etc/ files, as well as my home directory for work and presonal settings.
Anyway it goes like this:
#!/bin/bash
# Overlay Preparation Script for Larch
# This script will copy over my home directory to the overlay, as well as key /etc/ files like pacman.conf, as well as Files with groups and users, and X11 # settings.
echo "Copying home Directory To Overlay"
cp ~/* ~/.config/larch/myprofiles/default/rootoverlay/
var1=/etc/conky
var2=/etc/X11
var3=/etc/gshadow
var4=/etc/host.conf
var5=/etc/hosts
var6=/etc/hosts.allow
var7=/etc/hosts.atm
var8=/etc/hosts.deny
var9=/etc/loacale.gen
var10=/etc/passwd
var11=/etc/rc.conf
var12=/etc/shadow
var13=/etc/slim.conf
var14=/etc/pacman.conf
echo "Copying /etc/ files"
for arg in "$var1" "$var2" "$var3" "$var4" "$var5" "$var6" "$var7" "$var8" "$var9" "$var10" "$var11" "$var12" "$var13" "$var14"
filepath=$arg
sudo cp -r $filepath ~/.config/larch/myprofiles/default/rootoverlay/
done
echo "Files copied to overlay"
exit 0
And that's it, I made it after just learning about variables and assigning values.
I would like it so as I could perhaps have another file, that's a list of all the files and their paths I want copying, thus I can change that list, if theres a new file I want including, as opposed to this script. I'm also considering having it delete ones that aren't in the list or home directory anymore.
But yeah, that's my first attempt at doing any form or scripting and thought I'd throw it out there for feedback or comment.
Then when I'm done I can delete the overlay and other larch files I don't need until I want to larchify again, as they take up quite a bit of memory.
Cheers,
Ben.
"In England we have come to rely upon a comfortable time-lag of fifty years or a century intervening between the perception that something ought to be done and a serious attempt to do it."
- H. G. Wells
Offline
Please use [ code ] tags.
You also might want to look into arrays, for example:
vars=( /etc/conky
/etc/X11
/etc/gshadow
/etc/host.conf
/etc/hosts
/etc/hosts.allow
/etc/hosts.atm
/etc/hosts.deny
/etc/loacale.gen
/etc/passwd
/etc/rc.conf
/etc/shadow
/etc/slim.conf
/etc/pacman.conf )
echo "Copying /etc/ files"
for arg in "${vars[@]}"; do
# something with $arg
done
//github/
Offline
Pages: 1