-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathgetConf.sh
executable file
·121 lines (106 loc) · 2.55 KB
/
getConf.sh
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/bash
##############################################
#
# the script backups some configuration files
# to current directory depending on the Hostname
#
##############################################
source var.sh
#===========================
# backup common config files
#===========================
backup_common(){
print_sep
echo "Backing up common configs"
print_sep
mkdir -p $COMMON_DIR >/dev/null 2>&1
COMMON_FILES=(.Xdefaults
.Xresources
.zshrc
.screenrc
.tmux.conf
.vimrc
.config/nvim/init.vim
.config/nvim/ginit.vim
.Xmodmap
base.vimrc
.ctags
.todo
.bcrc
firefoxProxy.pac
)
COMMON_DOT_ZSH_FILES="$HOME/.zsh/completion"
for f in ${COMMON_FILES[@]}
do
f_tr=""
if [[ ! $f == ".todo" ]]; then #exclude directories
f_tr=$(sed 's@/@%%@g' <<< "$f")
fi
print_step "$f_tr"
#backup ~/.x/y/z -> COMMON/.x%%y%%z
rsync -a --force --exclude="todo.txt" --exclude="$HOME/.zsh/myZsh.zsh" $HOME/$f $COMMON_DIR/$f_tr
done
DOT_ZSH_DIR="$HOME/.zsh"
print_step "$DOT_ZSH_DIR excluding .zsh/.zsh-* and .zsh/.zsh_*"
rsync -a --exclude="myZsh.zsh" --exclude=".zsh_*" --exclude=".zsh-*" $DOT_ZSH_DIR $COMMON_DIR
echo "Common Part Done!"
}
#======================
# host specific configurations
#======================
backup_host_config(){
print_sep
echo "Backing up Host specific configs"
print_sep
rsync -a --force --delete-after $HOST_CONF_DIR $HOST_BKUP_DIR/
#cp ssh config and keep directory structure
mkdir -p $HOST_BKUP_DIR/.ssh
cp $HOME/.ssh/config $HOST_DOTFILES/.ssh/config > /dev/null 2>&1
echo "Backing up HOME/bin... "
rsync -a --safe-links --force --delete-after $HOME/bin $HOST_BKUP_DIR/
echo "Host-spec Part Done!"
}
#======================
# CUPS config
#======================
backup_cups_config(){
print_sep
echo "$ME /etc/cups root password needed[sudo]"
print_sep
mkdir -p $HOST_BKUP_DIR/cups > /dev/null 2>&1
sudo cp -rf /etc/cups/* $HOST_BKUP_DIR/cups/
sudo chown -R $USER $HOST_BKUP_DIR/cups
echo "cups Part Done!"
}
#======================
# /etc
#======================
backup_etc_config(){
print_sep
echo "$ME /etc "
print_sep
mkdir -p $HOST_ETC > /dev/null 2>&1
ETC_FILES=(/etc/hostname
/etc/hosts
/etc/vconsole.conf
/etc/locale.conf
/etc/locale.gen
/etc/pacman.conf
/etc/mtab
/etc/fstab
/etc/grub.d
/etc/X11
/etc/modprobe.d
)
for f in ${ETC_FILES[@]}; do
print_step "$f"
sudo rsync -a --copy-unsafe-links --force --delete-after $f $HOST_ETC/
done
sudo chown -R $USER $HOST_ETC
echo "/etc Part Done!"
}
backup_common
backup_host_config
backup_etc_config
backup_cups_config
# vim:ts=2 sw=2