Skip to content

Commit

Permalink
core functionality implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
onusai committed Dec 16, 2022
1 parent ce69a09 commit 2c84cb8
Show file tree
Hide file tree
Showing 122 changed files with 6,443 additions and 422 deletions.
21 changes: 13 additions & 8 deletions .env_sample
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
# NODE_ENV options: development | production
NODE_ENV=dev
# address and port this server will listen on
LISTEN_ADDRESS=0.0.0.0
LISTEN_PORT=8081

DEV_PORT=8081
PROD_PORT=8080
# this address will be given to, and used by, IoT devices to connect to this server
# use public address for devices to connect over the internet (will require port forwarding)
# use private address for devices on your LAN
SERVER_ADDRESS=192.168.0.3

JWT_SECRET="TOP_SECRET"
# this address will be given to, and used by, IoT devices to connect to your MQTT server
MQTT_ADDRESS=192.168.0.3
MQTT_PORT=1883

# string starts with: mongodb+srv://
# mongodb connection string - starts with: mongodb+srv://
MONGODB_CONNECTION_STRING=

MQTT_ADDRESS=
MQTT_PORT=
# JWT secret
JWT_SECRET="TOP_SECRET"
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/node_modules
node_modules
.env
.vscode
.vscode
.vagrant
22 changes: 22 additions & 0 deletions database/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
v.name = "MongoDB"
end

config.vm.network "forwarded_port", guest: 27017, host: 27017
config.vm.network "private_network", ip: "192.168.56.10"

config.vm.provision "shell", path: "mongo-bootstrap.sh"
config.vm.synced_folder "./shared", "/vagrant"

config.vm.provider :virtualbox do |v|
v.customize ["modifyvm", :id, "--uart1", "0x3F8", "4"]
v.customize ["modifyvm", :id, "--uartmode1", "file", File::NULL]
end
end
49 changes: 49 additions & 0 deletions database/mongo-bootstrap.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env bash

# Adding Repo
echo "-------------------------- ADDING REPO -------------------------------------"
wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

# Updating Package Index and Installing MongoDB-5
echo "-------------------------- UPDATING PACKAGE INDEX -------------------------------------"
sudo apt update

echo "-------------------------- INSTALL PACKAGES --------------------------"
sudo apt install -y mongodb-org net-tools

# Start and Enable Mongod
echo "-------------------------- START & ENABLE MONGOD --------------------------"
sudo systemctl enable --now mongod

sleep 20

# Create user
echo "-------------------------- CREATE VAGRANT USER --------------------------"
mongosh << BLK
use admin
db.createUser(
{
user: "iothub",
pwd: "pass123",
roles: [
{ role: "userAdminAnyDatabase", db: "iothub" },
{ role: "readWriteAnyDatabase", db: "iothub" },
{ role: "dbAdminAnyDatabase", db: "iothub" },
{ role: "clusterAdmin", db: "iothub" }
]
})
exit
BLK


## Enable Authorization

sudo cat << EOB >> /etc/mongod.conf
#security:
security:
authorization: "enabled"
EOB

echo "-------------------------- RESTARTED MONGOD --------------------------"
sudo systemctl restart mongod
Loading

0 comments on commit 2c84cb8

Please sign in to comment.