-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·72 lines (64 loc) · 1.24 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
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
CMDNAME=`basename $0`
detail_usage() {
echo "Usage: $CMDNAME [-i] [-d] [-h]"
echo
echo "Options:"
echo " -i : install"
echo " -d : clean up backupfile"
echo " -h : help"
echo
exit 1
}
if [ $# -le 0 ] ; then
detail_usage
fi
while getopts idh OPTION
do
case $OPTION in
"i" ) OPT_I="TRUE" ;;
"d" ) OPT_D="TRUE" ;;
"h" ) detail_usage ;;
-* ) detail_usage ;;
* ) detail_usage ;;
esac
done
DEST=$HOME
ORIGIN=$PWD
DOT_FILES=( \
.bashrc \
.bash_profile \
.gitconfig \
.git-completion.bash \
.git-prompt.sh \
.vimrc \
.gvimrc \
)
if [ "$OPT_I" = "TRUE" ]; then
for file in ${DOT_FILES[@]}
do
if [ -a $DEST/$file ]; then
echo "$file"
rm -f $DEST/$file~
cp -f $DEST/$file $DEST/$file~
echo "既にファイルが存在します: $file"
echo "バックアップを作成します: $DEST/$file~"
rm -f $DEST/$file
else
echo "$file"
fi
ln -sF $ORIGIN/$file $DEST/$file
echo "シンボリックリンクを貼りました"
echo ""
done
fi
if [ "$OPT_D" = "TRUE" ]; then
for file in ${DOT_FILES[@]}
do
if [ -a $DEST/$file~ ]; then
echo "$DEST/$file~"
rm -f $DEST/$file~
fi
echo ""
done
fi