couchdb/install.sh

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