-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmovein_etc.sh
More file actions
executable file
·67 lines (58 loc) · 1.5 KB
/
movein_etc.sh
File metadata and controls
executable file
·67 lines (58 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# This is a script to assist with setting up a new Linux computer, at FCI. It
# attempts to copy some files from a backup to the /etc directory
# !!!!!!!!!!!!!!!!! This Script only has minimal testing!!!!!!!!!!!!!!!!!!
# This is a starter, for next time. - RBB 2019-02-28
source movein_conf.sh
src="$movein_etc_src"
dst="/etc"
usage() {
echo "Usage: $0 [-s src [-d dest] [-n] [-h]"
echo " default src: $src"
echo " default dest: $dst"
exit 1
}
dryrun=""
verbose=""
while getopts ":s:d:hnv" o; do
case "${o}" in
s)
src=${OPTARG}
;;
d)
dst=${OPTARG}
;;
n)
dryrun="-n"
;;
v)
verbose="-v"
;;
*) # Note: this covers -h as well
usage
;;
esac
done
shift $((OPTIND-1))
cp_etc_target () {
name=$1
rp_name=$(realpath -s "$dst/$name")
echo "cp_etc_target rp_name = $rp_name"
echo "cp_etc_target src dir = $src"
if [ -f "$rp_name" ]; then
echo "$rp_name exists backing upto /etc/$name.movein_etc.orig"
if [ -z $dryrun ]; then
sudo mv "$rp_name" "/etc/$name.movein_etc.orig"
fi
fi
if [ -e "$src/$name" ]; then
echo "Copying $src/$name to $rp_name"
if [ -z $dryrun ]; then
sudo cp -aprv "$src/$name" "$rp_name"
fi
fi
}
cp_etc_target "fstab"
cp_etc_target "hosts"
cp_etc_target "netplan/01-network-manager-all.yaml"
#cp_etc_target "network/interfaces"