From 005f52a2ac78916f0814a997a068928ebe5812da Mon Sep 17 00:00:00 2001 From: Kristian Skov Date: Thu, 12 Nov 2026 14:35:38 +0100 Subject: [PATCH] Updated ASP.NET Web App script to Debian and adds a .Net selection (#18628) * Updated scripts to Debian and adds a .Net selection * Uses `fetch_and_deploy_from_url` instead of wget * Cleanup * Sets defaults for variables * Removed unused error message for missing project name * Unbound variable fix * Improve .NET SDK installation script Refactor .NET SDK installation process and update prompts. * Update Microsoft repository keys and Nginx config --------- Co-authored-by: CanbiZ (MickLesk) <47820557+MickLesk@users.noreply.github.com> --- ct/dotnetaspwebapi.sh | 10 ++++---- install/dotnetaspwebapi-install.sh | 40 ++++++++++++++++++++---------- 2 files changed, 32 insertions(+), 18 deletions(-) diff --git a/ct/dotnetaspwebapi.sh b/ct/dotnetaspwebapi.sh index 8a89fc78d..926ed7dcd 100644 --- a/ct/dotnetaspwebapi.sh +++ b/ct/dotnetaspwebapi.sh @@ -4,17 +4,17 @@ source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_ # Copyright (c) 2021-2026 community-scripts ORG # Author: Kristian Skov # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE -# Source: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-9.0&tabs=linux-ubuntu +# Source: https://learn.microsoft.com/en-us/dotnet/core/install/linux-debian APP="Dotnet ASP Web API" var_tags="${var_tags:-web}" var_cpu="${var_cpu:-1}" var_ram="${var_ram:-1024}" var_disk="${var_disk:-8}" -var_os="${var_os:-ubuntu}" -var_version="${var_version:-24.04}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" var_arm64="${var_arm64:-yes}" -var_unprivileged="${var_unprivileged:-0}" +var_unprivileged="${var_unprivileged:-1}" header_info "$APP" variables @@ -43,4 +43,4 @@ 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 IP:${CL}" -echo -e "${GATEWAY}${BGN}${IP}:80${CL}" +echo -e "${GATEWAY}${BGN}${IP}:80${CL}" \ No newline at end of file diff --git a/install/dotnetaspwebapi-install.sh b/install/dotnetaspwebapi-install.sh index 4baab89f5..6898fd8f5 100644 --- a/install/dotnetaspwebapi-install.sh +++ b/install/dotnetaspwebapi-install.sh @@ -3,7 +3,7 @@ # Copyright (c) 2021-2026 community-scripts ORG # Author: Kristian Skov # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE -# Source: https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/linux-nginx?view=aspnetcore-9.0&tabs=linux-ubuntu +# Source: https://learn.microsoft.com/en-us/dotnet/core/install/linux-debian source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" color @@ -14,21 +14,36 @@ network_check update_os msg_info "Installing Dependencies" -apt_update_safe $STD apt install -y \ - ssh \ - software-properties-common - -$STD add-apt-repository -y ppa:dotnet/backports -$STD apt install -y \ - dotnet-sdk-9.0 \ vsftpd \ nginx msg_ok "Installed Dependencies" -var_project_name="${var_project_name:-}" -[[ -n "$var_project_name" ]] || read -r -p "${TAB3}Type the assembly name of the project: " var_project_name || true -[[ -n "$var_project_name" ]] || { msg_error "No assembly name given; set var_project_name or answer the prompt"; exit 64; } +setup_deb822_repo \ + "microsoft" \ + "https://packages.microsoft.com/keys/microsoft-2025.asc" \ + "https://packages.microsoft.com/debian/13/prod/" \ + "trixie" \ + "main" + +if [[ -z "${var_dotnet_version:-}" && -t 0 ]]; then + read -r -t 60 -p "${TAB3}.NET SDK version, 10 (LTS) or 11 [10]: " var_dotnet_version || echo +fi +var_dotnet_version="${var_dotnet_version:-10}" +var_dotnet_version="${var_dotnet_version%%.*}" +if ! apt-cache show "dotnet-sdk-${var_dotnet_version}.0" &>/dev/null; then + msg_warn ".NET SDK ${var_dotnet_version} is not available for this system, using 10" + var_dotnet_version="10" +fi + +if [[ -z "${var_project_name:-}" && -t 0 ]]; then + read -r -t 60 -p "${TAB3}Assembly name of the project [testproject]: " var_project_name || echo +fi +var_project_name="${var_project_name:-testproject}" + +msg_info "Installing .NET SDK ${var_dotnet_version}" +$STD apt install -y "dotnet-sdk-${var_dotnet_version}.0" +msg_ok "Installed .NET SDK ${var_dotnet_version}" msg_info "Setting up FTP Server" useradd ftpuser @@ -55,7 +70,7 @@ msg_ok "FTP server setup completed" msg_info "Setting up Nginx Server" rm -f /var/www/html/index.nginx-debian.html -sed "s/\$var_project_name/$var_project_name/g" >myfile <<'EOF' >/etc/nginx/sites-available/default +sed "s/\$var_project_name/$var_project_name/g" <<'EOF' >/etc/nginx/sites-available/default map $http_connection $connection_upgrade { "~*Upgrade" $http_connection; default keep-alive; @@ -87,7 +102,6 @@ Description=.NET Web API App running on Linux WorkingDirectory=/var/www/html ExecStart=/usr/bin/dotnet /var/www/html/$var_project_name.dll Restart=always -# Restart service after 10 seconds if the dotnet service crashes: RestartSec=10 KillSignal=SIGINT SyslogIdentifier=dotnet-${var_project_name}