diff --git a/.github/workflows/dev-git-install.yaml b/.github/workflows/dev-git-install.yaml deleted file mode 100644 index 48d3324..0000000 --- a/.github/workflows/dev-git-install.yaml +++ /dev/null @@ -1,37 +0,0 @@ -name: (dev) git-install - -on: - push: - branches-ignore: - - main - paths: - - "**/install.sh" - - "**/dev-git-install.yaml" - - "**/uwsgi-sample.yaml" - -jobs: - install: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-20.04 ] - steps: - - name: Extract branch name - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - - name: Escape branch name - run: echo "##[set-output name=branch;]$(echo "${{ steps.extract_branch.outputs.branch }}" | sed 's/#/\%23/g;')" - id: escaped_extract_branch - - - name: Download specific branch's installation script and run it - run: | - wget -q "https://raw.githubusercontent.com/joseantmazonsb/linguard/${{ steps.escaped_extract_branch.outputs.branch }}/scripts/install.sh" - chmod +x install.sh - sudo ./install.sh /var/www/linguard "${{ steps.extract_branch.outputs.branch }}" - - - name: Briefly test using uWSGI - run: | - sudo -u linguard uwsgi --yaml /var/www/linguard/config/uwsgi.sample.yaml & - sleep 2s - sudo pkill -f uwsgi \ No newline at end of file diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index 50d0a45..d0564f8 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -12,6 +12,7 @@ on: - "**.js" - "**.yml" - "**.yaml" + - "**.sh" - "poetry.lock" - "pyproject.toml" @@ -43,7 +44,7 @@ jobs: run: | wget https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py python3 install-poetry.py - poetry config virtualenvs.create false + poetry config virtualenvs.in-project true poetry install --no-interaction - name: Install linux dependencies @@ -57,7 +58,25 @@ jobs: poetry run coverage run -m pytest && poetry run coverage xml - name: Upload coverage report to Codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v2 if: always() with: - files: coverage.xml \ No newline at end of file + files: coverage.xml + + - name: Build release + run: | + chmod +x build.sh + ./build.sh + + - name: Install release + run: | + cd dist + tar -xf *.tar.gz + chmod +x install.sh + sudo ./install.sh + + - name: Briefly test uwgsi (can't use service here) + run: | + sudo -u linguard /usr/bin/uwsgi --yaml /etc/linguard/config/uwsgi.yaml & + sleep 2s + sudo pkill -f uwsgi \ No newline at end of file diff --git a/.github/workflows/git-install.yaml b/.github/workflows/git-install.yaml deleted file mode 100644 index 1ab5864..0000000 --- a/.github/workflows/git-install.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: git-install - -on: - push: - branches: - - main - paths: - - "**/install.sh" - - "**/git-install.yaml" - - "**/uwsgi-sample.yaml" - -jobs: - install: - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ ubuntu-20.04 ] - steps: - - name: Download and install - run: | - wget -q https://raw.githubusercontent.com/joseantmazonsb/linguard/main/scripts/install.sh - chmod +x install.sh - sudo ./install.sh /var/www/linguard - - - name: Briefly test using uWSGI - run: | - sudo -u linguard uwsgi --yaml /var/www/linguard/config/uwsgi.sample.yaml & - sleep 2s - sudo pkill -f uwsgi \ No newline at end of file diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 3cac848..8bb44af 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -59,3 +59,21 @@ jobs: if: always() with: files: coverage.xml + + - name: Build release + run: | + chmod +x build.sh + ./build.sh + + - name: Install release + run: | + cd dist + tar -xf *.tar.gz + chmod +x install.sh + sudo ./install.sh + + - name: Briefly test uwgsi (can't use service here) + run: | + sudo -u linguard /usr/bin/uwsgi --yaml /etc/linguard/config/uwsgi.yaml & + sleep 2s + sudo pkill -f uwsgi \ No newline at end of file diff --git a/README.md b/README.md index 0fa31d3..05594e8 100644 --- a/README.md +++ b/README.md @@ -11,33 +11,26 @@ Check out [the wiki](https://github.com/joseantmazonsb/linguard/wiki) for additi ## Table of contents - [Installation](#installation) -- [Screenshots](#screenshots) - - [Git](#git) - - [Debian package](#debian-package) + - [Release](#release) - [Docker](#docker) +- [Screenshots](#screenshots) - [Contributing](#contributing) ## Installation -### Git +### Release -1. Download the installation script and run it. You must supply the installation directory (for instance, `/var/www/linguard`) and (optionally) the tag to check out. +1. Download [any release](https://github.com/joseantmazonsb/linguard/releases). + +2. Extract it and run the installation script: ```bash - wget -q https://raw.githubusercontent.com/joseantmazonsb/linguard/main/scripts/install.sh chmod +x install.sh - sudo ./install.sh [git_branch] + sudo ./install.sh ``` -2. Edit the configuration files located in `/var/www/linguard/config` to fit your needs. -3. Start linguard: +3. Run Linguard: ```bash - sudo -u linguard /var/www/linguard/scripts/run.sh + sudo systemctl start linguard.service ``` - or, if you renamed the uwsgi configuration file: - ```bash - sudo -u linguard uwsgi --yaml /path/to/uwsgi/config/file - ``` - -### Debian package ### Docker diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..b042d9a --- /dev/null +++ b/build.sh @@ -0,0 +1,79 @@ +#!/bin/bash + +source ./scripts/log.sh + +if [[ $# -gt 0 ]]; then + fatal "Invalid arguments." + info "Usage: $0" + exit 1 +fi + +OUT_DIR=$(pwd) +DIST_DIR="$OUT_DIR/dist" + +info "Creating dist folder in '$DIST_DIR'..." + +if [[ -d "$DIST_DIR" ]]; then + while true; do + warn -n "'$DIST_DIR' already exists. Shall I overwrite it? [y/n] " + read yn + case $yn in + [Yy]* ) + rm -rf "$DIST_DIR"; + if [ $? -ne 0 ]; then + fatal "Unable to overwrite '$DIST_DIR'." + exit 1 + fi + break;; + [Nn]* ) + info "Aborting..."; + exit;; + * ) echo "Please answer yes or no.";; + esac + done + if [ $? -ne 0 ]; then + fatal "Unable to overwrite '$DIST_DIR'." + exit 1 + fi +fi +mkdir -p "$DIST_DIR" + +info "Copying source code..." +CODE_DIR="$DIST_DIR/linguard" +mkdir "$CODE_DIR" +cp -r linguard/common "$CODE_DIR/common" +cp -r linguard/core "$CODE_DIR/core" +cp -r linguard/web "$CODE_DIR/web" +cp linguard/__main__.py "$CODE_DIR" +cp linguard/__init__.py "$CODE_DIR" + +info "Copying configuration files..." +cp -r systemd/ "$DIST_DIR" +CONFIG_DIR="$DIST_DIR/config" +mkdir "$CONFIG_DIR" +find config -type f | grep -E "[^.]+\.sample\.yaml" | xargs -i cp {} "$CONFIG_DIR" + +info "Exporting python requirements..." +poetry export --without-hashes -f requirements.txt -o requirements.txt +if [ $? -ne 0 ]; then + fatal "Unable to export requirements." + exit 1 +fi +mv requirements.txt "$DIST_DIR" + +info "Copying scripts..." +cp scripts/install.sh "$DIST_DIR" +cp scripts/log.sh "$DIST_DIR" + +version=$(poetry version -s) +zip_name="linguard-$version.tar.gz" + +info "Compressing package into '$zip_name'..." +cd "$DIST_DIR" +tar -czf "$zip_name" * +mv "$zip_name" .. +cd - > /dev/null +rm -rf "$DIST_DIR" +mkdir -p "$DIST_DIR" +mv "$zip_name" "$DIST_DIR" +info "Done!" \ No newline at end of file diff --git a/config/linguard.sample.yaml b/config/linguard.sample.yaml index 5ebdf9c..fd705e5 100644 --- a/config/linguard.sample.yaml +++ b/config/linguard.sample.yaml @@ -30,20 +30,20 @@ wireguard: !yamlable/wireguard private_key: 4Ob32NhyhwIXbj7od6L5ASWle3vbOjn9g80at/dxPm0= public_key: 7NTAVIucHQJsS9Z8eT3lUV8VUoTSFrB6J272F9ox5RQ= uuid: 39a855187c4c4ca694d8c3f215e76cdc - interfaces_folder: /var/www/linguard/interfaces + interfaces_folder: /etc/linguard/interfaces iptables_bin: /usr/sbin/iptables wg_bin: /usr/bin/wg wg_quick_bin: /usr/bin/wg-quick logger: !yamlable/logger - level: debug - logfile: /var/www/linguard/linguard.log + level: info + logfile: /var/log/linguard/linguard.log overwrite: false traffic: !yamlable/traffic driver: !yamlable/traffic_storage_driver_json - filepath: /var/www/linguard/traffic.json + filepath: /etc/linguard/traffic.json timestamp_format: '%d/%m/%Y %H:%M:%S' enabled: true web: !yamlable/web - credentials_file: /var/www/linguard/credentials.yaml + credentials_file: /etc/linguard/credentials.yaml login_attempts: 0 secret_key: G,XhSEIu{>TFu$y?4-kMy+ Response: @staticmethod def send_text_as_file(filename: str, text: str): - proxy = io.StringIO() - proxy.writelines(text) - # Creating the byteIO object from the StringIO Object - mem = io.BytesIO() - mem.write(proxy.getvalue().encode()) - # seeking was necessary. Python 3.5.2, Flask 0.12.2 - mem.seek(0) - proxy.close() - return send_file(mem, as_attachment=True, attachment_filename=filename, mimetype="text/plain") + wrapper = FileWrapper(io.BytesIO(text.encode())) + headers = { + 'Content-Disposition': f'attachment; filename={filename}' + } + return Response(wrapper, mimetype='text/plain', direct_passthrough=True, headers=headers) @staticmethod def save_settings(form): diff --git a/linguard/web/templates/web/settings.html b/linguard/web/templates/web/settings.html index 9ded034..c1e18dd 100644 --- a/linguard/web/templates/web/settings.html +++ b/linguard/web/templates/web/settings.html @@ -102,7 +102,7 @@

