initial commit.

This commit is contained in:
2023-02-03 18:27:44 +01:00
commit 831e9b124d
4 changed files with 155 additions and 0 deletions

21
README.md Normal file
View File

@@ -0,0 +1,21 @@
# speedtest-tracker
a speedtest-tracker docker-compose setup that i like.
## usage / configuration
there's not much to configure for speedtest-tracker. to setup a new `.env` file you can either run the `setup.sh` script or just copy the `env.sample` file to `.env` and configure the values the way you like. if you do the configuration manually don't forget to create the data directory.
**important**
the instructions here will not save you knowing how to handle linux systems, docker and so on. if you don't know what you are doing either ask for help or let people do it for you.
## links
* speedtest-tracker docs
https://docs.speedtest-tracker.dev/
* speedtest-tracker github repo
https://github.com/alexjustesen/speedtest-tracker
## disclaimer
speedtest-tracker is an open source project by alexjustesen and not associated with this repository. this repository aims to provide a preconfigured and git-enabled way of configuration management for it including some features that i found useful.
2023-02-03
dede

35
docker-compose.yml Normal file
View File

@@ -0,0 +1,35 @@
version: '3.8'
services:
speedtest-tracker:
container_name: speedtest-tracker
ports:
- '8080:80'
- '8443:443'
environment:
- PUID
- PGID
- DB_CONNECTION
- DB_HOST
- DB_PORT
- DB_DATABASE
- DB_USERNAME
- DB_PASSWORD
volumes:
- '/path/to/directory:/config'
image: 'ghcr.io/alexjustesen/speedtest-tracker:latest'
restart: unless-stopped
depends_on:
- db
db:
container_name: speedtest-tracker-db
image: mariadb:10
restart: always
environment:
- MARIADB_DATABASE
- MARIADB_USER
- MARIADB_PASSWORD
- MARIADB_RANDOM_ROOT_PASSWORD
volumes:
- speedtest-db:/var/lib/mysql
volumes:
speedtest-db:

19
env.sample Normal file
View File

@@ -0,0 +1,19 @@
# general
COMPOSE_PROJECT_NAME=speedtest-tracker
DATA_DIR_PATH=./data
# speedtest tracker
PUID=1000
PGID=1000
DB_CONNECTION=mysql
DB_HOST=db
DB_PORT=3306
DB_DATABASE=speedtest_tracker
DB_USERNAME=speedy
DB_PASSWORD=password
# mariadb
MARIADB_DATABASE=speedtest_tracker
MARIADB_USER=speedy
MARIADB_PASSWORD=password
MARIADB_RANDOM_ROOT_PASSWORD=true

80
setup.sh Executable file
View File

@@ -0,0 +1,80 @@
#!/bin/bash
# env setup script for docker compose .env setup
# 2023-01-06 by dede & dany
env_sample="env.sample"
dirname=$(basename "$(dirname "${BASH_SOURCE[0]}")")
echo "$dirname docker compose setup"
echo "> env setup for $dirname with docker compose"
# check for existing .env file to not break an existing setup
if [[ -f .env ]]; then
if [[ "$1" == "-f" ]]; then
echo ".env file already exists. force param is set. .env will be overwritten."
else
echo ".env file already exists. setup will not run."\
"either rename/delete it first or run this script with force param like this: "
echo "$ ./${0##*/} -f"
exit 1
fi
elif [[ ! -f $env_sample ]]; then
echo "> $env_sample file is missing. cannot run."
exit 2
fi
# create .env file
echo -e "# file generated by ${0##*/} on $(date +"%F %H:%M") by $USER\n" > .env
# step through the list of lines and ask for each key to use default value or set value
# for each line in configfile
while read -r -u 3 line; do
# keep blank and comment lines
if [[ -z $line ]] || [[ $line == \#* ]]; then
echo "$line" >> .env
# handle variable lines
else
# split line by '=' into key and value
readarray -d "=" -t currvar<<< "$line"
# preset value with default
value=${currvar[1]::-1}
# check if there's a password to generate
if [[ ${currvar[0]} =~ (PASS|PASSWORD|PWD|PASSWD)$ ]]; then
value=$(openssl rand -base64 29 | tr -d "=+/" | cut -c1-25)
fi
# ask for user input
echo -n "please enter value for ${currvar[0]} [$value]: "
read -r userinput
# set userinput as new value if any
if [ -n "$userinput" ]; then
value=$userinput
fi
# check if there's a directory to create
if [[ ${currvar[0]} =~ (DIR|DIRECTORY)$ ]]; then
if [[ ! -d $value ]]; then
echo -n "do you want to create the directory? [Y/n]: "
read -r createdir
if [[ $createdir =~ ^([yY]|)$ ]]; then
mkdir -p "$value"
echo "directory created."
fi
else
echo "directory already exists."
if [ -n "$(ls -A "$value")" ]; then
echo "WATCH OUT! the directory is NOT empty. please ensure this is intended."
fi
fi
fi
# now append the line
echo "${currvar[0]}=$value" >> .env
fi
done 3< $env_sample