Compare commits

..

2 Commits

Author SHA1 Message Date
CanbiZ
1c2b9d2513 Refactor setup_deb822_repo for clarity and efficiency
Refactor setup_deb822_repo function to improve parameter handling and error messages.
2025-11-08 19:25:10 +01:00
CanbiZ
34dac86b4b Refactor setup_deb822_repo for optional architectures
Refactor setup_deb822_repo function to make architectures optional and improve GPG key download logic.
2025-11-08 17:39:38 +01:00
5 changed files with 30 additions and 51 deletions

View File

@@ -16,7 +16,6 @@ Exercise vigilance regarding copycat or coat-tailing sites that seek to exploit
- #### 🐞 Bug Fixes - #### 🐞 Bug Fixes
- Technitium DNS: Fix update [@tremor021](https://github.com/tremor021) ([#8980](https://github.com/community-scripts/ProxmoxVE/pull/8980))
- MediaManager: add LOG_FILE to start.sh script; fix BASE_PATH and PUBLIC_API_URL [@vhsdream](https://github.com/vhsdream) ([#8981](https://github.com/community-scripts/ProxmoxVE/pull/8981)) - MediaManager: add LOG_FILE to start.sh script; fix BASE_PATH and PUBLIC_API_URL [@vhsdream](https://github.com/vhsdream) ([#8981](https://github.com/community-scripts/ProxmoxVE/pull/8981))
- Firefly: Fix missing command in update script [@tremor021](https://github.com/tremor021) ([#8972](https://github.com/community-scripts/ProxmoxVE/pull/8972)) - Firefly: Fix missing command in update script [@tremor021](https://github.com/tremor021) ([#8972](https://github.com/community-scripts/ProxmoxVE/pull/8972))
- MongoDB: Remove unused message [@tremor021](https://github.com/tremor021) ([#8969](https://github.com/community-scripts/ProxmoxVE/pull/8969)) - MongoDB: Remove unused message [@tremor021](https://github.com/tremor021) ([#8969](https://github.com/community-scripts/ProxmoxVE/pull/8969))

View File

@@ -28,11 +28,6 @@ function update_script() {
exit exit
fi fi
if is_package_installed "aspnetcore-runtime-8.0"; then
$STD apt remove -y aspnetcore-runtime-8.0
$STD apt install -y aspnetcore-runtime-9.0
fi
RELEASE=$(curl -fsSL https://technitium.com/dns/ | grep -oP 'Version \K[\d.]+') RELEASE=$(curl -fsSL https://technitium.com/dns/ | grep -oP 'Version \K[\d.]+')
if [[ ! -f ~/.technitium || "${RELEASE}" != "$(cat ~/.technitium)" ]]; then if [[ ! -f ~/.technitium || "${RELEASE}" != "$(cat ~/.technitium)" ]]; then
msg_info "Updating Technitium DNS" msg_info "Updating Technitium DNS"

View File

@@ -17,11 +17,7 @@ msg_info "Installing Dependencies"
$STD apt install -y ffmpeg $STD apt install -y ffmpeg
msg_ok "Installed Dependencies" msg_ok "Installed Dependencies"
PYTHON_VERSION="3.12" setup_uv USE_UVX="YES" PYTHON_VERSION="3.12" setup_uv
msg_info "Installing Open WebUI"
$STD uv tool install --python 3.12 open-webui[all]
msg_ok "Installed Open WebUI"
read -r -p "${TAB3}Would you like to add Ollama? <y/N> " prompt read -r -p "${TAB3}Would you like to add Ollama? <y/N> " prompt
if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then if [[ ${prompt,,} =~ ^(y|yes)$ ]]; then
@@ -60,7 +56,7 @@ After=network.target
Type=simple Type=simple
EnvironmentFile=-/root/.env EnvironmentFile=-/root/.env
Environment=DATA_DIR=/root/.open-webui Environment=DATA_DIR=/root/.open-webui
ExecStart=/root/.local/bin/open-webui serve ExecStart=/usr/local/bin/uvx --python 3.12 open-webui@latest serve
WorkingDirectory=/root WorkingDirectory=/root
Restart=on-failure Restart=on-failure
RestartSec=5 RestartSec=5

View File

@@ -18,7 +18,7 @@ curl -fsSL "https://packages.microsoft.com/config/debian/12/packages-microsoft-p
$STD dpkg -i packages-microsoft-prod.deb $STD dpkg -i packages-microsoft-prod.deb
rm -rf packages-microsoft-prod.deb rm -rf packages-microsoft-prod.deb
$STD apt update $STD apt update
$STD apt install -y aspnetcore-runtime-9.0 $STD apt install -y aspnetcore-runtime-8.0
msg_ok "Installed ASP.NET Core Runtime" msg_ok "Installed ASP.NET Core Runtime"
RELEASE=$(curl -fsSL https://technitium.com/dns/ | grep -oP 'Version \K[\d.]+') RELEASE=$(curl -fsSL https://technitium.com/dns/ | grep -oP 'Version \K[\d.]+')
@@ -26,7 +26,6 @@ msg_info "Installing Technitium DNS"
mkdir -p /opt/technitium/dns mkdir -p /opt/technitium/dns
curl -fsSL "https://download.technitium.com/dns/DnsServerPortable.tar.gz" -o /opt/DnsServerPortable.tar.gz curl -fsSL "https://download.technitium.com/dns/DnsServerPortable.tar.gz" -o /opt/DnsServerPortable.tar.gz
$STD tar zxvf /opt/DnsServerPortable.tar.gz -C /opt/technitium/dns/ $STD tar zxvf /opt/DnsServerPortable.tar.gz -C /opt/technitium/dns/
rm -f /opt/DnsServerPortable.tar.gz
echo "${RELEASE}" >~/.technitium echo "${RELEASE}" >~/.technitium
msg_ok "Installed Technitium DNS" msg_ok "Installed Technitium DNS"
@@ -37,4 +36,10 @@ msg_ok "Service created"
motd_ssh motd_ssh
customize customize
cleanup_lxc
msg_info "Cleaning up"
rm -f /opt/DnsServerPortable.tar.gz
$STD apt -y autoremove
$STD apt -y autoclean
$STD apt -y clean
msg_ok "Cleaned"

View File

@@ -1198,8 +1198,8 @@ ensure_apt_working() {
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Standardized deb822 repository setup # Standardized deb822 repository setup (with optional Architectures)
# Validates all parameters and fails safely if any are empty # Always runs apt update after repo creation to ensure package availability
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
setup_deb822_repo() { setup_deb822_repo() {
local name="$1" local name="$1"
@@ -1207,56 +1207,40 @@ setup_deb822_repo() {
local repo_url="$3" local repo_url="$3"
local suite="$4" local suite="$4"
local component="${5:-main}" local component="${5:-main}"
local architectures="${6:-$(dpkg --print-architecture)}" local architectures="$6" # optional
# Validate required parameters # Validate required parameters
if [[ -z "$name" || -z "$gpg_url" || -z "$repo_url" || -z "$suite" ]]; then if [[ -z "$name" || -z "$gpg_url" || -z "$repo_url" || -z "$suite" ]]; then
msg_error "setup_deb822_repo: missing required parameters (name=$name, gpg=$gpg_url, repo=$repo_url, suite=$suite)" msg_error "setup_deb822_repo: missing required parameters (name=$name repo=$repo_url suite=$suite)"
return 1 return 1
fi fi
# Cleanup old configs for this app # Cleanup
cleanup_old_repo_files "$name" cleanup_old_repo_files "$name"
# Cleanup any orphaned .sources files from other apps
cleanup_orphaned_sources cleanup_orphaned_sources
# Ensure keyring directory exists
mkdir -p /etc/apt/keyrings || { mkdir -p /etc/apt/keyrings || {
msg_error "Failed to create /etc/apt/keyrings directory" msg_error "Failed to create /etc/apt/keyrings"
return 1 return 1
} }
# Download GPG key (with --yes to avoid interactive prompts) # Import GPG
curl -fsSL "$gpg_url" | gpg --dearmor --yes -o "/etc/apt/keyrings/${name}.gpg" 2>/dev/null || { curl -fsSL "$gpg_url" | gpg --dearmor --yes -o "/etc/apt/keyrings/${name}.gpg" || {
msg_error "Failed to download or import GPG key for ${name} from $gpg_url" msg_error "Failed to import GPG key for ${name}"
return 1 return 1
} }
# Create deb822 sources file # Write deb822
cat <<EOF >/etc/apt/sources.list.d/${name}.sources {
Types: deb echo "Types: deb"
URIs: $repo_url echo "URIs: $repo_url"
Suites: $suite echo "Suites: $suite"
Components: $component echo "Components: $component"
Architectures: $architectures [[ -n "$architectures" ]] && echo "Architectures: $architectures"
Signed-By: /etc/apt/keyrings/${name}.gpg echo "Signed-By: /etc/apt/keyrings/${name}.gpg"
EOF } >/etc/apt/sources.list.d/${name}.sources
# Use cached apt update $STD apt update
local apt_cache_file="/var/cache/apt-update-timestamp"
local current_time=$(date +%s)
local last_update=0
if [[ -f "$apt_cache_file" ]]; then
last_update=$(cat "$apt_cache_file" 2>/dev/null || echo 0)
fi
# For repo changes, always update but respect short-term cache (30s)
if ((current_time - last_update > 30)); then
$STD apt update
echo "$current_time" >"$apt_cache_file"
fi
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------