diff --git a/ct/AppName.sh b/ct/AppName.sh new file mode 100644 index 0000000..f1bba65 --- /dev/null +++ b/ct/AppName.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: [YourUserName] +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: [SOURCE_URL] + +# App Default Values +APP="[APP_NAME]" +# Name of the app (e.g. Google, Adventurelog, Apache-Guacamole" +var_tags="[TAGS]" +# Tags for Proxmox VE, maximum 2 pcs., no spaces allowed, separated by a semicolon ; (e.g. database | adblock;dhcp) +var_cpu="[CPU]" +# Number of cores (1-X) (e.g. 4) - default are 2 +var_ram="[RAM]" +# Amount of used RAM in MB (e.g. 2048 or 4096) +var_disk="[DISK]" +# Amount of used disk space in GB (e.g. 4 or 10) +var_os="[OS]" +# Default OS (e.g. debian, ubuntu, alpine) +var_version="[VERSION]" +# Default OS version (e.g. 12 for debian, 24.04 for ubuntu, 3.20 for alpine) +var_unprivileged="[UNPRIVILEGED]" +# 1 = unprivileged container, 0 = privileged container + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + # Check if installation is present | -f for file, -d for folder + if [[ ! -f [INSTALLATION_CHECK_PATH] ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + # Crawling the new version and checking whether an update is required + RELEASE=$(curl -fsSL [RELEASE_URL] | [PARSE_RELEASE_COMMAND]) + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + # Stopping Services + msg_info "Stopping $APP" + systemctl stop [SERVICE_NAME] + msg_ok "Stopped $APP" + + # Creating Backup + msg_info "Creating Backup" + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" [IMPORTANT_PATHS] + msg_ok "Backup Created" + + # Execute Update + msg_info "Updating $APP to v${RELEASE}" + [UPDATE_COMMANDS] + msg_ok "Updated $APP to v${RELEASE}" + + # Starting Services + msg_info "Starting $APP" + systemctl start [SERVICE_NAME] + msg_ok "Started $APP" + + # Cleaning up + msg_info "Cleaning Up" + rm -rf [TEMP_FILES] + msg_ok "Cleanup Completed" + + # Last Action + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already at v${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}:[PORT]${CL}" diff --git a/ct/huntarr.sh b/ct/huntarr.sh index 834d4af..9d8b85e 100644 --- a/ct/huntarr.sh +++ b/ct/huntarr.sh @@ -1,15 +1,15 @@ #!/usr/bin/env bash source <(curl -fsSL https://git.bila.li/Proxmox/proxmox-ve-install-scripts/raw/branch/dev/misc/build.func) -# Copyright (c) 2021-2025 tteck -# Author: tteck (tteckster) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: [YourUserName] # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE -# Source: https://github.com/huntarr/huntarr +# Source: [SOURCE_URL] -APP="Huntarr" +APP="huntarr" var_tags="${var_tags:-arr}" var_cpu="${var_cpu:-2}" -var_ram="${var_ram:-2048}" -var_disk="${var_disk:-8}" +var_ram="${var_ram:-1024}" +var_disk="${var_disk:-4}" var_os="${var_os:-debian}" var_version="${var_version:-12}" var_unprivileged="${var_unprivileged:-1}" @@ -23,32 +23,49 @@ function update_script() { header_info check_container_storage check_container_resources - - if [[ ! -d /var/lib/huntarr/ ]]; then + + # Check if installation is present | -f for file, -d for folder + if [[ ! -f /opt/huntarr/huntarr ]]; then msg_error "No ${APP} Installation Found!" exit fi - - msg_info "Updating $APP LXC" - temp_file="$(mktemp)" - rm -rf /opt/huntarr - RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - curl -fsSL "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.tar.gz" -o "$temp_file" - $STD mkdir -p /opt/huntarr - $STD tar -xzf "$temp_file" -C /opt/huntarr --strip-components=1 - - cd /opt/huntarr - $STD npm install - $STD npm run build - chmod 775 /opt/huntarr - systemctl restart huntarr - msg_ok "Updated $APP LXC" - - msg_info "Cleaning up" - rm -rf "$temp_file" - $STD apt-get -y autoremove - $STD apt-get -y autoclean - msg_ok "Cleaned up" + + # Crawling the new version and checking whether an update is required + RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') + if [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]] || [[ ! -f /opt/${APP}_version.txt ]]; then + # Stopping Services + msg_info "Stopping $APP" + systemctl stop huntarr + msg_ok "Stopped $APP" + + # Creating Backup + msg_info "Creating Backup" + tar -czf "/opt/${APP}_backup_$(date +%F).tar.gz" /opt/huntarr + msg_ok "Backup Created" + + # Execute Update + msg_info "Updating $APP to v${RELEASE}" + curl -fsSL -o "/opt/huntarr/huntarr_${RELEASE}_linux_amd64.tar.gz" "https://github.com/plexguide/Huntarr.io/releases/download/${RELEASE}/huntarr_${RELEASE}_linux_amd64.tar.gz" + tar -xzf "/opt/huntarr/huntarr_${RELEASE}_linux_amd64.tar.gz" -C /opt/huntarr + chmod +x /opt/huntarr/huntarr + msg_ok "Updated $APP to v${RELEASE}" + + # Starting Services + msg_info "Starting $APP" + systemctl start huntarr + msg_ok "Started $APP" + + # Cleaning up + msg_info "Cleaning Up" + rm -f /opt/huntarr/huntarr_${RELEASE}_linux_amd64.tar.gz + msg_ok "Cleanup Completed" + + # Last Action + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Update Successful" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi exit } @@ -59,4 +76,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 URL:${CL}" -echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3000${CL}" \ No newline at end of file +echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:9705${CL}" diff --git a/install/AppName-install.sh b/install/AppName-install.sh new file mode 100644 index 0000000..8bb49fe --- /dev/null +++ b/install/AppName-install.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: [YourUserName] +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: [SOURCE_URL] + +# Import Functions und Setup +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +# Installing Dependencies +msg_info "Installing Dependencies" +$STD apt-get install -y \ + [PACKAGE_1] \ + [PACKAGE_2] \ + [PACKAGE_3] +msg_ok "Installed Dependencies" + +# Template: MySQL Database +msg_info "Setting up Database" +DB_NAME=[DB_NAME] +DB_USER=[DB_USER] +DB_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13) +$STD mysql -u root -e "CREATE DATABASE $DB_NAME;" +$STD mysql -u root -e "CREATE USER '$DB_USER'@'localhost' IDENTIFIED WITH mysql_native_password AS PASSWORD('$DB_PASS');" +$STD mysql -u root -e "GRANT ALL ON $DB_NAME.* TO '$DB_USER'@'localhost'; FLUSH PRIVILEGES;" +{ + echo "${APPLICATION} Credentials" + echo "Database User: $DB_USER" + echo "Database Password: $DB_PASS" + echo "Database Name: $DB_NAME" +} >>~/$APP_NAME.creds +msg_ok "Set up Database" + +# Temp + +# Setup App +msg_info "Setup ${APPLICATION}" +RELEASE=$(curl -fsSL https://api.github.com/repos/[REPO]/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') +curl -fsSL -o "${RELEASE}.zip" "https://github.com/[REPO]/archive/refs/tags/${RELEASE}.zip" +unzip -q "${RELEASE}.zip" +mv "${APPLICATION}-${RELEASE}/" "/opt/${APPLICATION}" +# +# +# +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Setup ${APPLICATION}" + +# Creating Service (if needed) +msg_info "Creating Service" +cat </etc/systemd/system/${APPLICATION}.service +[Unit] +Description=${APPLICATION} Service +After=network.target + +[Service] +ExecStart=[START_COMMAND] +Restart=always + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now ${APPLICATION} +msg_ok "Created Service" + +motd_ssh +customize + +# Cleanup +msg_info "Cleaning up" +rm -f ${RELEASE}.zip +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned" diff --git a/install/huntarr-install.sh b/install/huntarr-install.sh index 3b2af8a..5e3c313 100644 --- a/install/huntarr-install.sh +++ b/install/huntarr-install.sh @@ -1,10 +1,11 @@ #!/usr/bin/env bash -# Copyright (c) 2021-2025 tteck -# Author: tteck (tteckster) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: [YourUserName] # License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE -# Source: https://github.com/huntarr/huntarr +# Source: https://github.com/plexguide/Huntarr.io +# Import Functions und Setup source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" color verb_ip6 @@ -13,105 +14,48 @@ setting_up_container network_check update_os +# Installing Dependencies msg_info "Installing Dependencies" -$STD apt-get install -y curl wget gnupg git openjdk-17-jdk nodejs npm +$STD apt-get install -y \ + curl \ + tar \ + unzip msg_ok "Installed Dependencies" -msg_info "Installing Huntarr" -temp_file="$(mktemp)" -mkdir -p /var/lib/huntarr/ -chmod 775 /var/lib/huntarr/ - -# Korrekte API-URL für Huntarr.io (plexguide/Huntarr.io) -RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }') - -# Download der neuesten Version (angepasste URL) -curl -fsSL "https://github.com/plexguide/Huntarr.io/archive/refs/tags/${RELEASE}.tar.gz" -o "$temp_file" - -$STD mkdir -p /opt/huntarr -$STD tar -xzf "$temp_file" -C /opt/huntarr --strip-components=1 - -# Check if package.json exists -if [ ! -f "/opt/huntarr/package.json" ]; then - msg_info "Looking for package.json in subdirectories" - # Use find with better subdirectory exploration - search deeper - PACKAGE_FILES=$(find /opt/huntarr -name package.json -type f -print -quit) - - if [ -n "$PACKAGE_FILES" ]; then - # Only use dirname when we actually found the file - PACKAGE_DIR=$(dirname "$PACKAGE_FILES") - msg_info "Found package.json in $PACKAGE_DIR" - # Create symlinks or copy files to right locations - cp -R "$PACKAGE_DIR"/* /opt/huntarr/ - cd /opt/huntarr - else - # First approach failed, try the backup repository immediately - msg_error "Could not find package.json in the extracted files" - msg_info "Trying backup repository directly" - - # Clean up and try alternate repository - rm -rf /opt/huntarr - $STD mkdir -p /opt/huntarr - - # Try the known working repository - $STD curl -fsSL "https://github.com/plexguide/Huntarr.io/archive/refs/tags/6.2.23.tar.gz" -o "$temp_file" - $STD tar -xzf "$temp_file" -C /opt/huntarr --strip-components=1 - - # Verify if this worked by listing files - ls -la /opt/huntarr - - # If still no package.json, try to look more deeply - if [ ! -f "/opt/huntarr/package.json" ]; then - msg_info "Exploring repository structure" - # Find any package.json files in any subdirectory - DEEP_PACKAGE=$(find /opt/huntarr -name package.json -type f | head -n 1) - - if [ -n "$DEEP_PACKAGE" ]; then - DEEP_DIR=$(dirname "$DEEP_PACKAGE") - msg_info "Found package.json in $DEEP_DIR" - # Copy the directory containing package.json to root - cp -R "$DEEP_DIR"/* /opt/huntarr/ - else - msg_error "Failed to find package.json anywhere in the repository" - exit 1 - fi - fi - cd /opt/huntarr - fi -else - cd /opt/huntarr -fi - -# Now install after finding the correct directory -$STD npm install -$STD npm run build -chmod 775 /opt/huntarr -msg_ok "Installed Huntarr" +# Setup App +msg_info "Setup ${APPLICATION}" +RELEASE=$(curl -fsSL https://api.github.com/repos/plexguide/Huntarr.io/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3)}') +mkdir -p /opt/${APPLICATION} +curl -fsSL -o "/opt/${APPLICATION}/${APPLICATION}_${RELEASE}_linux_amd64.tar.gz" "https://github.com/plexguide/Huntarr.io/releases/download/${RELEASE}/${APPLICATION}_${RELEASE}_linux_amd64.tar.gz" +tar -xzf "/opt/${APPLICATION}/${APPLICATION}_${RELEASE}_linux_amd64.tar.gz" -C /opt/${APPLICATION} +chmod +x /opt/${APPLICATION}/${APPLICATION} +echo "${RELEASE}" >/opt/${APPLICATION}_version.txt +msg_ok "Setup ${APPLICATION}" +# Creating Service (if needed) msg_info "Creating Service" -cat </etc/systemd/system/huntarr.service +cat </etc/systemd/system/${APPLICATION}.service [Unit] -Description=Huntarr Service +Description=${APPLICATION} Service After=network.target + [Service] -UMask=0002 -Type=simple -WorkingDirectory=/opt/huntarr -ExecStart=/usr/bin/npm start -Restart=on-failure -TimeoutStopSec=20 -KillMode=process +Environment=TZ=America/New_York +ExecStart=/opt/${APPLICATION}/${APPLICATION} --config /opt/${APPLICATION} --port 9705 +Restart=always + [Install] WantedBy=multi-user.target EOF -systemctl enable -q --now huntarr +systemctl enable -q --now ${APPLICATION} msg_ok "Created Service" motd_ssh customize +# Cleanup msg_info "Cleaning up" -rm -rf "$temp_file" +rm -f ${RELEASE}.zip $STD apt-get -y autoremove $STD apt-get -y autoclean -msg_ok "Cleaned" \ No newline at end of file +msg_ok "Cleaned"