{{ title }}

- {{ app_name }} + Wireguard
diff --git a/poetry.lock b/poetry.lock index d7e63da..f22269a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -2,7 +2,7 @@ name = "atomicwrites" version = "1.4.0" description = "Atomic file writes." -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -10,7 +10,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" name = "attrs" version = "21.2.0" description = "Classes Without Boilerplate" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" @@ -63,7 +63,7 @@ python-versions = "*" name = "coverage" version = "5.5" description = "Code coverage measurement for Python" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" @@ -91,7 +91,7 @@ test = ["pytest (>=6.0)", "pytest-cov", "pytest-subtests", "pytest-xdist", "pret [[package]] name = "faker" -version = "8.12.1" +version = "8.13.2" description = "Faker is a Python package that generates fake data for you." category = "main" optional = false @@ -167,7 +167,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes name = "iniconfig" version = "1.1.1" description = "iniconfig: brain-dead simple config-ini parsing" -category = "main" +category = "dev" optional = false python-versions = "*" @@ -205,7 +205,7 @@ python-versions = ">=3.6" name = "packaging" version = "21.0" description = "Core utilities for Python packages" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -216,7 +216,7 @@ pyparsing = ">=2.0.2" name = "pluggy" version = "1.0.0" description = "plugin and hook calling mechanisms for python" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -231,7 +231,7 @@ testing = ["pytest", "pytest-benchmark"] name = "py" version = "1.10.0" description = "library with cross-python path, ini-parsing, io, code, log facilities" -category = "main" +category = "dev" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" @@ -247,7 +247,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" name = "pyparsing" version = "2.4.7" description = "Python parsing module" -category = "main" +category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" @@ -255,7 +255,7 @@ python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" name = "pytest" version = "6.2.5" description = "pytest: simple powerful testing with Python" -category = "main" +category = "dev" optional = false python-versions = ">=3.6" @@ -320,7 +320,7 @@ python-versions = "*" name = "toml" version = "0.10.2" description = "Python Library for Tom's Obvious, Minimal Language" -category = "main" +category = "dev" optional = false python-versions = ">=2.6, !=3.0.*, !=3.1.*, !=3.2.*" @@ -386,7 +386,7 @@ testing = ["pytest (>=4.6)", "pytest-checkdocs (>=2.4)", "pytest-flake8", "pytes [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "2d888670b97d45516a6bf02729a76749023e0a5266f8d19678db3d0f31ae086c" +content-hash = "364948a88602de0a0bab2ff23ee788db11fd47b5146bd3db7cda3043965773ff" [metadata.files] atomicwrites = [ @@ -530,8 +530,8 @@ cryptography = [ {file = "cryptography-3.4.8.tar.gz", hash = "sha256:94cc5ed4ceaefcbe5bf38c8fba6a21fc1d365bb8fb826ea1688e3370b2e24a1c"}, ] faker = [ - {file = "Faker-8.12.1-py3-none-any.whl", hash = "sha256:6714c153433086681b26e5c95ee314ee0fcd45ec05f2426097543dd4c70789a6"}, - {file = "Faker-8.12.1.tar.gz", hash = "sha256:810859626d19e62a2a13aa4a08d59ada131f0522431eec163b09b6df147a25b9"}, + {file = "Faker-8.13.2-py3-none-any.whl", hash = "sha256:0e41f73deb8233210b728c98b926284d3a7f51c001793e8b61f4382561971011"}, + {file = "Faker-8.13.2.tar.gz", hash = "sha256:d4492b0f84d67e76a86ce1712ec7d38ecb92f91c0ca0ac0a9f2a0c3227ab9eb2"}, ] flask = [ {file = "Flask-2.0.1-py3-none-any.whl", hash = "sha256:a6209ca15eb63fc9385f38e452704113d679511d9574d09b2cf9183ae7d20dc9"}, diff --git a/pyproject.toml b/pyproject.toml index 0d96e6c..e60aeee 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,10 +20,10 @@ PyYAML = "^5.4.1" schedule = "^1.1.0" WTForms = "^2.3.3" yamlable = "^1.0.4" -pytest = "^6.2.5" -coverage = "^5.5" [tool.poetry.dev-dependencies] +pytest = "^6.2.5" +coverage = "^5.5" [tool.coverage.run] omit = ["*/site-packages/*"] diff --git a/scripts/install.sh b/scripts/install.sh old mode 100755 new mode 100644 index 5ad3910..ca835a9 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -1,74 +1,84 @@ #!/bin/bash -bold=$(tput bold) -default=$(tput sgr0) -cyan=$(tput setaf 6) -red=$(tput setaf 1) -yellow=$(tput setaf 3) -dark_gray=$(tput setaf 8) - -function log() { - level=$1 - if [ $# -gt 2 ]; then - options=$2 - msg=$3 - else - options="" - msg=$2 - fi - case $level in - DEBUG* ) echo -e $options "${dark_gray}${bold}[DEBUG]${default} ${dark_gray}$msg${default}";; - INFO* ) echo -e $options "${cyan}${bold}[INFO]${default} ${cyan}$msg${default}";; - WARN* ) echo -e $options "${yellow}${bold}[WARN]${default} ${yellow}$msg${default}";; - ERROR* ) echo -e $options "${red}${bold}[ERROR]${default} ${red}$msg${default}";; - FATAL* ) echo -e $options "${red}${bold}[FATAL] $msg${default}";; - * ) echo "Invalid log level: '$level'";; - esac -} - -function debug() { - log DEBUG "$@" -} - -function info() { - log INFO "$@" -} - -function warn() { - log WARN "$@" -} - -function err() { - log ERROR "$@" -} - -function fatal() { - log FATAL "$@" -} +source ./log.sh if [[ $EUID -ne 0 ]]; then fatal "This script must be run as superuser! Try using sudo." exit 1 fi -if [[ $# -gt 2 ]] || [[ $# -lt 1 ]]; then +if [[ $# -gt 0 ]]; then fatal "Invalid arguments." - info "Usage: $0 [git_branch]\n\t \t| Path where Linguard will be checked out and installed.\n\t [git_branch]\t\t| Tag to download. Default: main." + info "Usage: $0" exit 1 fi -INSTALLATION_PATH=$1 -GIT_TAG=$2 -if [[ $GIT_TAG == "" ]]; then - GIT_TAG="main" +ETC_DIR="/etc/linguard" +VAR_DIR="/var/www/linguard" +LOG_DIR="/var/log/linguard" + +info "Creating '$ETC_DIR'..." + +if [[ -d "$ETC_DIR" ]]; then + while true; do + warn -n "'$ETC_DIR' already exists. Shall I overwrite it? [y/n] " + read yn + case $yn in + [Yy]* ) rm -rf "$ETC_DIR"; break;; + [Nn]* ) info "Aborting..."; exit;; + * ) echo "Please answer yes or no.";; + esac + done +fi +CONFIG_DIR="$ETC_DIR/config" +mkdir -p "$CONFIG_DIR" +cp config/linguard.sample.yaml "$CONFIG_DIR/linguard.yaml" +cp config/uwsgi.sample.yaml "$CONFIG_DIR/uwsgi.yaml" + +info "Creating '$VAR_DIR'..." + +if [[ -d "$VAR_DIR" ]]; then + while true; do + warn -n "'$VAR_DIR' already exists. Shall I overwrite it? [y/n] " + read yn + case $yn in + [Yy]* ) rm -rf "$VAR_DIR"; break;; + [Nn]* ) + info "Aborting..."; + rm -rf "$ETC_DIR" + exit;; + * ) echo "Please answer yes or no.";; + esac + done +fi +mkdir -p "$VAR_DIR" +cp -r linguard "$VAR_DIR" +cp requirements.txt "$VAR_DIR" + +info "Creating '$LOG_DIR'..." + +if [[ -d "$LOG_DIR" ]]; then + while true; do + warn -n "'$LOG_DIR' already exists. Shall I overwrite it? [y/n] " + read yn + case $yn in + [Yy]* ) rm -rf "$LOG_DIR"; break;; + [Nn]* ) + info "Aborting..."; + rm -rf "$VAR_DIR" + rm -rf "$ETC_DIR" + exit;; + * ) echo "Please answer yes or no.";; + esac + done fi -debug "Installation path set to '$INSTALLATION_PATH'." -debug "Git tag set to '$GIT_TAG'." +mkdir -p "$LOG_DIR" + info "Installing dependencies..." debug "Updating packages list..." apt-get -qq update -dependencies="curl git python3 python3-venv wireguard iptables libpcre3 libpcre3-dev uwsgi uwsgi-plugin-python3" +dependencies="python3 python3-venv wireguard iptables libpcre3 libpcre3-dev uwsgi uwsgi-plugin-python3" debug "The following packages will be installed: $dependencies" apt-get -qq install $dependencies if [ $? -ne 0 ]; then @@ -76,43 +86,17 @@ if [ $? -ne 0 ]; then exit 1 fi -info "Cloning repository in $INSTALLATION_PATH..." -clone=true -if [[ -d "$INSTALLATION_PATH" ]]; then - while true; do - warn -n "$INSTALLATION_PATH already exists. Shall I overwrite it? [y/n] " - read yn - case $yn in - [Yy]* ) rm -rf "$INSTALLATION_PATH"; break;; - [Nn]* ) clone=false; break;; - * ) echo "Please answer yes or no.";; - esac - done -fi - -if [ "$clone" = true ]; then - git clone --branch "$GIT_TAG" https://github.com/joseantmazonsb/linguard.git "$INSTALLATION_PATH" - if [ $? -ne 0 ]; then - fatal "Unable to clone repository." - exit 1 - fi -fi -cwd=$(pwd) -cd "${INSTALLATION_PATH}" info "Setting up virtual environment..." -python3 -m venv venv -source venv/bin/activate +python3 -m venv "$VAR_DIR/venv" +source "$VAR_DIR/venv/bin/activate" if [ $? -ne 0 ]; then fatal "Unable to activate virtual environment." exit 1 fi debug "Upgrading pip..." python3 -m pip install --upgrade pip -debug "Installing Poetry..." -curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/install-poetry.py | python3 - -export PATH="$HOME/.local/bin:$PATH" debug "Installing python requirements..." -poetry install --no-interaction; +python3 -m pip install -r "$VAR_DIR/requirements.txt" if [ $? -ne 0 ]; then fatal "Unable to install requirements." exit 1 @@ -122,11 +106,15 @@ deactivate info "Settings permissions..." groupadd linguard useradd -g linguard linguard -chown -R linguard:linguard . +chown -R linguard:linguard "$VAR_DIR" +chown -R linguard:linguard "$ETC_DIR" +chown -R linguard:linguard "$LOG_DIR" +chmod +x -R "$VAR_DIR/linguard/core/tools" echo "linguard ALL=(ALL) NOPASSWD: /usr/bin/wg" > /etc/sudoers.d/linguard echo "linguard ALL=(ALL) NOPASSWD: /usr/bin/wg-quick" >> /etc/sudoers.d/linguard -chmod +x scripts/run.sh -chmod +x -R linguard/core/tools -cd "$cwd" -info "DONE!" \ No newline at end of file +info "Adding linguard service..." +cp systemd/linguard.service /etc/systemd/system/ +chmod 644 /etc/systemd/system/linguard.service + +info "All set! Run 'systemctl start linguard.service' to get started." \ No newline at end of file diff --git a/scripts/log.sh b/scripts/log.sh new file mode 100644 index 0000000..1317859 --- /dev/null +++ b/scripts/log.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +bold=$(tput bold) +default=$(tput sgr0) +cyan=$(tput setaf 6) +red=$(tput setaf 1) +yellow=$(tput setaf 3) +dark_gray=$(tput setaf 8) + +function log() { + level=$1 + if [ $# -gt 2 ]; then + options=$2 + msg=$3 + else + options="" + msg=$2 + fi + case $level in + DEBUG* ) echo -e $options "${dark_gray}${bold}[DEBUG]${default} ${dark_gray}$msg${default}";; + INFO* ) echo -e $options "${cyan}${bold}[INFO]${default} ${cyan}$msg${default}";; + WARN* ) echo -e $options "${yellow}${bold}[WARN]${default} ${yellow}$msg${default}";; + ERROR* ) echo -e $options "${red}${bold}[ERROR]${default} ${red}$msg${default}";; + FATAL* ) echo -e $options "${red}${bold}[FATAL] $msg${default}";; + * ) echo "Invalid log level: '$level'";; + esac +} + +function debug() { + log DEBUG "$@" +} + +function info() { + log INFO "$@" +} + +function warn() { + log WARN "$@" +} + +function err() { + log ERROR "$@" +} + +function fatal() { + log FATAL "$@" +} \ No newline at end of file diff --git a/scripts/run.sh b/scripts/run.sh deleted file mode 100644 index 74a002c..0000000 --- a/scripts/run.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -uwsgi --yaml /var/www/linguard/config/uwsgi.sample.yaml \ No newline at end of file diff --git a/systemd/linguard.service b/systemd/linguard.service new file mode 100644 index 0000000..6c37cde --- /dev/null +++ b/systemd/linguard.service @@ -0,0 +1,12 @@ +[Unit] +Description=Linguard: Wireguard management made simple +After=network.target + +[Service] +Type=simple +Restart=always +User=linguard +ExecStart=/usr/bin/uwsgi --yaml /etc/linguard/config/uwsgi.yaml + +[Install] +WantedBy=multi-user.target \ No newline at end of file