Skip to content

Commit d51ee6a

Browse files
'Add new script'
1 parent 369265a commit d51ee6a

File tree

4 files changed

+233
-0
lines changed

4 files changed

+233
-0
lines changed

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 -s 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:-1}"
11+
var_ram="${var_ram:-512}"
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 -s 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": 1,
23+
"ram": 512,
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": 1,
34+
"ram": 256,
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+
}

install/bitmagnet-install.sh

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
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 apt-get install -y \
18+
iproute2 \
19+
gcc \
20+
musl-dev
21+
msg_ok "Installed Dependencies"
22+
23+
PG_VERSION="16" install_postgresql
24+
install_go
25+
RELEASE=$(curl -s https://api.github.com/repos/bitmagnet-io/bitmagnet/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
26+
27+
msg_info "Installing bitmagnet v${RELEASE}"
28+
mkdir -p /opt/bitmagnet
29+
temp_file=$(mktemp)
30+
curl -fsSL "https://github.com/bitmagnet-io/bitmagnet/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file"
31+
tar zxf "$temp_file" --strip-components=1 -C /opt/bitmagnet
32+
cd /opt/bitmagnet
33+
VREL=v$RELEASE
34+
$STD go build -ldflags "-s -w -X github.com/bitmagnet-io/bitmagnet/internal/version.GitTag=$VREL"
35+
chmod +x bitmagnet
36+
POSTGRES_PASSWORD=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | head -c13)
37+
$STD sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD '$POSTGRES_PASSWORD';"
38+
$STD sudo -u postgres psql -c "CREATE DATABASE bitmagnet;"
39+
{
40+
echo "PostgreSQL Credentials"
41+
echo ""
42+
echo "postgres user password: $POSTGRES_PASSWORD"
43+
} >>~/postgres.creds
44+
echo "${RELEASE}" >/opt/bitmagnet_version.txt
45+
msg_ok "Installed bitmagnet v${RELEASE}"
46+
47+
read -r -p "${TAB3}Enter your TMDB API key if you have one: " tmdbapikey
48+
49+
msg_info "Creating Service"
50+
cat <<EOF >/etc/systemd/system/bitmagnet-web.service
51+
[Unit]
52+
Description=bitmagnet Web GUI
53+
After=network-online.target
54+
55+
[Service]
56+
Type=simple
57+
User=root
58+
WorkingDirectory=/opt/bitmagnet
59+
ExecStart=/opt/bitmagnet/bitmagnet worker run --all
60+
Environment=POSTGRES_HOST=localhost
61+
Environment=POSTGRES_PASSWORD=$POSTGRES_PASSWORD
62+
Environment=TMDB_API_KEY=$tmdbapikey
63+
Restart=on-failure
64+
65+
[Install]
66+
WantedBy=multi-user.target
67+
EOF
68+
systemctl enable -q --now bitmagnet-web
69+
msg_ok "Created Service"
70+
71+
motd_ssh
72+
customize
73+
74+
msg_info "Cleaning up"
75+
rm -f "$temp_file"
76+
$STD apt-get -y autoremove
77+
$STD apt-get -y autoclean
78+
msg_ok "Cleaned"

0 commit comments

Comments
 (0)