-
Notifications
You must be signed in to change notification settings - Fork 4
/
install
executable file
·84 lines (76 loc) · 1.21 KB
/
install
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
#!/bin/bash
#options
do_install=
#function
cai() {
local dir=${HOME}/${1}
echo "create directory ${dir}"
if [[ ! -d ${dir} ]]; then
if [[ -n ${do_install} ]]; then
mkdir -p ${dir}
fi
fi
}
#install configure files
conf() {
for from in conf/*; do
from=${PWD}/${from}
local file=$(basename ${from})
local to=${HOME}/.${file}
echo "link ${from} to ${to}"
if [[ -n ${do_install} ]]; then
ln -sf ${from} ${to}
fi
done
}
#install binary files
bin() {
cai ".local/bin"
for from in bin/*; do
from=${PWD}/${from}
file=$(basename ${from})
to=${HOME}/.local/bin/${file}
echo "link ${from} to ${to}"
if [[ -n ${do_install} ]]; then
ln -sf ${from} ${to}
fi
done
}
#copy download files
down() {
cai "Downloads"
for from in down/*; do
file=$(basename ${from})
to=${HOME}/Downloads/${file}
echo "copy ${from} to ${to}"
if [[ -n ${do_install} ]]; then
cp -rf ${from} ${to}
fi
done
}
#main function
main() {
conf
bin
down
cai "Music"
cai "Videos"
}
#parsing arguments
case ${1} in
"run")
do_install="true"
;;
"show")
;;
*)
if [[ -n ${1} ]]; then
echo "invalid option: ${1}"
else
echo "missing option"
fi
echo "usage: ${0} (run | show)"
exit -1
;;
esac
main