Skip to content

Commit

Permalink
Merge pull request #1 from predly/patch-1
Browse files Browse the repository at this point in the history
Patch 1
  • Loading branch information
deepweather authored Oct 30, 2020
2 parents aa2eb2b + 41cd6b4 commit 1150179
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# init_scripts

1. Change credentials in JS file
2. Run Conda install and accept the points
3. Create and activate virtual environment
4. Run Mongo install
5. Run CDO Stack install
6 changes: 6 additions & 0 deletions gdal_cdo_pymongo_stack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,10 @@ conda install -c anaconda pymongo -y
conda install -c conda-forge cdo -y
conda install -c conda-forge fastapi -y
conda install -c conda-forge uvicorn -y
conda install -c conda-forge rasterio -y
conda install -c conda-forge geojson -y
conda install -c conda-forge dateparser -y
conda install -c conda-forge metar -y
pip3 install gdal2tiles
pip3 install haversine
pip3 install slowapi
84 changes: 84 additions & 0 deletions mongo_init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/bin/bash

# MongoDB installation

echo ##############################################
echo ##############################################
echo Starting Database Initialization
echo ##############################################
echo ##############################################
sleep 3

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 68818C72E52529D4

sudo echo "deb http://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list

sudo apt-get update

sudo apt-get install -y mongodb-org

sudo systemctl enable mongod
sudo systemctl start mongod
sleep 5

# Initialize the DB with User and PW
echo -e "\n NOTE: IF YES, THE FILE WILL BE DELETED AFTER INITIALIZATION \n YOU WILL NOT HAVE ACCESS TO THE PASSWORD AFTER THIS STEP ANYMORE\n Initialize the database with the given credentials (mongo_init_script.js)?"
read -p "(y/n)" CONT
if [ "$CONT" = "y" ]; then
echo "Okay, starting Initialization with given credentials"
sleep 1

mongo < mongo_init_script.js


sudo systemctl daemon-reload
sudo service mongod restart

# Enable authentication

echo "
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network.target
[Service]
User=mongodb
Group=mongodb
EnvironmentFile=-/etc/default/mongod
ExecStart=/usr/bin/mongod --auth --config /etc/mongod.conf
PIDFile=/var/run/mongodb/mongod.pid
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for for mongod as specified in
# http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
[Install]
WantedBy=multi-user.target" | sudo tee /lib/systemd/system/mongod.service

sudo systemctl daemon-reload
sudo service mongod restart
sudo rm mongo_init_script.js

else
echo "Okay... Database initialized without password protection."
sleep 1
fi


echo ##############################################
echo ##############################################
echo Database successfully initialized
echo ##############################################
echo ##############################################
3 changes: 3 additions & 0 deletions mongo_init_script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
use admin
db.createUser({user:"admin", pwd:"PASSWORD HERE", roles:[{role:"root", db:"admin"}]})
exit
10 changes: 10 additions & 0 deletions redis_install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
sudo apt update
sudo apt install redis-server -y
echo -e "\n Running ubuntu? Please update the following: >supervised no< to >supervised systemd<"
read -p "(y/n)" INPUT
if [ "$INPUT" = "y" ]; then
sudo vim /etc/redis/redis.conf
else
echo "Okay. Redis initialized without supervisor."
sleep 1
fi

0 comments on commit 1150179

Please sign in to comment.