-
Notifications
You must be signed in to change notification settings - Fork 2
/
install-gems.sh
executable file
·94 lines (69 loc) · 1.38 KB
/
install-gems.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/usr/bin/env bash
set -euo pipefail
function boolean-var {
variable_name=$1
default=${2:-no}
val=${!variable_name:=$default}
if [[ "n|no|f|false|off|0" =~ $val ]]; then
echo 'false'
elif [[ "y|yes|t|true|on|1" =~ $val ]]; then
echo 'true'
else
echo "Variable \$$variable_name is set to \`$val' which is not a boolean value" >&2
echo >&2
exit 1
fi
}
if [ -z ${REMOVE_GEMS+x} ]; then
echo
echo "REMOVE_GEMS is not set. Using \"on\" by default."
remove_gems="on"
else
remove_gems=$REMOVE_GEMS
fi
gem_dir="./gems"
echo
echo "Install Gems"
echo "= = ="
if [ -z ${POSTURE+x} ]; then
echo "POSTURE is not set. Using \"operational\" by default."
posture="operational"
else
posture=$POSTURE
fi
echo "Posture: $posture"
echo "Gem Directory: $gem_dir"
echo "Remove Gems: $remove_gems"
echo
echo "Removing bundler configuration"
echo "- - -"
cmd="rm -rfv ./.bundle"
echo $cmd
($cmd)
echo
echo "Removing Gemfile.lock"
echo "- - -"
cmd="rm -fv Gemfile.lock"
echo $cmd
($cmd)
remove_gems=$(boolean-var remove_gems)
if $remove_gems; then
echo
echo "Removing installed gems"
echo "- - -"
cmd="rm -rf $gem_dir"
echo $cmd
($cmd)
fi
echo
echo "Installing bundle"
echo "- - -"
cmd="bundle install --standalone --path=./gems"
if [ operational == "$posture" ]; then
cmd="$cmd --without=development"
fi
echo $cmd
($cmd)
echo "- - -"
echo "(done)"
echo