Last active
May 18, 2021 06:02
-
-
Save Rishabh04-02/5591d8bfa38d2f7744d6bfd97b8c8606 to your computer and use it in GitHub Desktop.
Configuration - Installing ODK Aggregate on DigitalOcean - ODK official Documentation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Documentation followed - https://docs.opendatakit.org/aggregate-digital-ocean/ | |
# cloud-config | |
packages: | |
- zip | |
- unzip | |
- wget | |
- curl | |
- tomcat8 | |
- tomcat8-common | |
- tomcat8-admin | |
- tomcat8-user | |
- postgresql-10 | |
- openjdk-8-jdk-headless | |
- nginx | |
- software-properties-common | |
write_files: | |
- path: /root/aggregate-config.json | |
content: | | |
{ | |
"home": "/root", | |
"jdbc": { | |
"host": "0.0.0.0", | |
"port": 5432, | |
"db": "aggregate", | |
"schema": "aggregate", | |
"user": "aggregate", | |
"password": "aggregate" | |
}, | |
"security": { | |
"hostname": "preboard.aggregate.samagra.io", | |
"forceHttpsLinks": true, | |
"port": 80, | |
"securePort": 443, | |
"checkHostnames": false | |
}, | |
"tomcat": { | |
"uid": "tomcat8", | |
"gid": "tomcat8", | |
"webappsPath": "/var/lib/tomcat8/webapps" | |
} | |
} | |
- path: /tmp/nginx-aggregate | |
content: | | |
server { | |
client_max_body_size 100m; | |
server_name foo.bar; | |
location / { | |
proxy_pass http://127.0.0.1:8080; | |
} | |
} | |
- path: /usr/local/bin/download-aggregate-cli | |
permissions: '0755' | |
content: | | |
#!/bin/sh | |
curl -sS https://api.github.com/repos/opendatakit/aggregate-cli/releases/latest \ | |
| grep "aggregate-cli.zip" \ | |
| cut -d: -f 2,3 \ | |
| tr -d \" \ | |
| wget -O /tmp/aggregate-cli.zip -qi - | |
unzip /tmp/aggregate-cli.zip -d /usr/local/bin | |
chmod +x /usr/local/bin/aggregate-cli | |
runcmd: | |
- download-aggregate-cli | |
- apt-get -y remove openjdk-11-jre-headless | |
- unattended-upgrades | |
- apt-get -y autoremove | |
- rm /etc/nginx/sites-enabled/default | |
- mv /tmp/nginx-aggregate /etc/nginx/sites-enabled/aggregate | |
- add-apt-repository -y universe | |
- add-apt-repository -y ppa:certbot/certbot | |
- apt-get -y update | |
- apt-get -y install python-certbot-nginx | |
- (crontab -l 2>/dev/null; echo "0 0 1 * * /usr/bin/certbot renew > /var/log/letsencrypt/letsencrypt.log") | crontab - | |
- su postgres -c "psql -c \"CREATE ROLE aggregate WITH LOGIN PASSWORD 'aggregate'\"" | |
- su postgres -c "psql -c \"CREATE DATABASE aggregate WITH OWNER aggregate\"" | |
- su postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE aggregate TO aggregate\"" | |
- su postgres -c "psql -c \"CREATE SCHEMA aggregate\" aggregate" | |
- su postgres -c "psql -c \"ALTER SCHEMA aggregate OWNER TO aggregate\" aggregate" | |
- su postgres -c "psql -c \"GRANT ALL PRIVILEGES ON SCHEMA aggregate TO aggregate\" aggregate" | |
- sed -i -e 's/foo\.bar/'"$(curl -s http://169.254.169.254/metadata/v1/hostname)"'/' /root/aggregate-config.json | |
- sed -i -e 's/foo\.bar/'"$(curl -s http://169.254.169.254/metadata/v1/hostname)"'/' /etc/nginx/sites-enabled/aggregate | |
- aggregate-cli -i -y -c /root/aggregate-config.json | |
- service nginx restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment