Skip to content

Commit

Permalink
reorg to a more typical flask app
Browse files Browse the repository at this point in the history
  • Loading branch information
furlongm committed Aug 30, 2024
1 parent 315029f commit c788b21
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 155 deletions.
57 changes: 15 additions & 42 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,51 +1,24 @@
name: "Code scanning - action"
name: "Code Scanning - Action"

on:
push:
branches: [main]
pull_request:
schedule:
- cron: '0 15 * * 2'
branches: [main]

jobs:
CodeQL-Build:

runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# We must fetch at least the immediate parents so that if this is
# a pull request then we can checkout the head.
fetch-depth: 2

# If this run was triggered by a pull request event, then checkout
# the head of the pull request instead of the merge commit.
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
# Override language selection by uncommenting this and choosing your languages
# with:
# languages: go, javascript, csharp, python, cpp, java

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 2
- run: git checkout HEAD^2
if: ${{ github.event_name == 'pull_request' }}
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
22 changes: 10 additions & 12 deletions .github/workflows/create-release-and-upload-assets.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
check-version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: check-version
run: |
version=$(echo "${{ github.ref }}" | cut -d/ -f3)
Expand All @@ -17,7 +17,7 @@ jobs:
needs: check-version
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Create release
id: create_release
uses: actions/create-release@v1
Expand All @@ -32,26 +32,24 @@ jobs:
run: |
echo "${{ steps.create_release.outputs.upload_url }}" > upload_url.txt
- name: Upload upload_url artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: upload_url.txt
path: upload_url.txt
build-and-upload-deb-asset:
needs: create-release
runs-on: ubuntu-latest
container:
image: debian:buster
image: debian:bookworm
steps:
- name: Install build dependencies
run: |
apt update
export DEBIAN_FRONTEND=noninteractive
apt -y install python3-stdeb dh-python
# https://bugs.launchpad.net/bugs/1916551
sed -i -e "s/python-all/python3-all/g" /usr/lib/python3/dist-packages/stdeb/util.py
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Download upload_url artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: upload_url.txt
- name: Get upload_url
Expand Down Expand Up @@ -82,9 +80,9 @@ jobs:
- name: Install build dependencies
run: |
dnf -y install rpm-build python3 python3-setuptools git
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Download upload_url artifact
uses: actions/download-artifact@v2
uses: actions/download-artifact@v4
with:
name: upload_url.txt
- name: Get upload_url
Expand All @@ -110,9 +108,9 @@ jobs:
needs: create-release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
python-version: ['3.x']
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
include README.md
include openvpn-monitor.py
recursive-include openvpn_monitor *.py
include openvpn-monitor.conf.example
include AUTHORS
include COPYING
include MANIFEST.in
include VERSION.txt
include requirements.txt
recursive-include images *
recursive-include openvpn_monitor/static/images *
133 changes: 84 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,20 @@ manage remote servers.

[![](https://raw.githubusercontent.com/furlongm/openvpn-monitor/gh-pages/screenshots/openvpn-monitor.png)](https://raw.githubusercontent.com/furlongm/openvpn-monitor/gh-pages/screenshots/openvpn-monitor.png)


## Supported Operating Systems

- Ubuntu 24.04 LTS (noble)
- Debian 11 (bullseye)
- Rocky/Alma/RHEL 9


## Source

The current source code is available on github:

https://github.com/furlongm/openvpn-monitor


## Install Options
## Installation Options

- [source](#source)
- [deb/rpm](#deb--rpm)
- [virtualenv + pip + gunicorn](#virtualenv--pip--gunicorn)
- [apache](#apache)
- [docker](#docker)
- [virtualenv + pip + gunicorn](#virtualenv--pip--gunicorn)
- [nginx + uwsgi](#nginx--uwsgi)

N.B. all Rocky/Alma/RHEL instructions assume the EPEL repository has been installed:
Expand All @@ -47,34 +41,80 @@ semanage port -a -t openvpn_port_t -p tcp 5555
setsebool -P httpd_can_network_connect 1
```

### Source

### virtualenv + pip + gunicorn
Checkout the code:

```shell
# apt -y install python3-venv # (debian/ubuntu)
# dnf -y install python3 geolite2-city # (rocky/alma/rhel)
mkdir /srv/openvpn-monitor
cd /srv/openvpn-monitor
cd /var/www/html
git clone https://github.com/furlongm/openvpn-monitor
cd openvpn-monitor
yarnpkg --prod --modules-folder openvpn_monitor/static/dist install
python3 -m venv .venv
. venv/bin/activate
pip install openvpn-monitor gunicorn
gunicorn openvpn_monitor.app -b 0.0.0.0:80
pip install -r requirements.txt
```

See [configuration](#configuration) for details on configuring openvpn-monitor.
Run the development server in debug mode:

```shell
flask --app openvpn_monitor/app run --debug
```

### deb/rpm

### Ubuntu 24.04 (noble)

```shell
curl -sS https://repo.openbytes.ie/openbytes.gpg > /usr/share/keyrings/openbytes.gpg
echo "deb [signed-by=/usr/share/keyrings/openbytes.gpg] https://repo.openbytes.ie/openvpn-monitor/ubuntu noble main" > /etc/apt/sources.list.d/openvpn-monitor.list
apt update
apt -y install python3-openvpn-monitor
```

### Debian 12 (bookworm)

```shell
curl -sS https://repo.openbytes.ie/openbytes.gpg > /usr/share/keyrings/openbytes.gpg
echo "deb [signed-by=/usr/share/keyrings/openbytes.gpg] https://repo.openbytes.ie/openvpn-monitor/debian bookworm main" > /etc/apt/sources.list.d/openvpn-monitor.list
apt update
apt -y install python3-openvpn-monitor
```

### CentOS 9

This also applies to Rocky/Alma/RHEL

```shell
curl -sS https://repo.openbytes.ie/openbytes.gpg > /etc/pki/rpm-gpg/RPM-GPG-KEY-openbytes
cat <<EOF >> /etc/yum.repos.d/openvpn-monitor.repo
[openbytes]
name=openbytes
baseurl=https://repo.openbytes.ie/openvpn-monitor/el9
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-openbytes
EOF
update-crypto-policies --set DEFAULT:SHA1
dnf -y install epel-release
dnf makecache
dnf -y install python3-openvpn-monitor
systemctl restart httpd
```


### apache

#### Install dependencies and configure apache

These instructions assume a source checkout to /var/www/html/openvpn-monitor

##### Debian / Ubuntu

```shell
apt -y install git apache2 libapache2-mod-wsgi-py3 python3-geoip2 python3-humanize python3-flask python3-semver yarnpkg
a2enmod rewrite wsgi
echo "RewriteRule ^/openvpn-monitor$ /openvpn-monitor/ [R,L]" > /etc/apache2/conf-available/openvpn-monitor.conf
echo "WSGIScriptAlias /openvpn-monitor /var/www/html/openvpn-monitor/openvpn_monitor/app.py" >> /etc/apache2/conf-available/openvpn-monitor.conf
echo "WSGIScriptAlias /openvpn-monitor /var/www/html/openvpn-monitor/openvpn_monitor/app.py" > /etc/apache2/conf-available/openvpn-monitor.conf
a2enconf openvpn-monitor
service apache2 restart
```
Expand All @@ -83,20 +123,10 @@ service apache2 restart

```shell
dnf -y install git httpd mod_wsgi python3-geoip2 python3-humanize python3-flask python3-semver geolite2-city yarnpkg
echo "RewriteRule ^/openvpn-monitor$ /openvpn-monitor/ [R,L]" > /etc/httpd/conf.d/openvpn-monitor.conf
echo "WSGIScriptAlias /openvpn-monitor /var/www/html/openvpn-monitor/openvpn_monitor/app.py" >> /etc/httpd/conf.d/openvpn-monitor.conf
echo "WSGIScriptAlias /openvpn-monitor /var/www/html/openvpn-monitor/openvpn_monitor/app.py" > /etc/httpd/conf.d/openvpn-monitor.conf
systemctl restart httpd
```

#### Checkout openvpn-monitor

```shell
cd /var/www/html
git clone https://github.com/furlongm/openvpn-monitor
cd openvpn-monitor
yarnpkg --prod --modules-folder openvpn_monitor/static/dist install
```

See [configuration](#configuration) for details on configuring openvpn-monitor.


Expand All @@ -111,18 +141,29 @@ for details on how to generate a dynamic configuration using only environment
variables.


### nginx + uwsgi

#### Install dependencies
### virtualenv + pip + gunicorn

```shell
apt -y install git gcc nginx uwsgi uwsgi-plugin-python3 python3-dev python3-venv libgeoip-dev yarnpkg # (debian/ubuntu)
dnf -y install git gcc nginx uwsgi uwsgi-plugin-python3 python3-devel geolite2-city yarnpkg # (centos/rhel)
apt -y install python3-venv # (debian/ubuntu)
dnf -y install python3 geolite2-city # (rocky/alma/rhel)
mkdir /srv/openvpn-monitor
cd /srv/openvpn-monitor
python3 -m venv .venv
. venv/bin/activate
pip install openvpn-monitor gunicorn
gunicorn openvpn_monitor.app -b 0.0.0.0:80
```

#### Checkout openvpn-monitor
See [configuration](#configuration) for details on configuring openvpn-monitor.


### nginx + uwsgi

#### Install openvpn-monitor

```shell
apt -y install git gcc nginx uwsgi uwsgi-plugin-python3 python3-dev python3-venv libgeoip-dev yarnpkg # (debian/ubuntu)
dnf -y install git gcc nginx uwsgi uwsgi-plugin-python3 python3-devel geolite2-city yarnpkg # (centos/rhel)
cd /srv
git clone https://github.com/furlongm/openvpn-monitor
cd openvpn-monitor
Expand Down Expand Up @@ -201,11 +242,15 @@ access to the management interface.
### Configure openvpn-monitor

Copy the example configuration file `openvpn-monitor.conf.example` to the same
directory as app.py.
directory as app.py or to /etc/openvpn-monitor/openvpn-monitor.conf

```shell
cp openvpn-monitor.conf.example openvpn_monitor/openvpn-monitor.conf

```
or
```shell
mkdir -p /etc/openvpn-monitor
cp openvpn-monitor.conf.example /etc/openvpn_monitor/openvpn-monitor.conf
```

In this file you can set site name, add a logo, set the default map location
Expand All @@ -214,16 +259,6 @@ In this file you can set site name, add a logo, set the default map location
Once configured, navigate to `http://myipaddress/openvpn-monitor/`


### Development / Debugging

openvpn-monitor can be run from the command line for development / debugging
purposes:

```shell
cd /var/www/html/openvpn-monitor
flask --app openvpn_monitor/app run --debug
```

## License

openvpn-monitor is licensed under the GPLv3, a copy of which can be found in
Expand Down
Loading

0 comments on commit c788b21

Please sign in to comment.