Skip to content

Commit 32df248

Browse files
authored
add alpine bitmagnet
1 parent edabc62 commit 32df248

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-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://git.community-scripts.org/community-scripts/ProxmoxVED/raw/branch/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:-1}"
11+
var_ram="${var_ram:-256}"
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 -s 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}"

0 commit comments

Comments
 (0)