-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·91 lines (71 loc) · 1.52 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·91 lines (71 loc) · 1.52 KB
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
#!/bin/bash
# Time-stamp: <2017-11-07 13:04:51 Tuesday by ahei>
readonly PROGRAM_NAME="install.sh"
readonly PROGRAM_VERSION="1.0"
home=`dirname "$0"`
home=`cd "$home"; pwd`
# echo to stderr
echoe()
{
printf "$*\n" 1>&2
}
usage()
{
code=1
if [ $# -gt 0 ]; then
code="$1"
fi
if [ "$code" != 0 ]; then
redirect="1>&2"
fi
eval cat "$redirect" << EOF
usage: ${PROGRAM_NAME} [OPTIONS] [<INSTALL_DIR>]
INSTALL_DIR default is /usr/bin.
Options:
-p <PROFILE>
PROFILE defualt is /etc/profile.
-v Output version info.
-h Output this help.
EOF
exit "$code"
}
writeToFile()
{
line="$1"
dst="$2"
if ! grep -qFx "${line}" "$dst"; then
printf "\n$line" >> "$dst"
fi
}
if [ "$USER" = root ]; then
profile="/etc/profile"
else
profile=~/.bashrc
fi
while getopts ":hvp:" OPT; do
case "$OPT" in
p)
profile="$OPTARG"
;;
h)
usage
;;
:)
case "${OPTARG}" in
?)
echoe "Option \`-${OPTARG}' need argument.\n"
usage 0
esac
;;
?)
echoe "Invalid option \`-${OPTARG}'.\n"
usage
;;
esac
done
shift $((OPTIND - 1))
writeToFile "export PATH=$home:"'$PATH' $profile
writeToFile 'alias rcp="remote -c"' $profile
writeToFile 'alias rssh=remote' $profile
writeToFile ". $home/remote-completion" $profile
echo "Install remote done, relogin terminal please"