Add speedtest-tracker (ct)

This commit is contained in:
push-app-to-main[bot] 2025-12-09 13:52:19 +00:00
parent f6f131efab
commit 1c175eb012
4 changed files with 294 additions and 0 deletions

View File

@ -0,0 +1,6 @@
_____ ____ __ ______ __
/ ___/____ ___ ___ ____/ / /____ _____/ /_ /_ __/________ ______/ /_____ _____
\__ \/ __ \/ _ \/ _ \/ __ / __/ _ \/ ___/ __/_____/ / / ___/ __ `/ ___/ //_/ _ \/ ___/
___/ / /_/ / __/ __/ /_/ / /_/ __(__ ) /_/_____/ / / / / /_/ / /__/ ,< / __/ /
/____/ .___/\___/\___/\__,_/\__/\___/____/\__/ /_/ /_/ \__,_/\___/_/|_|\___/_/
/_/

84
ct/speedtest-tracker.sh Normal file
View File

@ -0,0 +1,84 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: AlphaLawless
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/alexjustesen/speedtest-tracker
APP="Speedtest-Tracker"
var_tags="${var_tags:-monitoring}"
var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-2048}"
var_disk="${var_disk:-4}"
var_os="${var_os:-debian}"
var_version="${var_version:-13}"
var_unprivileged="${var_unprivileged:-1}"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -d /opt/speedtest-tracker ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
if check_for_gh_release "speedtest-tracker" "alexjustesen/speedtest-tracker"; then
PHP_VERSION="8.4" PHP_FPM="YES" PHP_MODULE="common,sqlite3,redis" setup_php
setup_composer
NODE_VERSION="22" setup_nodejs
msg_info "Stopping Service"
systemctl stop speedtest-tracker
msg_ok "Stopped Service"
msg_info "Updating Speedtest CLI"
$STD apt update
$STD apt --only-upgrade install -y speedtest
msg_ok "Updated Speedtest CLI"
msg_info "Creating Backup"
cp -r /opt/speedtest-tracker /opt/speedtest-tracker-backup
msg_ok "Backup Created"
fetch_and_deploy_gh_release "speedtest-tracker" "alexjustesen/speedtest-tracker" "tarball" "latest" "/opt/speedtest-tracker"
msg_info "Updating Speedtest Tracker"
cp -r /opt/speedtest-tracker-backup/.env /opt/speedtest-tracker/.env
cd /opt/speedtest-tracker
export COMPOSER_ALLOW_SUPERUSER=1
$STD composer install --optimize-autoloader --no-dev
$STD npm ci
$STD npm run build
$STD php artisan migrate --force
$STD php artisan config:clear
$STD php artisan cache:clear
$STD php artisan view:clear
chown -R www-data:www-data /opt/speedtest-tracker
chmod -R 755 /opt/speedtest-tracker/storage
chmod -R 755 /opt/speedtest-tracker/bootstrap/cache
msg_ok "Updated Speedtest Tracker"
msg_info "Starting Service"
systemctl start speedtest-tracker
msg_ok "Started Service"
msg_ok "Updated successfully"
fi
exit
}
start
build_container
description
msg_ok "Completed Successfully!\n"
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}${CL}"

View File

@ -0,0 +1,40 @@
{
"name": "Speedtest-Tracker",
"slug": "speedtest-tracker",
"categories": [
4
],
"date_created": "2025-01-15",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 80,
"documentation": "https://docs.speedtest-tracker.dev/",
"website": "https://github.com/alexjustesen/speedtest-tracker",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/svg/speedtest-tracker.svg",
"config_path": "/opt/speedtest-tracker/.env",
"description": "Speedtest Tracker is a self-hosted application that runs scheduled speed tests using the Ookla Speedtest CLI and saves the results to a database for historical tracking and visualization.",
"install_methods": [
{
"type": "default",
"script": "ct/speedtest-tracker.sh",
"resources": {
"cpu": 2,
"ram": 2048,
"hdd": 4,
"os": "debian",
"version": "13"
}
}
],
"default_credentials": {
"username": null,
"password": null
},
"notes": [
{
"text": "Installation path: /opt/speedtest-tracker",
"type": "info"
}
]
}

View File

@ -0,0 +1,164 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: AlphaLawless
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/alexjustesen/speedtest-tracker
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt install -y \
nginx \
sqlite3
msg_ok "Installed Dependencies"
PHP_VERSION="8.4" PHP_FPM="YES" PHP_MODULE="common,sqlite3,redis" setup_php
setup_composer
NODE_VERSION="22" setup_nodejs
fetch_and_deploy_gh_release "speedtest-tracker" "alexjustesen/speedtest-tracker" "tarball" "latest" "/opt/speedtest-tracker"
msg_info "Installing Speedtest CLI"
setup_deb822_repo \
"speedtest-cli" \
"https://packagecloud.io/ookla/speedtest-cli/gpgkey" \
"https://packagecloud.io/ookla/speedtest-cli/debian" \
"$(get_os_info codename)" \
"main"
$STD apt install -y speedtest
msg_ok "Installed Speedtest CLI"
msg_info "Configuring PHP-FPM runtime directory"
mkdir -p /etc/systemd/system/php8.4-fpm.service.d/
cat >/etc/systemd/system/php8.4-fpm.service.d/override.conf <<'EOF'
[Service]
RuntimeDirectory=php
RuntimeDirectoryMode=0755
EOF
msg_ok "Configured PHP-FPM runtime directory"
msg_info "Setting up Speedtest Tracker"
cd /opt/speedtest-tracker
CONTAINER_IP=$(hostname -I | awk '{print $1}')
APP_KEY=$(php -r "echo bin2hex(random_bytes(16));")
TIMEZONE=$(timedatectl | grep "Time zone" | awk '{print $3}')
cat <<EOF >/opt/speedtest-tracker/.env
APP_NAME="Speedtest Tracker"
APP_ENV=production
APP_TIMEZONE=${TIMEZONE}
APP_KEY=base64:$(echo -n $APP_KEY | base64)
APP_DEBUG=false
APP_URL=http://${CONTAINER_IP}
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_CONNECTION=sqlite
DB_DATABASE=/opt/speedtest-tracker/database/database.sqlite
BROADCAST_DRIVER=log
CACHE_DRIVER=file
FILESYSTEM_DISK=local
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120
SPEEDTEST_SCHEDULE="0 */6 * * *"
SPEEDTEST_SERVERS=
PRUNE_RESULTS_OLDER_THAN=0
DISPLAY_TIMEZONE=${TIMEZONE}
EOF
mkdir -p /opt/speedtest-tracker/database
touch /opt/speedtest-tracker/database/database.sqlite
export COMPOSER_ALLOW_SUPERUSER=1
$STD composer install --optimize-autoloader --no-dev
$STD npm ci
$STD npm run build
$STD php artisan key:generate --force
$STD php artisan migrate --force --seed
$STD php artisan config:clear
$STD php artisan cache:clear
$STD php artisan view:clear
chown -R www-data:www-data /opt/speedtest-tracker
chmod -R 755 /opt/speedtest-tracker/storage
chmod -R 755 /opt/speedtest-tracker/bootstrap/cache
msg_ok "Set up Speedtest Tracker"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/speedtest-tracker.service
[Unit]
Description=Speedtest Tracker Queue Worker
After=network.target
[Service]
Type=simple
User=www-data
Group=www-data
Restart=always
ExecStart=/usr/bin/php /opt/speedtest-tracker/artisan queue:work --sleep=3 --tries=3 --max-time=3600
WorkingDirectory=/opt/speedtest-tracker
[Install]
WantedBy=multi-user.target
EOF
systemctl enable -q --now speedtest-tracker
msg_ok "Created Service"
msg_info "Setting up Scheduler"
cat <<EOF >/etc/cron.d/speedtest-tracker
* * * * * www-data cd /opt/speedtest-tracker && php artisan schedule:run >> /dev/null 2>&1
EOF
msg_ok "Set up Scheduler"
msg_info "Configuring Nginx"
cat <<EOF >/etc/nginx/sites-available/speedtest-tracker
server {
listen 80;
server_name _;
root /opt/speedtest-tracker/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-Content-Type-Options "nosniff";
index index.php;
charset utf-8;
location / {
try_files \$uri \$uri/ /index.php?\$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php8.4-fpm.sock;
fastcgi_param SCRIPT_FILENAME \$realpath_root\$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.(?!well-known).* {
deny all;
}
}
EOF
ln -sf /etc/nginx/sites-available/speedtest-tracker /etc/nginx/sites-enabled/
rm -f /etc/nginx/sites-enabled/default
systemctl reload nginx
msg_ok "Configured Nginx"
motd_ssh
customize
cleanup_lxc