From bf3fad39848321aaf155d06beb05ff8f129d1c78 Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Tue, 6 Oct 2026 10:48:36 +0200 Subject: [PATCH] Add pricebuddy (ct) (#17708) Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> --- ct/pricebuddy.sh | 106 +++++++++++++++++++++ install/pricebuddy-install.sh | 168 ++++++++++++++++++++++++++++++++++ 2 files changed, 274 insertions(+) create mode 100644 ct/pricebuddy.sh create mode 100644 install/pricebuddy-install.sh diff --git a/ct/pricebuddy.sh b/ct/pricebuddy.sh new file mode 100644 index 000000000..3d0c001b1 --- /dev/null +++ b/ct/pricebuddy.sh @@ -0,0 +1,106 @@ +#!/usr/bin/env bash +_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func" +source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/build.func") +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/jez500/pricebuddy + +APP="PriceBuddy" +var_tags="${var_tags:-shopping;price-tracker}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-3072}" +var_disk="${var_disk:-10}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_arm64="${var_arm64:-no}" # the bundled scraper runs Google Chrome, which is amd64-only +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/pricebuddy ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "pricebuddy" "jez500/pricebuddy"; then + msg_info "Stopping PriceBuddy Worker" + systemctl stop pricebuddy-worker + msg_ok "Stopped PriceBuddy Worker" + + setup_composer + NODE_VERSION="22" setup_nodejs + + create_backup /opt/pricebuddy/.env /opt/pricebuddy/storage + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "pricebuddy" "jez500/pricebuddy" "tarball" + + restore_backup + + msg_info "Updating PriceBuddy" + cd /opt/pricebuddy + sed -i "s/^APP_VERSION=.*/APP_VERSION=$(cat ~/.pricebuddy)/" .env + $STD composer install --no-dev --optimize-autoloader --no-interaction + $STD npm install + $STD npm run build + $STD php artisan storage:link + $STD php artisan migrate --force + $STD php artisan optimize + $STD php artisan icons:cache + $STD php artisan buddy:regenerate-price-cache + chown -R www-data:www-data /opt/pricebuddy + msg_ok "Updated PriceBuddy" + + msg_info "Starting PriceBuddy Worker" + systemctl start pricebuddy-worker + msg_ok "Started PriceBuddy Worker" + msg_ok "Updated successfully!" + fi + + if check_for_gh_release "seleniumbase-scrapper" "jez500/seleniumbase-scrapper"; then + msg_info "Stopping SeleniumBase Scrapper" + systemctl stop seleniumbase-scrapper + msg_ok "Stopped SeleniumBase Scrapper" + + msg_info "Updating Google Chrome" + apt_update_safe + upgrade_packages_with_retry google-chrome-stable + msg_ok "Updated Google Chrome" + + PYTHON_VERSION="3.12" setup_uv + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "seleniumbase-scrapper" "jez500/seleniumbase-scrapper" "tarball" + + msg_info "Updating SeleniumBase Scrapper" + $STD uv venv --python 3.12 /opt/seleniumbase-scrapper/.venv + $STD uv pip install --python /opt/seleniumbase-scrapper/.venv/bin/python \ + "seleniumbase==$(sed -n 's/^ARG SELENIUMBASE_VERSION=v//p' /opt/seleniumbase-scrapper/Dockerfile)" \ + flask \ + beautifulsoup4 + $STD /opt/seleniumbase-scrapper/.venv/bin/seleniumbase get chromedriver + msg_ok "Updated SeleniumBase Scrapper" + + msg_info "Starting SeleniumBase Scrapper" + systemctl start seleniumbase-scrapper + msg_ok "Started SeleniumBase Scrapper" + 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 "${GATEWAY}${BGN}http://${IP}${CL}" +echo -e "${INFO}${YW}Log in as admin@example.com - the password is APP_USER_PASSWORD in /opt/pricebuddy/.env${CL}" diff --git a/install/pricebuddy-install.sh b/install/pricebuddy-install.sh new file mode 100644 index 000000000..8c7840030 --- /dev/null +++ b/install/pricebuddy-install.sh @@ -0,0 +1,168 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/jez500/pricebuddy + +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 \ + cron \ + xvfb +msg_ok "Installed Dependencies" + +PHP_VERSION="8.4" PHP_FPM="YES" PHP_MEMORY_LIMIT="2048M" setup_php +setup_composer +NODE_VERSION="22" setup_nodejs +setup_mariadb +MARIADB_DB_NAME="pricebuddy" MARIADB_DB_USER="pricebuddy" setup_mariadb_db +PYTHON_VERSION="3.12" setup_uv + +msg_info "Installing Google Chrome" +setup_deb822_repo \ + "google-chrome" \ + "https://dl.google.com/linux/linux_signing_key.pub" \ + "https://dl.google.com/linux/chrome/deb/" \ + "stable" +$STD apt install -y google-chrome-stable +# the package adds its own .list for the same repo, which apt rejects next to the deb822 source +rm -f /etc/apt/sources.list.d/google-chrome.list +msg_ok "Installed Google Chrome" + +fetch_and_deploy_gh_release "seleniumbase-scrapper" "jez500/seleniumbase-scrapper" "tarball" + +msg_info "Setting up SeleniumBase Scrapper" +$STD uv venv --python 3.12 /opt/seleniumbase-scrapper/.venv +# the SeleniumBase release upstream builds and tests its image against +$STD uv pip install --python /opt/seleniumbase-scrapper/.venv/bin/python \ + "seleniumbase==$(sed -n 's/^ARG SELENIUMBASE_VERSION=v//p' /opt/seleniumbase-scrapper/Dockerfile)" \ + flask \ + beautifulsoup4 +$STD /opt/seleniumbase-scrapper/.venv/bin/seleniumbase get chromedriver +msg_ok "Set up SeleniumBase Scrapper" + +fetch_and_deploy_gh_release "pricebuddy" "jez500/pricebuddy" "tarball" + +msg_info "Setting up PriceBuddy" +cd /opt/pricebuddy +cat </opt/pricebuddy/.env +APP_NAME=PriceBuddy +APP_ENV=production +APP_KEY=base64:$(openssl rand -base64 32) +APP_DEBUG=false +APP_URL=http://${LOCAL_IP} +APP_VERSION=$(cat ~/.pricebuddy) + +DB_CONNECTION=mariadb +DB_HOST=127.0.0.1 +DB_PORT=3306 +DB_DATABASE=pricebuddy +DB_USERNAME=pricebuddy +DB_PASSWORD=${MARIADB_DB_PASS} + +SCRAPER_BASE_URL=http://127.0.0.1:3000 + +APP_USER_EMAIL=admin@example.com +APP_USER_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c16) +EOF +$STD composer install --no-dev --optimize-autoloader --no-interaction +$STD npm install +$STD npm run build +$STD php artisan storage:link +# reads APP_USER_* for the admin via env(), so it has to run before optimize caches the config +$STD php artisan buddy:init-db +$STD php artisan optimize +$STD php artisan icons:cache +chown -R www-data:www-data /opt/pricebuddy +chmod 600 /opt/pricebuddy/.env +msg_ok "Set up PriceBuddy" + +msg_info "Configuring Nginx" +PHP_SOCK=$(get_php_fpm_socket) +cat </etc/nginx/sites-available/pricebuddy +server { + listen 80; + server_name _; + root /opt/pricebuddy/public; + + 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:${PHP_SOCK}; + fastcgi_param SCRIPT_FILENAME \$realpath_root\$fastcgi_script_name; + include fastcgi_params; + fastcgi_read_timeout 300; + } + + location ~ /\.(?!well-known).* { + deny all; + } +} +EOF +nginx_enable_site "pricebuddy" +msg_ok "Configured Nginx" + +msg_info "Creating Services" +cat </etc/systemd/system/seleniumbase-scrapper.service +[Unit] +Description=SeleniumBase Scrapper for PriceBuddy +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/seleniumbase-scrapper/api +Environment=API_HOST=127.0.0.1 +Environment=API_PORT=3000 +ExecStart=/opt/seleniumbase-scrapper/.venv/bin/python /opt/seleniumbase-scrapper/api/server.py +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +cat </etc/systemd/system/pricebuddy-worker.service +[Unit] +Description=PriceBuddy Queue Worker +After=network.target mariadb.service + +[Service] +Type=simple +User=www-data +Group=www-data +WorkingDirectory=/opt/pricebuddy +ExecStart=/usr/bin/php /opt/pricebuddy/artisan queue:work +Restart=always +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +cat </etc/cron.d/pricebuddy +* * * * * www-data cd /opt/pricebuddy && php artisan schedule:run >/dev/null 2>&1 +EOF +systemctl enable -q --now seleniumbase-scrapper pricebuddy-worker +msg_ok "Created Services" + +motd_ssh +customize +cleanup_lxc