mirror of
				https://github.com/community-scripts/ProxmoxVE.git
				synced 2025-11-04 02:12:49 +00:00 
			
		
		
		
	bitmagnet (#4493)
* 'Add new script' * -fsSL * -fsSL * add alpine bitmagnet * add alpine bitmagnet * Update alpine-bitmagnet.sh * Update alpine-bitmagnet-install.sh * Update alpine-bitmagnet.sh * Update bitmagnet.sh * Update bitmagnet.json --------- Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> Co-authored-by: CanbiZ <47820557+MickLesk@users.noreply.github.com> Co-authored-by: Slaviša Arežina <58952836+tremor021@users.noreply.github.com>
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							4fd065a4bd
						
					
				
				
					commit
					de9ae6eaa9
				
			
							
								
								
									
										89
									
								
								ct/alpine-bitmagnet.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										89
									
								
								ct/alpine-bitmagnet.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,89 @@
 | 
				
			|||||||
 | 
					#!/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: Slaviša Arežina (tremor021)
 | 
				
			||||||
 | 
					# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
 | 
					# Source: https://github.com/bitmagnet-io/bitmagnet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					APP="Alpine-bitmagnet"
 | 
				
			||||||
 | 
					var_tags="${var_tags:-alpine;torrent}"
 | 
				
			||||||
 | 
					var_cpu="${var_cpu:-2}"
 | 
				
			||||||
 | 
					var_ram="${var_ram:-1024}"
 | 
				
			||||||
 | 
					var_disk="${var_disk:-3}"
 | 
				
			||||||
 | 
					var_os="${var_os:-alpine}"
 | 
				
			||||||
 | 
					var_version="${var_version:-3.21}"
 | 
				
			||||||
 | 
					var_unprivileged="${var_unprivileged:-1}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					header_info "$APP"
 | 
				
			||||||
 | 
					variables
 | 
				
			||||||
 | 
					color
 | 
				
			||||||
 | 
					catch_errors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function update_script() {
 | 
				
			||||||
 | 
					  header_info
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  if [[ ! -d /opt/bitmagnet ]]; then
 | 
				
			||||||
 | 
					    msg_error "No ${APP} Installation Found!"
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					  RELEASE=$(curl -fsSL https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
				
			||||||
 | 
					  if [ "${RELEASE}" != "$(cat /opt/bitmagnet_version.txt)" ] || [ ! -f /opt/bitmagnet_version.txt ]; then
 | 
				
			||||||
 | 
					    msg_info "Backing up database"
 | 
				
			||||||
 | 
					    rm -f /tmp/backup.sql
 | 
				
			||||||
 | 
					    $STD sudo -u postgres pg_dump \
 | 
				
			||||||
 | 
					      --column-inserts \
 | 
				
			||||||
 | 
					      --data-only \
 | 
				
			||||||
 | 
					      --on-conflict-do-nothing \
 | 
				
			||||||
 | 
					      --rows-per-insert=1000 \
 | 
				
			||||||
 | 
					      --table=metadata_sources \
 | 
				
			||||||
 | 
					      --table=content \
 | 
				
			||||||
 | 
					      --table=content_attributes \
 | 
				
			||||||
 | 
					      --table=content_collections \
 | 
				
			||||||
 | 
					      --table=content_collections_content \
 | 
				
			||||||
 | 
					      --table=torrent_sources \
 | 
				
			||||||
 | 
					      --table=torrents \
 | 
				
			||||||
 | 
					      --table=torrent_files \
 | 
				
			||||||
 | 
					      --table=torrent_hints \
 | 
				
			||||||
 | 
					      --table=torrent_contents \
 | 
				
			||||||
 | 
					      --table=torrent_tags \
 | 
				
			||||||
 | 
					      --table=torrents_torrent_sources \
 | 
				
			||||||
 | 
					      --table=key_values \
 | 
				
			||||||
 | 
					      bitmagnet \
 | 
				
			||||||
 | 
					      >/tmp/backup.sql
 | 
				
			||||||
 | 
					    mv /tmp/backup.sql /opt/
 | 
				
			||||||
 | 
					    msg_ok "Database backed up"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    msg_info "Updating ${APP} from $(cat /opt/bitmagnet_version.txt) to ${RELEASE}"
 | 
				
			||||||
 | 
					    $STD apk -U upgrade
 | 
				
			||||||
 | 
					    $STD service bitmagnet stop
 | 
				
			||||||
 | 
					    [ -f /opt/bitmagnet/.env ] && cp /opt/bitmagnet/.env /opt/
 | 
				
			||||||
 | 
					    [ -f /opt/bitmagnet/config.yml ] && cp /opt/bitmagnet/config.yml /opt/
 | 
				
			||||||
 | 
					    rm -rf /opt/bitmagnet/*
 | 
				
			||||||
 | 
					    temp_file=$(mktemp)
 | 
				
			||||||
 | 
					    curl -fsSL "https://github.com/bitmagnet-io/bitmagnet/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
 | 
				
			||||||
 | 
					    tar zxf "$temp_file" --strip-components=1 -C /opt/bitmagnet
 | 
				
			||||||
 | 
					    cd /opt/bitmagnet
 | 
				
			||||||
 | 
					    VREL=v$RELEASE
 | 
				
			||||||
 | 
					    $STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL"
 | 
				
			||||||
 | 
					    chmod +x bitmagnet
 | 
				
			||||||
 | 
					    [ -f "/opt/.env" ] && cp "/opt/.env" /opt/bitmagnet/
 | 
				
			||||||
 | 
					    [ -f "/opt/config.yml" ] && cp "/opt/config.yml" /opt/bitmagnet/
 | 
				
			||||||
 | 
					    rm -f "$temp_file"
 | 
				
			||||||
 | 
					    echo "${RELEASE}" >/opt/bitmagnet_version.txt
 | 
				
			||||||
 | 
					    $STD service bitmagnet start
 | 
				
			||||||
 | 
					    msg_ok "Updated Successfully"
 | 
				
			||||||
 | 
					  else
 | 
				
			||||||
 | 
					    msg_ok "No update required. ${APP} is already at ${RELEASE}"
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  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 IP:${CL}"
 | 
				
			||||||
 | 
					echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3333${CL}"
 | 
				
			||||||
							
								
								
									
										98
									
								
								ct/bitmagnet.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										98
									
								
								ct/bitmagnet.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,98 @@
 | 
				
			|||||||
 | 
					#!/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: Slaviša Arežina (tremor021)
 | 
				
			||||||
 | 
					# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
 | 
					# Source: https://github.com/bitmagnet/bitmagnet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					APP="Bitmagnet"
 | 
				
			||||||
 | 
					var_tags="${var_tags:-os}"
 | 
				
			||||||
 | 
					var_cpu="${var_cpu:-2}"
 | 
				
			||||||
 | 
					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}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					header_info "$APP"
 | 
				
			||||||
 | 
					variables
 | 
				
			||||||
 | 
					color
 | 
				
			||||||
 | 
					catch_errors
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function update_script() {
 | 
				
			||||||
 | 
					  header_info
 | 
				
			||||||
 | 
					  check_container_storage
 | 
				
			||||||
 | 
					  check_container_resources
 | 
				
			||||||
 | 
					  if [[ ! -d /opt/bitmagnet ]]; then
 | 
				
			||||||
 | 
					    msg_error "No ${APP} Installation Found!"
 | 
				
			||||||
 | 
					    exit
 | 
				
			||||||
 | 
					  fi
 | 
				
			||||||
 | 
					  RELEASE=$(curl -fsSL https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
				
			||||||
 | 
					  if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
 | 
				
			||||||
 | 
					    msg_info "Stopping Service"
 | 
				
			||||||
 | 
					    systemctl stop bitmagnet-web
 | 
				
			||||||
 | 
					    msg_ok "Stopped Service"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    msg_info "Backing up database"
 | 
				
			||||||
 | 
					    rm -f /tmp/backup.sql
 | 
				
			||||||
 | 
					    $STD sudo -u postgres pg_dump \
 | 
				
			||||||
 | 
					      --column-inserts \
 | 
				
			||||||
 | 
					      --data-only \
 | 
				
			||||||
 | 
					      --on-conflict-do-nothing \
 | 
				
			||||||
 | 
					      --rows-per-insert=1000 \
 | 
				
			||||||
 | 
					      --table=metadata_sources \
 | 
				
			||||||
 | 
					      --table=content \
 | 
				
			||||||
 | 
					      --table=content_attributes \
 | 
				
			||||||
 | 
					      --table=content_collections \
 | 
				
			||||||
 | 
					      --table=content_collections_content \
 | 
				
			||||||
 | 
					      --table=torrent_sources \
 | 
				
			||||||
 | 
					      --table=torrents \
 | 
				
			||||||
 | 
					      --table=torrent_files \
 | 
				
			||||||
 | 
					      --table=torrent_hints \
 | 
				
			||||||
 | 
					      --table=torrent_contents \
 | 
				
			||||||
 | 
					      --table=torrent_tags \
 | 
				
			||||||
 | 
					      --table=torrents_torrent_sources \
 | 
				
			||||||
 | 
					      --table=key_values \
 | 
				
			||||||
 | 
					      bitmagnet \
 | 
				
			||||||
 | 
					      >/tmp/backup.sql
 | 
				
			||||||
 | 
					    mv /tmp/backup.sql /opt/
 | 
				
			||||||
 | 
					    msg_ok "Database backed up"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    msg_info "Updating ${APP} to v${RELEASE}"
 | 
				
			||||||
 | 
					    [ -f /opt/bitmagnet/.env ] && cp /opt/bitmagnet/.env /opt/
 | 
				
			||||||
 | 
					    [ -f /opt/bitmagnet/config.yml ] && cp /opt/bitmagnet/config.yml /opt/
 | 
				
			||||||
 | 
					    rm -rf /opt/bitmagnet/*
 | 
				
			||||||
 | 
					    temp_file=$(mktemp)
 | 
				
			||||||
 | 
					    curl -fsSL "https://github.com/bitmagnet-io/bitmagnet/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
 | 
				
			||||||
 | 
					    tar zxf "$temp_file" --strip-components=1 -C /opt/bitmagnet
 | 
				
			||||||
 | 
					    cd /opt/bitmagnet
 | 
				
			||||||
 | 
					    VREL=v$RELEASE
 | 
				
			||||||
 | 
					    $STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL"
 | 
				
			||||||
 | 
					    chmod +x bitmagnet
 | 
				
			||||||
 | 
					    [ -f "/opt/.env" ] && cp "/opt/.env" /opt/bitmagnet/
 | 
				
			||||||
 | 
					    [ -f "/opt/config.yml" ] && cp "/opt/config.yml" /opt/bitmagnet/
 | 
				
			||||||
 | 
					    echo "${RELEASE}" >/opt/${APP}_version.txt
 | 
				
			||||||
 | 
					    msg_ok "Updated $APP to v${RELEASE}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    msg_info "Starting Service"
 | 
				
			||||||
 | 
					    systemctl start bitmagnet-web
 | 
				
			||||||
 | 
					    msg_ok "Started Service"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    msg_info "Cleaning up"
 | 
				
			||||||
 | 
					    rm -f "$temp_file"
 | 
				
			||||||
 | 
					    msg_ok "Cleaned"
 | 
				
			||||||
 | 
					    msg_ok "Updated Successfully"
 | 
				
			||||||
 | 
					  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}:3333${CL}"
 | 
				
			||||||
							
								
								
									
										6
									
								
								ct/headers/bitmagnet
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								ct/headers/bitmagnet
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,6 @@
 | 
				
			|||||||
 | 
					    ____  _ __                                   __ 
 | 
				
			||||||
 | 
					   / __ )(_) /_____ ___  ____ _____ _____  ___  / /_
 | 
				
			||||||
 | 
					  / __  / / __/ __ `__ \/ __ `/ __ `/ __ \/ _ \/ __/
 | 
				
			||||||
 | 
					 / /_/ / / /_/ / / / / / /_/ / /_/ / / / /  __/ /_  
 | 
				
			||||||
 | 
					/_____/_/\__/_/ /_/ /_/\__,_/\__, /_/ /_/\___/\__/  
 | 
				
			||||||
 | 
					                            /____/                  
 | 
				
			||||||
							
								
								
									
										51
									
								
								frontend/public/json/bitmagnet.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										51
									
								
								frontend/public/json/bitmagnet.json
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,51 @@
 | 
				
			|||||||
 | 
					{
 | 
				
			||||||
 | 
					  "name": "Bitmagnet",
 | 
				
			||||||
 | 
					  "slug": "bitmagnet",
 | 
				
			||||||
 | 
					  "categories": [
 | 
				
			||||||
 | 
					    11
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "date_created": "2025-05-13",
 | 
				
			||||||
 | 
					  "type": "ct",
 | 
				
			||||||
 | 
					  "updateable": true,
 | 
				
			||||||
 | 
					  "privileged": false,
 | 
				
			||||||
 | 
					  "interface_port": 3333,
 | 
				
			||||||
 | 
					  "documentation": "https://bitmagnet.io/setup.html",
 | 
				
			||||||
 | 
					  "website": "https://bitmagnet.io/",
 | 
				
			||||||
 | 
					  "logo": "https://raw.githubusercontent.com/selfhst/icons/refs/heads/main/webp/bitmagnet.webp",
 | 
				
			||||||
 | 
					  "config_path": "`/opt/bitmagnet/config.yml` or `/opt/bitmagnet/.env`",
 | 
				
			||||||
 | 
					  "description": "A self-hosted BitTorrent indexer, DHT crawler, content classifier and torrent search engine with web UI, GraphQL API and Servarr stack integration.",
 | 
				
			||||||
 | 
					  "install_methods": [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      "type": "default",
 | 
				
			||||||
 | 
					      "script": "ct/bitmagnet.sh",
 | 
				
			||||||
 | 
					      "resources": {
 | 
				
			||||||
 | 
					        "cpu": 2,
 | 
				
			||||||
 | 
					        "ram": 1024,
 | 
				
			||||||
 | 
					        "hdd": 4,
 | 
				
			||||||
 | 
					        "os": "debian",
 | 
				
			||||||
 | 
					        "version": "12"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      "type": "alpine",
 | 
				
			||||||
 | 
					      "script": "ct/alpine-bitmagnet.sh",
 | 
				
			||||||
 | 
					      "resources": {
 | 
				
			||||||
 | 
					        "cpu": 2,
 | 
				
			||||||
 | 
					        "ram": 1024,
 | 
				
			||||||
 | 
					        "hdd": 3,
 | 
				
			||||||
 | 
					        "os": "alpine",
 | 
				
			||||||
 | 
					        "version": "3.21"
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  ],
 | 
				
			||||||
 | 
					  "default_credentials": {
 | 
				
			||||||
 | 
					    "username": null,
 | 
				
			||||||
 | 
					    "password": null
 | 
				
			||||||
 | 
					  },
 | 
				
			||||||
 | 
					  "notes": [
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					      "text": "During installation you will be asked to enter your TMDB API key, if you wanna use it. Make sure you have it ready.",
 | 
				
			||||||
 | 
					      "type": "info"
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  ]
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										85
									
								
								install/alpine-bitmagnet-install.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										85
									
								
								install/alpine-bitmagnet-install.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,85 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Copyright (c) 2021-2025 community-scripts ORG
 | 
				
			||||||
 | 
					# Author: Slaviša Arežina (tremor021)
 | 
				
			||||||
 | 
					# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
 | 
					# Source: https://github.com/bitmagnet-io/bitmagnet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
 | 
				
			||||||
 | 
					color
 | 
				
			||||||
 | 
					verb_ip6
 | 
				
			||||||
 | 
					catch_errors
 | 
				
			||||||
 | 
					setting_up_container
 | 
				
			||||||
 | 
					network_check
 | 
				
			||||||
 | 
					update_os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Installing dependencies"
 | 
				
			||||||
 | 
					$STD apk add --no-cache \
 | 
				
			||||||
 | 
					  gcc \
 | 
				
			||||||
 | 
					  musl-dev \
 | 
				
			||||||
 | 
					  git \
 | 
				
			||||||
 | 
					  iproute2-ss \
 | 
				
			||||||
 | 
					  sudo
 | 
				
			||||||
 | 
					$STD apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community go
 | 
				
			||||||
 | 
					msg_ok "Installed dependencies"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Installing PostgreSQL"
 | 
				
			||||||
 | 
					$STD apk add --no-cache \
 | 
				
			||||||
 | 
					  postgresql16 \
 | 
				
			||||||
 | 
					  postgresql16-contrib \
 | 
				
			||||||
 | 
					  postgresql16-openrc
 | 
				
			||||||
 | 
					$STD rc-update add postgresql
 | 
				
			||||||
 | 
					$STD rc-service postgresql start
 | 
				
			||||||
 | 
					msg_ok "Installed PostreSQL"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					RELEASE=$(curl -fsSL https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Installing bitmagnet v${RELEASE}"
 | 
				
			||||||
 | 
					mkdir -p /opt/bitmagnet
 | 
				
			||||||
 | 
					temp_file=$(mktemp)
 | 
				
			||||||
 | 
					curl -fsSL "https://github.com/bitmagnet-io/bitmagnet/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
 | 
				
			||||||
 | 
					tar zxf "$temp_file" --strip-components=1 -C /opt/bitmagnet
 | 
				
			||||||
 | 
					cd /opt/bitmagnet
 | 
				
			||||||
 | 
					VREL=v$RELEASE
 | 
				
			||||||
 | 
					$STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL"
 | 
				
			||||||
 | 
					chmod +x bitmagnet
 | 
				
			||||||
 | 
					$STD su - postgres -c "psql -c 'CREATE DATABASE bitmagnet;'"
 | 
				
			||||||
 | 
					echo "${RELEASE}" >/opt/bitmagnet_version.txt
 | 
				
			||||||
 | 
					msg_ok "Installed bitmagnet v${RELEASE}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					read -rp "${TAB3}Enter your TMDB API key if you have one: " tmdbapikey
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Enabling bitmagnet Service"
 | 
				
			||||||
 | 
					cat <<EOF >/etc/init.d/bitmagnet
 | 
				
			||||||
 | 
					#!/sbin/openrc-run
 | 
				
			||||||
 | 
					description="bitmagnet Service"
 | 
				
			||||||
 | 
					directory="/opt/bitmagnet"
 | 
				
			||||||
 | 
					command="/opt/bitmagnet/bitmagnet"
 | 
				
			||||||
 | 
					command_args="worker run --all"
 | 
				
			||||||
 | 
					command_background="true"
 | 
				
			||||||
 | 
					command_user="root"
 | 
				
			||||||
 | 
					pidfile="/var/run/bitmagnet.pid"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					depend() {
 | 
				
			||||||
 | 
					    use net
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					start_pre() {
 | 
				
			||||||
 | 
					    export TMDB_API_KEY="$tmdbapikey"
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					chmod +x /etc/init.d/bitmagnet
 | 
				
			||||||
 | 
					$STD rc-update add bitmagnet default
 | 
				
			||||||
 | 
					msg_ok "Enabled bitmagnet Service"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Starting bitmagnet"
 | 
				
			||||||
 | 
					$STD service bitmagnet start
 | 
				
			||||||
 | 
					msg_ok "Started bitmagnet"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					motd_ssh
 | 
				
			||||||
 | 
					customize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Cleaning up"
 | 
				
			||||||
 | 
					rm -f "$temp_file"
 | 
				
			||||||
 | 
					$STD apk cache clean
 | 
				
			||||||
 | 
					msg_ok "Cleaned"
 | 
				
			||||||
							
								
								
									
										78
									
								
								install/bitmagnet-install.sh
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										78
									
								
								install/bitmagnet-install.sh
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,78 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Copyright (c) 2021-2025 community-scripts ORG
 | 
				
			||||||
 | 
					# Author: Slaviša Arežina (tremor021)
 | 
				
			||||||
 | 
					# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
 | 
				
			||||||
 | 
					# Source: https://github.com/bitmagnet-io/bitmagnet
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
 | 
				
			||||||
 | 
					color
 | 
				
			||||||
 | 
					verb_ip6
 | 
				
			||||||
 | 
					catch_errors
 | 
				
			||||||
 | 
					setting_up_container
 | 
				
			||||||
 | 
					network_check
 | 
				
			||||||
 | 
					update_os
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Installing Dependencies"
 | 
				
			||||||
 | 
					$STD apt-get install -y \
 | 
				
			||||||
 | 
					  iproute2 \
 | 
				
			||||||
 | 
					  gcc \
 | 
				
			||||||
 | 
					  musl-dev
 | 
				
			||||||
 | 
					msg_ok "Installed Dependencies"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					PG_VERSION="16" install_postgresql
 | 
				
			||||||
 | 
					install_go
 | 
				
			||||||
 | 
					RELEASE=$(curl -fsSL https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Installing bitmagnet v${RELEASE}"
 | 
				
			||||||
 | 
					mkdir -p /opt/bitmagnet
 | 
				
			||||||
 | 
					temp_file=$(mktemp)
 | 
				
			||||||
 | 
					curl -fsSL "https://github.com/bitmagnet-io/bitmagnet/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
 | 
				
			||||||
 | 
					tar zxf "$temp_file" --strip-components=1 -C /opt/bitmagnet
 | 
				
			||||||
 | 
					cd /opt/bitmagnet
 | 
				
			||||||
 | 
					VREL=v$RELEASE
 | 
				
			||||||
 | 
					$STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL"
 | 
				
			||||||
 | 
					chmod +x bitmagnet
 | 
				
			||||||
 | 
					POSTGRES_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
 | 
				
			||||||
 | 
					$STD sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$POSTGRES_PASSWORD';"
 | 
				
			||||||
 | 
					$STD sudo -u postgres psql -c "CREATE DATABASE bitmagnet;"
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					  echo "PostgreSQL Credentials"
 | 
				
			||||||
 | 
					  echo ""
 | 
				
			||||||
 | 
					  echo "postgres user password: $POSTGRES_PASSWORD"
 | 
				
			||||||
 | 
					} >>~/postgres.creds
 | 
				
			||||||
 | 
					echo "${RELEASE}" >/opt/bitmagnet_version.txt
 | 
				
			||||||
 | 
					msg_ok "Installed bitmagnet v${RELEASE}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					read -r -p "${TAB3}Enter your TMDB API key if you have one: " tmdbapikey
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Creating Service"
 | 
				
			||||||
 | 
					cat <<EOF >/etc/systemd/system/bitmagnet-web.service
 | 
				
			||||||
 | 
					[Unit]
 | 
				
			||||||
 | 
					Description=bitmagnet Web GUI
 | 
				
			||||||
 | 
					After=network-online.target
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Service]
 | 
				
			||||||
 | 
					Type=simple
 | 
				
			||||||
 | 
					User=root
 | 
				
			||||||
 | 
					WorkingDirectory=/opt/bitmagnet
 | 
				
			||||||
 | 
					ExecStart=/opt/bitmagnet/bitmagnet worker run --all
 | 
				
			||||||
 | 
					Environment=POSTGRES_HOST=localhost
 | 
				
			||||||
 | 
					Environment=POSTGRES_PASSWORD=$POSTGRES_PASSWORD
 | 
				
			||||||
 | 
					Environment=TMDB_API_KEY=$tmdbapikey
 | 
				
			||||||
 | 
					Restart=on-failure
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[Install]
 | 
				
			||||||
 | 
					WantedBy=multi-user.target
 | 
				
			||||||
 | 
					EOF
 | 
				
			||||||
 | 
					systemctl enable -q --now bitmagnet-web
 | 
				
			||||||
 | 
					msg_ok "Created Service"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					motd_ssh
 | 
				
			||||||
 | 
					customize
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					msg_info "Cleaning up"
 | 
				
			||||||
 | 
					rm -f "$temp_file"
 | 
				
			||||||
 | 
					$STD apt-get -y autoremove
 | 
				
			||||||
 | 
					$STD apt-get -y autoclean
 | 
				
			||||||
 | 
					msg_ok "Cleaned"
 | 
				
			||||||
		Reference in New Issue
	
	Block a user