Skip to content

Commit 5270ea3

Browse files
authored
Merge pull request #174 from opennetadmin/develop
Develop
2 parents 0ab7fd7 + 8b0bb17 commit 5270ea3

File tree

409 files changed

+53335
-17933
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

409 files changed

+53335
-17933
lines changed

.devcontainer/Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM mcr.microsoft.com/devcontainers/php:0-8.0
2+
3+
# Install MariaDB client
4+
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
5+
&& apt-get install -y mariadb-client \
6+
&& apt-get clean -y && rm -rf /var/lib/apt/lists/*
7+
8+
# Install php-mysql driver
9+
RUN docker-php-ext-install mysqli pdo pdo_mysql
10+
11+
RUN [ ! -d /var/www/html/ona ] && ln -fs /workspace/ona/www /var/www/html/ona
12+
RUN apache2ctl start
13+
14+
# run php install/installcli.php and set 127.0.0.1
15+
16+
# [Optional] Uncomment this section to install additional OS packages.
17+
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
18+
# && apt-get -y install --no-install-recommends <your-package-list-here>
19+
20+
# [Optional] Uncomment this line to install global node packages.
21+
# RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
22+

.devcontainer/README

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
I'm not sure that I will continue with the .devcontainer testing. I will
2+
leave it here for the time being.

.devcontainer/devcontainer.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
2+
// README at: https://github.com/devcontainers/templates/tree/main/src/php-mariadb
3+
{
4+
"name": "PHP & MariaDB",
5+
"dockerComposeFile": "docker-compose.yml",
6+
"service": "app",
7+
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
8+
9+
// Features to add to the dev container. More info: https://containers.dev/features.
10+
// "features": {},
11+
12+
// For use with PHP or Apache (e.g.php -S localhost:8080 or apache2ctl start)
13+
"forwardPorts": [
14+
8080,
15+
3306
16+
],
17+
"features": {
18+
"ghcr.io/devcontainers-contrib/features/neofetch:1": {}
19+
}
20+
21+
// Use 'postCreateCommand' to run commands after the container is created.
22+
// "postCreateCommand": "sudo chmod a+x \"$(pwd)\" && sudo rm -rf /var/www/html && sudo ln -s \"$(pwd)\" /var/www/html"
23+
24+
// Configure tool-specific properties.
25+
// "customizations": {},
26+
27+
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
28+
// "remoteUser": "root"
29+
}

.devcontainer/docker-compose.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: '3.8'
2+
3+
services:
4+
app:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
9+
volumes:
10+
- ../..:/workspaces:cached
11+
12+
# Overrides default command so things don't shut down after the process ends.
13+
command: sleep infinity
14+
15+
# Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function.
16+
network_mode: service:db
17+
18+
# Use "forwardPorts" in **devcontainer.json** to forward an app port locally.
19+
# (Adding the "ports" property to this file will not forward from a Codespace.)
20+
21+
db:
22+
image: mariadb:10.4
23+
restart: unless-stopped
24+
volumes:
25+
- mariadb-data:/var/lib/mysql
26+
environment:
27+
MYSQL_ROOT_PASSWORD: mariadb
28+
MYSQL_DATABASE: mariadb
29+
MYSQL_USER: mariadb
30+
MYSQL_PASSWORD: mariadb
31+
32+
# Add "forwardPorts": ["3306"] to **devcontainer.json** to forward MariaDB locally.
33+
# (Adding the "ports" property to this file will not forward from a Codespace.)
34+
35+
volumes:
36+
mariadb-data:

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,13 @@ www/*.htm
2121
cfg_archive_local
2222

2323
spool
24+
25+
*.log
26+
27+
.vagrant
28+
.DS_Store
29+
30+
# ignore vim swap files
31+
*.swp
32+
33+
.gitignore

Dockerfile

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# This Dockerfile is intended for development and testing purposes only. Not
2+
# recommended for production use.
3+
#
4+
# First: Build an image with a specific version of Ubuntu and tag it as such.
5+
# docker build --build-arg UBUNTU_VERSION=23.04 -t ona-dev:23.04 .
6+
#
7+
# Second: Start the container for general use. Point your browser to http://localhost/ona
8+
# docker run -p 80:80 -it ona-dev:23.04
9+
#
10+
# OR
11+
#
12+
# Start the container for development. Mount the current directory as a volume
13+
# This will allow you to edit the files on your host and have them be hosted
14+
# in the container
15+
# docker run -p 80:80 -it -v $(pwd):/opt/ona ona-dev:23.04
16+
#
17+
# This assumes you are in the directory you cloned the ONA repo into.
18+
# Also, if you have already installed this prior, you may need to remove
19+
# www/local/config/database_settings.conf.php to get the install to run again.
20+
21+
ARG UBUNTU_VERSION=latest
22+
FROM ubuntu:${UBUNTU_VERSION}
23+
24+
LABEL description="OpenNetAdmin development and testing docker image"
25+
LABEL Author="Matt Pascoe <[email protected]>"
26+
27+
ENV TZ=UTC
28+
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
29+
30+
RUN apt-get update
31+
RUN apt-get -y install git mariadb-server apache2 php-yaml php-gmp php-mysql libapache2-mod-php php-mbstring php-xml unzip vim sendemail jq curl && \
32+
apt-get clean && \
33+
rm -rf /var/lib/apt/lists/*
34+
35+
RUN git -C /opt clone https://github.com/opennetadmin/ona.git -b develop
36+
37+
ENV APACHE_RUN_USER www-data
38+
ENV APACHE_RUN_GROUP www-data
39+
ENV APACHE_LOG_DIR /var/log/apache2
40+
41+
RUN ln -sf /opt/ona/www /var/www/html/ona
42+
RUN rm -f /var/www/html/index.html
43+
44+
RUN touch /var/log/ona.log
45+
RUN chmod 666 /var/log/ona.log
46+
47+
RUN chown www-data /opt/ona/www/local/config
48+
49+
# Start as mariadb or mysql depending on version of Ubuntu.
50+
RUN service mariadb start || service mysql start
51+
52+
RUN echo '/opt/ona' > /etc/onabase
53+
RUN echo "\n\n\n"|php /opt/ona/install/installcli.php
54+
RUN echo "ServerName ona-dev.localhost" > /etc/apache2/conf-enabled/servername.conf
55+
56+
EXPOSE 80
57+
58+
# Since we are running mysql and apache, start them both. Also runs initial install.
59+
CMD bash -c 'service mariadb start || service mysql start && echo "\n\n\n"|php /opt/ona/install/installcli.php && /usr/sbin/apache2ctl -D FOREGROUND'

README.md

Lines changed: 53 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Thanks for your interest in OpenNetAdmin!
1616
---
1717

1818
Each host or subnet can be tracked via a centralized AJAX enabled web interface
19-
that can help reduce errors. A full [CLI interface](https://github.com/opennetadmin/dcm) is available
20-
as well to use for scripting and bulk work. We hope to provide a useful
21-
Network Management application for managing your IP subnets and hosts.
22-
Stop using spreadsheets to manage your network! Start doing proper IP
19+
that can help reduce errors. A full [CLI interface](https://github.com/opennetadmin/dcm) is available
20+
as well to use for scripting and bulk work. We hope to provide a useful
21+
Network Management application for managing your IP subnets and hosts.
22+
Stop using spreadsheets to manage your network! Start doing proper IP
2323
address management!
2424

2525
![desktop image](https://github.com/opennetadmin/ona/wiki/images/desktop.png)
@@ -32,6 +32,55 @@ your web server to serve out `/opt/ona/www`. Open it in your web browser and ru
3232

3333
Please refer to the [install page on the Github Wiki for more detail](https://github.com/opennetadmin/ona/wiki/Install)
3434

35+
DEVELOPMENT
36+
-----------
37+
You can interact with either Docker or Vagrant. Docker is is the preferred
38+
method at this time.
39+
40+
## Docker
41+
42+
Once you have cloned the repo you can issue
43+
The Dockerfile is intended for development and testing purposes only. It is not recommended for production use.
44+
45+
First: Build an image with a specific version of Ubuntu and tag it as such.
46+
```
47+
docker build --build-arg UBUNTU_VERSION=23.04 -t ona-dev:23.04 .
48+
```
49+
50+
Second: Start the container for general use. Point your browser to http://localhost/ona
51+
```
52+
docker run -p 80:80 -it ona-dev:23.04
53+
```
54+
55+
OR
56+
57+
Start the container for development. Mount the current directory as a volume. This will allow you to edit the files on your host and have them be hosted in the container
58+
```
59+
docker run -p 80:80 -it -v $(pwd):/opt/ona ona-dev:23.04
60+
```
61+
62+
This assumes you are in the directory you cloned the ONA repo into.
63+
Also, if you have already installed this prior, you may need to remove `www/local/config/database_settings.conf.php` to get the install to run again.
64+
65+
66+
## Vagrant
67+
68+
Simply clone this repo and issue a vagrant up to get a basic working system to develop with.
69+
You will need to have git and [vagrant](https://vagrantup.com) installed on your system
70+
71+
git clone https://github.com/opennetadmin/ona.git
72+
cd ona
73+
vagrant up
74+
75+
## Postman
76+
77+
There is a postman collection in the `docs` directory that can be used to interact with the API. An environment file is also provided that can be used. Simply import the collection and environment into postman or use Newman to run the collection from the command line.
78+
79+
A simple usage would be:
80+
```
81+
cd /opt/ona
82+
newman run docs/ONA-dcm.postman_collection.json -e docs/ONA-dcm-dev.postman_environment.json
83+
```
3584

3685
CONTACT
3786
-------

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.1.1
1+
v19.0.0

Vagrantfile

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# Allow user to pass in a different web port forward value.
5+
# Use when you are running multiple vms on one system
6+
PORTNUM = ENV["PORTNUM"] || "10000"
7+
8+
Vagrant.configure("2") do |config|
9+
config.vm.box = "ubuntu/jammy64"
10+
11+
# Assign this VM to a bridged network, allowing you to connect directly to a
12+
# network using the host's network device. This makes the VM appear as another
13+
# physical device on your network.
14+
# Uncomment the following if you want this VM to have its own IP
15+
#config.vm.network :bridged
16+
17+
# Create a forwarded port mapping which allows access to a specific port
18+
# within the machine from a port on the host machine. In the example below,
19+
# accessing "localhost:10000" will access port 80 on the guest machine.
20+
# NOTE: This will enable public access to the opened port
21+
config.vm.network "forwarded_port", guest: 80, host: PORTNUM , auto_correct: false
22+
23+
# Set up our repo as a synced folder
24+
config.vm.synced_folder ".", "/opt/ona"
25+
26+
# The basic install script
27+
$script = <<-SCRIPT
28+
#------- Start provision --------
29+
PORTNUM=$1
30+
31+
# Tell apt to quit its whining
32+
export DEBIAN_FRONTEND=noninteractive
33+
34+
apt-get update
35+
apt-get install -y \
36+
curl \
37+
apache2 \
38+
mariadb-server \
39+
php \
40+
php-mysql \
41+
php-mbstring \
42+
php-gmp \
43+
php-pear \
44+
libapache2-mod-php \
45+
libyaml-dev \
46+
libio-socket-ssl-perl
47+
48+
# Link in our ona code
49+
[ ! -d /var/www/html/ona ] && ln -fs /opt/ona/www /var/www/html/ona
50+
51+
# Allow others to see apache logs (and probably other stuff)
52+
#usermod -a -G adm www-data
53+
#usermod -a -G adm vagrant
54+
55+
# Set up application log file
56+
if [ ! -f /var/log/ona.log ]
57+
then
58+
touch /var/log/ona.log
59+
chmod 666 /var/log/ona.log
60+
fi
61+
62+
# restart apache so it picks up changes
63+
systemctl restart apache2.service
64+
65+
# Clean out any old configs
66+
# Re-running the provisioner will wipe out any previous configs
67+
rm -f /opt/ona/www/local/config/database_settings.inc.php
68+
69+
# Run the CLI installer with all default options
70+
echo "\n\n\n"|php /opt/ona/install/installcli.php
71+
72+
echo "
73+
74+
75+
Please point your browser to: http://localhost:${PORTNUM}/ona
76+
77+
"
78+
#------- End provision --------
79+
SCRIPT
80+
81+
# Run our shell provisioner
82+
config.vm.provision "shell", inline: $script, :args => [ PORTNUM ]
83+
84+
end
File renamed without changes.

0 commit comments

Comments
 (0)