couchdb/install.sh

raw link view readme
1 yum install firewalld -y
2 sed "s/\"80\"/\"5984\"/;s/WWW (HTTP)/CouchDB/;/<description>.*/d" /usr/lib/firewalld/services/http.xml > /etc/firewalld/services/couchdb.xml
3 systemctl start firewalld
4 systemctl enable firewalld
5 firewall-cmd --permanent --zone=public --add-interface=eth0
6 firewall-cmd --reload
7 firewall-cmd --permanent --add-service=couchdb --zone=public
8 firewall-cmd --reload
9
10 yum install epel-release -y
11 yum install autoconf autoconf-archive automake curl-devel erlang-asn1 erlang-erts erlang-eunit erlang-os_mon erlang-xmerl help2man js-devel libicu-devel libtool perl-Test-Harness gcc-c++ -y
12
13 dd if=/dev/zero of=/root/temp.img bs=1M count=100
14 mkfs.xfs /root/temp.img
15 mkdir /mnt/tmp
16 mount -o loop /root/temp.img /mnt/tmp
17
18 curl -sSL http://www-us.apache.org/dist/couchdb/source/1.6.1/apache-couchdb-1.6.1.tar.gz -o /mnt/tmp/apache-couchdb-1.6.1.tar.gz
19
20 cd /mnt/tmp
21 tar -zxvf apache-couchdb-1.6.1.tar.gz
22
23 cd apache-couchdb-1.6.1
24
25 ./configure --with-erlang=/usr/lib64/erlang/usr/include
26
27 make && make install
28
29 # one file is quicker than rm -rf entire branch of nonsense
30 cd
31 umount /mnt/tmp
32 rm -f /root/temp.img
33
34 useradd --system --home /usr/local/var/lib/couchdb --no-create-home --shell /bin/bash -c "CouchDB Administrator" couchdb
35
36 chown -R couchdb:couchdb /usr/local/etc/couchdb
37 chown -R couchdb:couchdb /usr/local/var/lib/couchdb
38 chown -R couchdb:couchdb /usr/local/var/log/couchdb
39 chown -R couchdb:couchdb /usr/local/var/run/couchdb
40
41 chmod 0770 /usr/local/etc/couchdb
42 chmod 0770 /usr/local/var/lib/couchdb
43 chmod 0770 /usr/local/var/log/couchdb
44 chmod 0770 /usr/local/var/run/couchdb
45
46 cat > /usr/lib/systemd/system/couchdb.service << EOF
47 [Unit]
48 Description=CouchDB
49 Documentation=http://docs.couchdb.org/en/1.6.1/contents.html
50 Wants=network-online.target
51 After=network-online.target
52
53 [Service]
54 User=couchdb
55 Group=couchdb
56 Type=simple
57 StandardOutput=journal
58 StandardError=journal
59 Restart=always
60 StartLimitInterval=10
61 StartLimitBurst=5
62 PIDFile=/usr/local/var/run/couchdb/couchdb.pid
63 ExecStart=/usr/local/bin/couchdb -p /usr/local/var/run/couchdb/couchdb.pid
64
65 [Install]
66 WantedBy=multi-user.target
67 EOF
68
69 sed -i.original "s/bind_address =.*/bind_address = $PUBLIC_IP/" /usr/local/etc/couchdb/default.ini
70
71 systemctl start couchdb
72 systemctl enable couchdb
73
74 export PUBLIC_IP=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/')
75 curl http://$PUBLIC_IP:5984
76