Skip to content

Commit de9ae6e

Browse files
push-app-to-main[bot]MickLesktremor021
authored
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 <[email protected]> Co-authored-by: Slaviša Arežina <[email protected]>
1 parent 4fd065a commit de9ae6e

File tree

6 files changed

+407
-0
lines changed

6 files changed

+407
-0
lines changed

ct/alpine-bitmagnet.sh

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
#!/usr/bin/env bash
2+
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Slaviša Arežina (tremor021)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/bitmagnet-io/bitmagnet
7+
8+
APP="Alpine-bitmagnet"
9+
var_tags="${var_tags:-alpine;torrent}"
10+
var_cpu="${var_cpu:-2}"
11+
var_ram="${var_ram:-1024}"
12+
var_disk="${var_disk:-3}"
13+
var_os="${var_os:-alpine}"
14+
var_version="${var_version:-3.21}"
15+
var_unprivileged="${var_unprivileged:-1}"
16+
17+
header_info "$APP"
18+
variables
19+
color
20+
catch_errors
21+
22+
function update_script() {
23+
header_info
24+
25+
if [[ ! -d /opt/bitmagnet ]]; then
26+
msg_error "No ${APP} Installation Found!"
27+
exit 1
28+
fi
29+
RELEASE=$(curl -fsSL https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
30+
if [ "${RELEASE}" != "$(cat /opt/bitmagnet_version.txt)" ] || [ ! -f /opt/bitmagnet_version.txt ]; then
31+
msg_info "Backing up database"
32+
rm -f /tmp/backup.sql
33+
$STD sudo -u postgres pg_dump \
34+
--column-inserts \
35+
--data-only \
36+
--on-conflict-do-nothing \
37+
--rows-per-insert=1000 \
38+
--table=metadata_sources \
39+
--table=content \
40+
--table=content_attributes \
41+
--table=content_collections \
42+
--table=content_collections_content \
43+
--table=torrent_sources \
44+
--table=torrents \
45+
--table=torrent_files \
46+
--table=torrent_hints \
47+
--table=torrent_contents \
48+
--table=torrent_tags \
49+
--table=torrents_torrent_sources \
50+
--table=key_values \
51+
bitmagnet \
52+
>/tmp/backup.sql
53+
mv /tmp/backup.sql /opt/
54+
msg_ok "Database backed up"
55+
56+
msg_info "Updating ${APP} from $(cat /opt/bitmagnet_version.txt) to ${RELEASE}"
57+
$STD apk -U upgrade
58+
$STD service bitmagnet stop
59+
[ -f /opt/bitmagnet/.env ] && cp /opt/bitmagnet/.env /opt/
60+
[ -f /opt/bitmagnet/config.yml ] && cp /opt/bitmagnet/config.yml /opt/
61+
rm -rf /opt/bitmagnet/*
62+
temp_file=$(mktemp)
63+
curl -fsSL "https://github.com/bitmagnet-io/bitmagnet/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
64+
tar zxf "$temp_file" --strip-components=1 -C /opt/bitmagnet
65+
cd /opt/bitmagnet
66+
VREL=v$RELEASE
67+
$STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL"
68+
chmod +x bitmagnet
69+
[ -f "/opt/.env" ] && cp "/opt/.env" /opt/bitmagnet/
70+
[ -f "/opt/config.yml" ] && cp "/opt/config.yml" /opt/bitmagnet/
71+
rm -f "$temp_file"
72+
echo "${RELEASE}" >/opt/bitmagnet_version.txt
73+
$STD service bitmagnet start
74+
msg_ok "Updated Successfully"
75+
else
76+
msg_ok "No update required. ${APP} is already at ${RELEASE}"
77+
fi
78+
79+
exit 0
80+
}
81+
82+
start
83+
build_container
84+
description
85+
86+
msg_ok "Completed Successfully!\n"
87+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
88+
echo -e "${INFO}${YW} Access it using the following IP:${CL}"
89+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3333${CL}"

ct/bitmagnet.sh

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
#!/usr/bin/env bash
2+
source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func)
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Slaviša Arežina (tremor021)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/bitmagnet/bitmagnet
7+
8+
APP="Bitmagnet"
9+
var_tags="${var_tags:-os}"
10+
var_cpu="${var_cpu:-2}"
11+
var_ram="${var_ram:-1024}"
12+
var_disk="${var_disk:-4}"
13+
var_os="${var_os:-debian}"
14+
var_version="${var_version:-12}"
15+
var_unprivileged="${var_unprivileged:-1}"
16+
17+
header_info "$APP"
18+
variables
19+
color
20+
catch_errors
21+
22+
function update_script() {
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [[ ! -d /opt/bitmagnet ]]; then
27+
msg_error "No ${APP} Installation Found!"
28+
exit
29+
fi
30+
RELEASE=$(curl -fsSL https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
31+
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
32+
msg_info "Stopping Service"
33+
systemctl stop bitmagnet-web
34+
msg_ok "Stopped Service"
35+
36+
msg_info "Backing up database"
37+
rm -f /tmp/backup.sql
38+
$STD sudo -u postgres pg_dump \
39+
--column-inserts \
40+
--data-only \
41+
--on-conflict-do-nothing \
42+
--rows-per-insert=1000 \
43+
--table=metadata_sources \
44+
--table=content \
45+
--table=content_attributes \
46+
--table=content_collections \
47+
--table=content_collections_content \
48+
--table=torrent_sources \
49+
--table=torrents \
50+
--table=torrent_files \
51+
--table=torrent_hints \
52+
--table=torrent_contents \
53+
--table=torrent_tags \
54+
--table=torrents_torrent_sources \
55+
--table=key_values \
56+
bitmagnet \
57+
>/tmp/backup.sql
58+
mv /tmp/backup.sql /opt/
59+
msg_ok "Database backed up"
60+
61+
msg_info "Updating ${APP} to v${RELEASE}"
62+
[ -f /opt/bitmagnet/.env ] && cp /opt/bitmagnet/.env /opt/
63+
[ -f /opt/bitmagnet/config.yml ] && cp /opt/bitmagnet/config.yml /opt/
64+
rm -rf /opt/bitmagnet/*
65+
temp_file=$(mktemp)
66+
curl -fsSL "https://github.com/bitmagnet-io/bitmagnet/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
67+
tar zxf "$temp_file" --strip-components=1 -C /opt/bitmagnet
68+
cd /opt/bitmagnet
69+
VREL=v$RELEASE
70+
$STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL"
71+
chmod +x bitmagnet
72+
[ -f "/opt/.env" ] && cp "/opt/.env" /opt/bitmagnet/
73+
[ -f "/opt/config.yml" ] && cp "/opt/config.yml" /opt/bitmagnet/
74+
echo "${RELEASE}" >/opt/${APP}_version.txt
75+
msg_ok "Updated $APP to v${RELEASE}"
76+
77+
msg_info "Starting Service"
78+
systemctl start bitmagnet-web
79+
msg_ok "Started Service"
80+
81+
msg_info "Cleaning up"
82+
rm -f "$temp_file"
83+
msg_ok "Cleaned"
84+
msg_ok "Updated Successfully"
85+
else
86+
msg_ok "No update required. ${APP} is already at v${RELEASE}"
87+
fi
88+
exit
89+
}
90+
91+
start
92+
build_container
93+
description
94+
95+
msg_ok "Completed Successfully!\n"
96+
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
97+
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
98+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:3333${CL}"

ct/headers/bitmagnet

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
____ _ __ __
2+
/ __ )(_) /_____ ___ ____ _____ _____ ___ / /_
3+
/ __ / / __/ __ `__ \/ __ `/ __ `/ __ \/ _ \/ __/
4+
/ /_/ / / /_/ / / / / / /_/ / /_/ / / / / __/ /_
5+
/_____/_/\__/_/ /_/ /_/\__,_/\__, /_/ /_/\___/\__/
6+
/____/
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "Bitmagnet",
3+
"slug": "bitmagnet",
4+
"categories": [
5+
11
6+
],
7+
"date_created": "2025-05-13",
8+
"type": "ct",
9+
"updateable": true,
10+
"privileged": false,
11+
"interface_port": 3333,
12+
"documentation": "https://bitmagnet.io/setup.html",
13+
"website": "https://bitmagnet.io/",
14+
"logo": "https://raw.githubusercontent.com/selfhst/icons/refs/heads/main/webp/bitmagnet.webp",
15+
"config_path": "`/opt/bitmagnet/config.yml` or `/opt/bitmagnet/.env`",
16+
"description": "A self-hosted BitTorrent indexer, DHT crawler, content classifier and torrent search engine with web UI, GraphQL API and Servarr stack integration.",
17+
"install_methods": [
18+
{
19+
"type": "default",
20+
"script": "ct/bitmagnet.sh",
21+
"resources": {
22+
"cpu": 2,
23+
"ram": 1024,
24+
"hdd": 4,
25+
"os": "debian",
26+
"version": "12"
27+
}
28+
},
29+
{
30+
"type": "alpine",
31+
"script": "ct/alpine-bitmagnet.sh",
32+
"resources": {
33+
"cpu": 2,
34+
"ram": 1024,
35+
"hdd": 3,
36+
"os": "alpine",
37+
"version": "3.21"
38+
}
39+
}
40+
],
41+
"default_credentials": {
42+
"username": null,
43+
"password": null
44+
},
45+
"notes": [
46+
{
47+
"text": "During installation you will be asked to enter your TMDB API key, if you wanna use it. Make sure you have it ready.",
48+
"type": "info"
49+
}
50+
]
51+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#!/usr/bin/env bash
2+
3+
# Copyright (c) 2021-2025 community-scripts ORG
4+
# Author: Slaviša Arežina (tremor021)
5+
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6+
# Source: https://github.com/bitmagnet-io/bitmagnet
7+
8+
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
9+
color
10+
verb_ip6
11+
catch_errors
12+
setting_up_container
13+
network_check
14+
update_os
15+
16+
msg_info "Installing dependencies"
17+
$STD apk add --no-cache \
18+
gcc \
19+
musl-dev \
20+
git \
21+
iproute2-ss \
22+
sudo
23+
$STD apk add --no-cache --repository=https://dl-cdn.alpinelinux.org/alpine/edge/community go
24+
msg_ok "Installed dependencies"
25+
26+
msg_info "Installing PostgreSQL"
27+
$STD apk add --no-cache \
28+
postgresql16 \
29+
postgresql16-contrib \
30+
postgresql16-openrc
31+
$STD rc-update add postgresql
32+
$STD rc-service postgresql start
33+
msg_ok "Installed PostreSQL"
34+
35+
RELEASE=$(curl -fsSL https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
36+
37+
msg_info "Installing bitmagnet v${RELEASE}"
38+
mkdir -p /opt/bitmagnet
39+
temp_file=$(mktemp)
40+
curl -fsSL "https://github.com/bitmagnet-io/bitmagnet/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
41+
tar zxf "$temp_file" --strip-components=1 -C /opt/bitmagnet
42+
cd /opt/bitmagnet
43+
VREL=v$RELEASE
44+
$STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL"
45+
chmod +x bitmagnet
46+
$STD su - postgres -c "psql -c 'CREATE DATABASE bitmagnet;'"
47+
echo "${RELEASE}" >/opt/bitmagnet_version.txt
48+
msg_ok "Installed bitmagnet v${RELEASE}"
49+
50+
read -rp "${TAB3}Enter your TMDB API key if you have one: " tmdbapikey
51+
52+
msg_info "Enabling bitmagnet Service"
53+
cat <<EOF >/etc/init.d/bitmagnet
54+
#!/sbin/openrc-run
55+
description="bitmagnet Service"
56+
directory="/opt/bitmagnet"
57+
command="/opt/bitmagnet/bitmagnet"
58+
command_args="worker run --all"
59+
command_background="true"
60+
command_user="root"
61+
pidfile="/var/run/bitmagnet.pid"
62+
63+
depend() {
64+
use net
65+
}
66+
67+
start_pre() {
68+
export TMDB_API_KEY="$tmdbapikey"
69+
}
70+
EOF
71+
chmod +x /etc/init.d/bitmagnet
72+
$STD rc-update add bitmagnet default
73+
msg_ok "Enabled bitmagnet Service"
74+
75+
msg_info "Starting bitmagnet"
76+
$STD service bitmagnet start
77+
msg_ok "Started bitmagnet"
78+
79+
motd_ssh
80+
customize
81+
82+
msg_info "Cleaning up"
83+
rm -f "$temp_file"
84+
$STD apk cache clean
85+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)