-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcouchdb_setup
81 lines (68 loc) · 1.84 KB
/
couchdb_setup
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
#!/bin/bash
# couchdb_setup by Robert Starmer is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.
set -o errexit
usage() {
cat <<EOF
usage: $0 options
OPTIONS:
-h Show this message
-p http proxy i.e. -p http://username:password@host:port/
EOF
}
function run_cmd () {
if [ -z "$PROXY" ]; then
sudo $*
else
sudo env http_proxy=$PROXY $*
fi
}
APT_CONFIG="-o Acquire::http::No-Cache=True -o Acquire::BrokenProxy=true -o Acquire::Retries=3"
if [ -n "$http_proxy" ]; then
if [ -z "$https_proxy" ]; then
echo "Please set https_proxy env variable."
exit 1
fi
PROXY=$http_proxy
fi
while getopts "h:p:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
p)
PROXY=$OPTARG
export http_proxy=$PROXY
export https_proxy=$PROXY
esac
done
echo "Updated apt repository..."
if ! run_cmd apt-get $APT_CONFIG update; then
echo "Can't upadte apt repository"
exit 1
fi
echo "Installing git..."
if ! run_cmd apt-get $APT_CONFIG install -qym git; then
echo "Can't install prerequisite: git"
exit 1
fi
echo "Installing puppet..."
if ! run_cmd apt-get $APT_CONFIG install -qym puppet; then
echo "Can't install prerequisite: puppet"
exit 1
fi
echo "Cloning couchdb repository from github.com..."
if [ -d /etc/puppet/modules/couchdb ] ; then
echo -e "Wait, did you already grab the code? Perhaps just try rerunning puppet:\n\n\tpuppet apply -v -d /etc/puppet/modules/couchdb/manifests/init.pp -e \'include couchdb\'"
exit 1
fi
if ! run_cmd git clone https://github.com/robertstarmer/puppet-couchdb /etc/puppet/modules/couchdb ; then
echo "Can't run git!"
exit 1
fi
echo "Applying manifest with puppet..."
if ! "puppet apply -v -d /etc/puppet/modules/couchdb/manifests/init.pp -e 'include couchdb' "; then
echo "Can't run puppet! Please try again."
exit 1
fi