-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·61 lines (54 loc) · 1.64 KB
/
install.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
#!/bin/bash
filelist=./file_list
CONFIGDIR=./config
USERHOME=/home/$USER
showtip() {
echo -e "Usage: \t./install.sh backup"
echo -e "\t./install.sh restore"
}
if [ "$1" != "backup" ] && [ "$1" != "restore" ]; then
showtip
exit
fi
while read myline; do
if [ "${myline:0:1}" != "#" ]; then
filename=`basename $myline`
if [ "${myline:0:2}" == "~/" ]; then
file_abs_path=$USERHOME/${myline:2}
else
file_abs_path=$myline
fi
if [ "$1" == "backup" ]; then
srcfile=$file_abs_path
tarfile=$CONFIGDIR/$filename
elif [ "$1" == "restore" ]; then
# We treat file and folder in different way
if [ ! -d "$CONFIGDIR/$filename" ]; then
#Sanity check if path exist or not
directoryname=`dirname $file_abs_path`
if [ ! -d "$directoryname" ]; then
mkdir -p $directoryname
fi
tarfile=$file_abs_path
srcfile=$CONFIGDIR/$filename
else
directoryname=`dirname $file_abs_path`
mkdir -p $file_abs_path
tarfile=$directoryname
srcfile=$CONFIGDIR/$filename
fi
else
showtip
exit
fi
echo srcfile = $srcfile
echo tarfile = $tarfile
rsync -avP $srcfile $tarfile
md5sum $srcfile $tarfile
fi
done < $filelist
if [ "$1" == "restore" ]; then
if [ ! -d "~/.vim/bundle/vundle.vim" ]; then
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
fi
fi