forked from sk1418/myConf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_applyConf.sh
executable file
·50 lines (40 loc) · 963 Bytes
/
_applyConf.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
#!/bin/bash
#apply the configuration files in myConf to real system
#original conf file will be backuped to ~/myConfBackup
source var.sh
#dir variables
BACKUP="$HOME/myConfBackup"
__backup_and_apply(){
targetDir="$1"
for file in $(ls -a $targetDir); do
if [[ $file =~ ^[.][.]?$ ]]; then
#skip the '../' and './'
continue
else
echo "appling $file ..."
rsync -a "$HOME/$file" "$BACKUP" > /dev/null 2>&1
rsync -a "$targetDir/$file" $HOME
fi
done
}
apply_common(){
print_sep
echo "appling common config files"
print_sep
__backup_and_apply $COMMON_DIR
print_sep
}
apply_host_cfg(){
print_sep
echo "appling host-specific config files"
print_sep
__backup_and_apply "$HOST_DIR/dotfiles"
print_sep
}
#prepare backupdir
mkdir -p $BACKUP
#backup and apply "common" at last, for the .zsh/completion (not clean solution, work-around)
apply_host_cfg
apply_common
echo "old configurations were backuped on $BACKUP"
# vim:ts=2 sw=2