Merge pull request #237 from elvito/main

New script: Librespeed
This commit is contained in:
CanbiZ 2025-04-26 21:16:29 +02:00 committed by GitHub
commit fd8f9bcde1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 148 additions and 0 deletions

57
ct/librespeed.sh Normal file
View File

@ -0,0 +1,57 @@
#!/usr/bin/env bash
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVED/refs/heads/main/misc/build.func)
# Copyright (c) 2021-2025 community-scripts ORG
# Author: elvito
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/librespeed/speedtest
APP="librespeed"
var_tags="speedtest"
var_cpu="1"
var_ram="512"
var_disk="4"
var_os="debian"
var_version="12"
var_unprivileged="1"
header_info "$APP"
variables
color
catch_errors
function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -f /opt/librespeed/index.html ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/librespeed/speedtest/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')
if [[ ! -f /opt/librespeed/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt//librespeed/${APP}_version.txt)" ]]; then
msg_info "Updating $APP..."
temp_file=$(mktemp)
curl -fsSL "https://github.com/librespeed/speedtest/archive/refs/tags/${RELEASE}.zip" -o $temp_file
mkdir -p /temp
unzip -qu $temp_file -d /temp
cd /temp/speedtest-${RELEASE}
cp -u favicon.ico index.html speedtest.js speedtest_worker.js /opt/librespeed/
cp -ru backend /opt/librespeed/
echo "${RELEASE}" >"/opt/librespeed/librespeed_version.txt"
systemctl restart caddy
msg_ok "$APP has been updated."
else
msg_ok "No update required. ${APP} is already at ${RELEASE}"
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,35 @@
{
"name": "Librespeed",
"slug": "librespeed",
"categories": [
4
],
"date_created": "2025-04-26",
"type": "ct",
"updateable": true,
"privileged": false,
"interface_port": 80,
"documentation": "https://github.com/librespeed/speedtest/blob/master/doc.md",
"config_path": "",
"website": "https://librespeed.org",
"logo": "https://github.com/librespeed/speedtest/blob/master/.logo/icon_huge.png",
"description": "No Flash, No Java, No Websocket, No Bullshit. This is a very lightweight speed test implemented in Javascript, using XMLHttpRequest and Web Workers.",
"install_methods": [
{
"type": "default",
"script": "ct/librespeed.sh",
"resources": {
"cpu": 1,
"ram": 512,
"hdd": 4,
"os": "Debian",
"version": "12"
}
}
],
"default_credentials": {
"username": "root",
"password": null
},
"notes": []
}

View File

@ -0,0 +1,56 @@
#!/usr/bin/env bash
# Copyright (c) 2021-2025 community-scripts ORG
# Author: elvito
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
# Source: https://github.com/librespeed/speedtest
source /dev/stdin <<< "$FUNCTIONS_FILE_PATH"
color
verb_ip6
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing Dependencies"
$STD apt-get update
$STD apt-get install -y \
caddy \
php-fpm
msg_ok "Installed Dependencies"
msg_info "Installing librespeed"
temp_file=$(mktemp)
RELEASE=$(curl -fsSL https://api.github.com/repos/librespeed/speedtest/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}')
curl -fsSL "https://github.com/librespeed/speedtest/archive/refs/tags/${RELEASE}.zip" -o $temp_file
mkdir -p /opt/librespeed
mkdir -p /temp
unzip -q $temp_file -d /temp
cd /temp/speedtest-${RELEASE}
cp -u favicon.ico index.html speedtest.js speedtest_worker.js /opt/librespeed/
cp -ru backend results /opt/librespeed/
echo "${RELEASE}" >"/opt/librespeed/librespeed_version.txt"
msg_ok "Installation completed"
msg_info "Creating Caddyfile"
cat <<EOF >/etc/caddy/Caddyfile
:80 {
root * /opt/librespeed
file_server
php_fastcgi unix//run/php/php-fpm.sock
}
EOF
systemctl restart caddy
msg_ok "Caddyfile created"
motd_ssh
customize
msg_info "Cleaning up"
rm -rf /temp
rm -f $temp_file
$STD apt-get -y autoremove
$STD apt-get -y autoclean
msg_ok "Cleaned"