-
Notifications
You must be signed in to change notification settings - Fork 1
/
install
executable file
·122 lines (109 loc) · 2.33 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!/usr/bin/env bash
# thanks RVM project for its so inspirationnal collection of bash scripts
if [[ "$*" =~ --trace ]]
then
set -x
set -o xtrace
export PS4="+ \${BASH_SOURCE} : \${FUNCNAME[0]:+\${FUNCNAME[0]}()} \${LINENO} > "
fi
typeset DEV
VERSION=0.1
CURDIR=$(pwd)
set -o errtrace
shopt -s extglob
DESTDIR="./logring"
show_version() {
echo "Logring installer v${VERSION} - https://github.com/eduvo/logring"
}
base_install() {
echo "Installing Logring in ${DESTDIR} ..."
mkdir "${DESTDIR}" 2> /dev/null
cd "${DESTDIR}"
echo "source 'https://rubygems.org'" > Gemfile
if [[ ${DEV:-0} == 0 ]]
then
echo "gem 'logring'" >> Gemfile
else
echo "gem 'logring', github: 'eduvo/logring'" >> Gemfile
fi
bundle install
if [[ $? == 0 ]]
then
echo "... all installed."
else
echo "Oops."
fi
}
slave_install() {
echo "Installing Logring in ${DESTDIR} ..."
mkdir "${DESTDIR}" 2> /dev/null
cd "${DESTDIR}"
mkdir "log" 2> /dev/null
mkdir "cache" 2> /dev/null
echo "source 'https://rubygems.org'" > Gemfile
echo "gem 'request-log-analyzer'" >> Gemfile
#bash -l -c "cd ${DESTDIR} && /usr/local/rbenv/shims/bundle install" 2>&1
if [[ $? == 0 ]]
then
echo "... all installed."
else
echo "Oops."
fi
}
install_usage() {
printf "%b" "
Usage:
${0} [options]
Options:
--dest where to install logring config and files (default to ./logring)
--dev will use local dir as gem for development purpose
--trace debug view
--help this help text
"
}
parse_args() {
while (( $# > 0 ))
do
token="$1"
shift
case "$token" in
(--dest=*)
dir="${token#*=}"
if [[ -d "${dir}" ]]
then
if [[ ! -w "${dir}" ]]
then
echo "Destination dir '${dir}' is not writable."
exit 1
fi
else
dirdir=$(dirname $dir)
if [[ ! -w "${dirdir}" ]]
then
echo "Dir '${dirdir}' is not writable."
exit 1
fi
fi
DESTDIR="${dir}"
;;
(--dev)
DEV=1
;;
(--version)
show_version
exit 0
;;
(--slave)
slave_install
exit 0
;;
(--help)
install_usage
exit 0
;;
esac
done
}
parse_args "$@"
base_install
exit 0