From 7258f7bcfd38a210cae4298202f4db50fe3ddc05 Mon Sep 17 00:00:00 2001 From: Michel Roegl-Brunner Date: Wed, 10 Sep 2025 15:10:10 +0200 Subject: [PATCH] fix: Update local scripts tab to scan /scripts/ct directory - Add getCtScripts() method to ScriptManager to scan ct subdirectory - Add getCtScripts tRPC endpoint for local scripts tab - Update ScriptsList component to use getCtScripts instead of getScripts - Fix script path construction to use relative paths for terminal - Local scripts tab now correctly shows scripts from /scripts/ct folder --- scripts/ct/2fauth.sh | 3 +- scripts/ct/actualbudget.sh | 3 +- scripts/ct/adguard.sh | 42 +++++++++++++++++++++ scripts/ct/alpine-adguard.sh | 47 +++++++++++++++++++++++ scripts/install/adguard-install.sh | 50 +++++++++++++++++++++++++ src/app/_components/ScriptsList.tsx | 6 +-- src/server/api/routers/scripts.ts | 10 +++++ src/server/lib/scripts.ts | 40 ++++++++++++++++++++ src/server/services/scriptDownloader.ts | 2 +- 9 files changed, 197 insertions(+), 6 deletions(-) create mode 100644 scripts/ct/adguard.sh create mode 100644 scripts/ct/alpine-adguard.sh create mode 100644 scripts/install/adguard-install.sh diff --git a/scripts/ct/2fauth.sh b/scripts/ct/2fauth.sh index dbc0cb5..ea78683 100644 --- a/scripts/ct/2fauth.sh +++ b/scripts/ct/2fauth.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -this SCRIPT_DIR="$(dirname "$0")" source "$SCRIPT_DIR/../core/build.func" +SCRIPT_DIR="$(dirname "$0")" +source "$SCRIPT_DIR/../core/build.func" # Copyright (c) 2021-2025 community-scripts ORG # Author: jkrgr0 # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE diff --git a/scripts/ct/actualbudget.sh b/scripts/ct/actualbudget.sh index 836c935..1c24cdb 100644 --- a/scripts/ct/actualbudget.sh +++ b/scripts/ct/actualbudget.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash -this SCRIPT_DIR="$(dirname "$0")" source "$SCRIPT_DIR/../core/build.func" +SCRIPT_DIR="$(dirname "$0")" +source "$SCRIPT_DIR/../core/build.func" # Copyright (c) 2021-2025 community-scripts ORG # Author: MickLesk (CanbiZ) # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE diff --git a/scripts/ct/adguard.sh b/scripts/ct/adguard.sh new file mode 100644 index 0000000..af1ec23 --- /dev/null +++ b/scripts/ct/adguard.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +SCRIPT_DIR="$(dirname "$0")" +source "$SCRIPT_DIR/../core/build.func" +# Copyright (c) 2021-2025 tteck +# Author: tteck (tteckster) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://adguard.com/ + +APP="Adguard" +var_tags="${var_tags:-adblock}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-512}" +var_disk="${var_disk:-2}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +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/AdGuardHome ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + msg_error "Adguard Home should be updated via the user interface." + 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}:3000${CL}" \ No newline at end of file diff --git a/scripts/ct/alpine-adguard.sh b/scripts/ct/alpine-adguard.sh new file mode 100644 index 0000000..a9837bd --- /dev/null +++ b/scripts/ct/alpine-adguard.sh @@ -0,0 +1,47 @@ +#!/usr/bin/env bash +SCRIPT_DIR="$(dirname "$0")" +source "$SCRIPT_DIR/../core/build.func" +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://adguardhome.com/ + +APP="Alpine-AdGuard" +var_tags="${var_tags:-alpine;adblock}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-256}" +var_disk="${var_disk:-1}" +var_os="${var_os:-alpine}" +var_version="${var_version:-3.22}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + msg_info "Updating Alpine Packages" + $STD apk -U upgrade + msg_ok "Updated Alpine Packages" + + msg_info "Updating AdGuard Home" + $STD /opt/AdGuardHome/AdGuardHome --update + msg_ok "Updated AdGuard Home" + + msg_info "Restarting AdGuard Home" + $STD rc-service adguardhome restart + msg_ok "Restarted AdGuard Home" + + exit 0 +} + +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}:3000${CL}" diff --git a/scripts/install/adguard-install.sh b/scripts/install/adguard-install.sh new file mode 100644 index 0000000..9d8e3b7 --- /dev/null +++ b/scripts/install/adguard-install.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 tteck +# Author: tteck (tteckster) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://adguard.com/ + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing AdGuard Home" +$STD tar zxvf <(curl -fsSL https://static.adtidy.org/adguardhome/release/AdGuardHome_linux_amd64.tar.gz) -C /opt +msg_ok "Installed AdGuard Home" + +msg_info "Creating Service" +cat </etc/systemd/system/AdGuardHome.service +[Unit] +Description=AdGuard Home: Network-level blocker +ConditionFileIsExecutable=/opt/AdGuardHome/AdGuardHome +After=syslog.target network-online.target + +[Service] +StartLimitInterval=5 +StartLimitBurst=10 +ExecStart=/opt/AdGuardHome/AdGuardHome "-s" "run" +WorkingDirectory=/opt/AdGuardHome +StandardOutput=file:/var/log/AdGuardHome.out +StandardError=file:/var/log/AdGuardHome.err +Restart=always +RestartSec=10 +EnvironmentFile=-/etc/sysconfig/AdGuardHome + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now AdGuardHome +msg_ok "Created Service" + +motd_ssh +customize + +msg_info "Cleaning up" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/src/app/_components/ScriptsList.tsx b/src/app/_components/ScriptsList.tsx index 816faa3..e942952 100644 --- a/src/app/_components/ScriptsList.tsx +++ b/src/app/_components/ScriptsList.tsx @@ -10,7 +10,7 @@ interface ScriptsListProps { } export function ScriptsList({ onRunScript }: ScriptsListProps) { - const { data, isLoading, error, refetch } = api.scripts.getScripts.useQuery(); + const { data, isLoading, error, refetch } = api.scripts.getCtScripts.useQuery(); const [selectedScript, setSelectedScript] = useState(null); if (isLoading) { @@ -110,7 +110,7 @@ export function ScriptsList({ onRunScript }: ScriptsListProps) { View