Skip to content

Commit c250cec

Browse files
authored
Refactor: Blocky (#7537)
Updated blocky.sh to improve update logic, including backup and restore of config, service management, and release fetching. Refactored blocky-install.sh to use fetch_and_deploy_gh_release for installation, removing manual release handling. Set Blocky as updateable in blocky.json.
1 parent a0af0f5 commit c250cec

File tree

3 files changed

+40
-22
lines changed

3 files changed

+40
-22
lines changed

ct/blocky.sh

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
33
# Copyright (c) 2021-2025 tteck
44
# Author: tteck (tteckster)
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6-
# Source: https://0xerr0r.github.io/blocky/latest/
6+
# Source: https://0xerr0r.github.io/blocky
77

88
APP="Blocky"
99
var_tags="${var_tags:-adblock}"
@@ -20,18 +20,38 @@ color
2020
catch_errors
2121

2222
function update_script() {
23-
header_info
24-
check_container_storage
25-
check_container_resources
26-
if [[ ! -d /var ]]; then
27-
msg_error "No ${APP} Installation Found!"
28-
exit
29-
fi
30-
msg_info "Updating $APP LXC"
31-
$STD apt-get update
32-
$STD apt-get -y upgrade
33-
msg_ok "Updated $APP LXC"
23+
header_info
24+
check_container_storage
25+
check_container_resources
26+
if [[ ! -d /opt/blocky ]]; then
27+
msg_error "No ${APP} Installation Found!"
3428
exit
29+
fi
30+
if check_for_gh_release "blocky" "0xERR0R/blocky"; then
31+
msg_info "Stopping Service"
32+
systemctl stop blocky
33+
msg_ok "Stopped Service"
34+
35+
msg_info "Backup Config"
36+
mv /opt/blocky/config.yml /opt/config.yml
37+
msg_ok "Backed Up Config"
38+
39+
msg_info "Removing Old Version"
40+
rm -rf /opt/blocky
41+
msg_ok "Removed Old Version"
42+
43+
fetch_and_deploy_gh_release "blocky" "0xERR0R/blocky" "prebuild" "latest" "/opt/blocky" "blocky_*_linux_x86_64.tar.gz"
44+
45+
msg_info "Restore Config"
46+
mv /opt/config.yml /opt/blocky/config.yml
47+
msg_ok "Restored Config"
48+
49+
msg_info "Starting Service"
50+
systemctl start blocky
51+
msg_ok "Started Service"
52+
msg_ok "Updated Successfully"
53+
fi
54+
exit
3555
}
3656

3757
start
@@ -41,4 +61,4 @@ description
4161
msg_ok "Completed Successfully!\n"
4262
echo -e "${CREATING}${GN}${APP} setup has been successfully initialized!${CL}"
4363
echo -e "${INFO}${YW} Access it using the following URL:${CL}"
44-
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4000${CL}"
64+
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:4000${CL}"

frontend/public/json/blocky.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
],
77
"date_created": "2024-05-02",
88
"type": "ct",
9-
"updateable": false,
9+
"updateable": true,
1010
"privileged": false,
1111
"interface_port": 4000,
1212
"documentation": "https://0xerr0r.github.io/blocky/latest/configuration/",

install/blocky-install.sh

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Copyright (c) 2021-2025 tteck
44
# Author: tteck (tteckster)
55
# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE
6-
# Source: https://0xerr0r.github.io/blocky/latest/
6+
# Source: https://0xerr0r.github.io/blocky
77

88
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
99
color
@@ -13,14 +13,12 @@ setting_up_container
1313
network_check
1414
update_os
1515

16-
msg_info "Installing Blocky"
16+
fetch_and_deploy_gh_release "blocky" "0xERR0R/blocky" "prebuild" "latest" "/opt/blocky" "blocky_*_linux_x86_64.tar.gz"
17+
18+
msg_info "Configuring Blocky"
1719
if systemctl is-active systemd-resolved >/dev/null 2>&1; then
1820
systemctl disable -q --now systemd-resolved
1921
fi
20-
mkdir /opt/blocky
21-
RELEASE=$(curl -fsSL https://api.github.com/repos/0xERR0R/blocky/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
22-
curl -fsSL "https://github.com/0xERR0R/blocky/releases/download/v${RELEASE}/blocky_v${RELEASE}_Linux_x86_64.tar.gz" | tar -xzf - -C /opt/blocky/
23-
2422
cat <<EOF >/opt/blocky/config.yml
2523
# configuration documentation: https://0xerr0r.github.io/blocky/latest/configuration/
2624
@@ -63,7 +61,7 @@ log:
6361
# optional: Log level (one from trace, debug, info, warn, error). Default: info
6462
level: info
6563
EOF
66-
msg_ok "Installed Blocky"
64+
msg_ok "Configured Blocky"
6765

6866
msg_info "Creating Service"
6967
cat <<EOF >/etc/systemd/system/blocky.service
@@ -77,7 +75,7 @@ ExecStart=/opt/blocky/./blocky --config config.yml
7775
[Install]
7876
WantedBy=multi-user.target
7977
EOF
80-
$STD systemctl enable --now blocky
78+
$STD systemctl enable -q --now blocky
8179
msg_ok "Created Service"
8280

8381
motd_ssh

0 commit comments

Comments
 (0)