author: Tristan Garside
date: 27-12-2022
A small database with a web frontend to manage an inventory, principally of devices (laptops, desktops, tablets and phones). Additionally the inventory will include office furniture, stationery and miscellaneous items.
As the main focus 'devices' will be richer with fields such as product IDs, OS, unique IDs, and fields relating to state and pending maintenance etc.
All CRUD operations are to be supported, and with a range of useful views.
- install snap if not already done so
$ sudo dnf install snapd
- Follow the exact instructions as described in this page in the couchdb github repo
- Stop couchdb
$ sudo snap stop couchdb
- edit the
local.ini
file to change the bind address:
sudo micro /var/snap/couchdb/9/etc/local.ini
[chttpd]
port = 5984
bind_address = 0.0.0.0
...
[httpd]
bind_address = 0.0.0.0
...
- Open port 5984 in zone 'home' and limit ip range to
local network only, via firewalld:
$ sudo firewall-cmd --zone=home --add-source=192.168.100.0/24
$ sudo firewall-cmd --zone=home --add-port=5984/tcp
$ sudo firewall-cmd --zone=home --list-all
$ sudo firewall-cmd --runtime-to-permanent
$ sudo systemctl restart firewalld
optionally pen-test the port from a computer
external to the network (when couchdb service
is running):
$ sudo nmap -sT -p 5984 <ip-address>
port should return "filtered"
-
Find and note down server ip:
ip addr | grep "inet " | tail -1
-
Restart couchdb:
sudo snap start couchdb
- See top-level view (pipe through python -mjson.tool to prettify JSON response)
curl -X GET 'http://admin:<password>@<ip-address>:5984' | python -mjson.tool
- Create a test database:
curl -X PUT 'http://admin:<password>@<ip-address>:5984/test
- Create a document:
curl -X PUT 'http://admin:<password>@<ip-address>:5984/test/doc1' -d {"name": "Polly"}
- View that document:
curl -X GET 'http://admin:<password>@<ip-address>:5984/test/doc1' | python -mjson.tool
url: <ip-address>:5984/_utils
$ sudo dnf install nodejs
npm (node package manager) is installed at ther same time
as a (weak) dependency
$ npm init
initialises the package.json which organises all the modules (dependencies)
the project will use
$ npm install express body-parser ejs node-couchdb --save