Refactor: HomeBox (#6338)

* Refactor

* Refactor

* Update
This commit is contained in:
Slaviša Arežina 2025-07-29 15:06:52 +02:00 committed by GitHub
parent 815720b59e
commit ab6f2dd24f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 32 deletions

View File

@ -22,26 +22,24 @@ function update_script() {
header_info
check_container_storage
check_container_resources
if [[ ! -f /opt/homebox ]]; then
if [[ ! -d /opt/homebox ]]; then
msg_error "No ${APP} Installation Found!"
exit
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/sysadminsmedia/homebox/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/${APP}_version.txt)" ]]; then
if [[ -x /opt/homebox ]]; then
sed -i 's|/opt\b|/opt/homebox|g' /etc/systemd/system/homebox.service
sed -i 's|^ExecStart=/opt/homebox$|ExecStart=/opt/homebox/homebox|' /etc/systemd/system/homebox.service
fi
RELEASE=$(curl -fsSL https://api.github.com/repos/sysadminsmedia/homebox/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }')
if [[ "${RELEASE}" != "$(cat ~/.homebox 2>/dev/null)" ]] || [[ ! -f ~/.homebox ]]; then
msg_info "Stopping ${APP}"
systemctl stop homebox
msg_ok "${APP} Stopped"
msg_info "Updating ${APP} to ${RELEASE}"
cd /opt
rm -rf homebox_bak
rm -rf /tmp/homebox.tar.gz
mv homebox homebox_bak
curl -fsSL "https://github.com/sysadminsmedia/homebox/releases/download/${RELEASE}/homebox_Linux_x86_64.tar.gz" -o "/tmp/homebox.tar.gz"
tar -xzf /tmp/homebox.tar.gz -C /opt
chmod +x /opt/homebox
echo "${RELEASE}" >/opt/${APP}_version.txt
msg_ok "Updated Homebox"
fetch_and_deploy_gh_release "homebox" "sysadminsmedia/homebox" "prebuild" "latest" "/opt/homebox" "homebox_Linux_x86_64.tar.gz"
chmod +x /opt/homebox/homebox
[ -f /opt/.env ] && mv /opt/.env /opt/homebox/.env
msg_info "Starting ${APP}"
systemctl start homebox
@ -61,4 +59,4 @@ 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}:7745${CL}"
echo -e "${TAB}${GATEWAY}${BGN}http://${IP}:7745${CL}"

View File

@ -9,10 +9,10 @@
"updateable": true,
"privileged": false,
"interface_port": 7745,
"documentation": null,
"documentation": "https://homebox.software/en/quick-start.html",
"website": "https://homebox.software/en/",
"logo": "https://cdn.jsdelivr.net/gh/selfhst/icons/webp/homebox.webp",
"config_path": "/opt/.env",
"config_path": "/opt/homebox/.env",
"description": "HomeBox is a simple, home-focused inventory management software. It allows users to organize and track household items by adding, updating, or deleting them. Features include optional details like warranty info, CSV import/export, custom labels, locations, and multi-tenant support for sharing with others. It\u2019s designed to be fast, easy to use, and portable.",
"install_methods": [
{
@ -31,10 +31,5 @@
"username": null,
"password": null
},
"notes": [
{
"text": ".env file location: `/opt/.env`",
"type": "info"
}
]
"notes": []
}

View File

@ -14,18 +14,17 @@ setting_up_container
network_check
update_os
msg_info "Installing Homebox"
RELEASE=$(curl -fsSL https://api.github.com/repos/sysadminsmedia/homebox/releases/latest | grep "tag_name" | awk '{print substr($2, 2, length($2)-3) }')
curl -fsSL "https://github.com/sysadminsmedia/homebox/releases/download/${RELEASE}/homebox_Linux_x86_64.tar.gz" | tar -xzf - -C /opt
chmod +x /opt/homebox
cat <<EOF >/opt/.env
fetch_and_deploy_gh_release "homebox" "sysadminsmedia/homebox" "prebuild" "latest" "/opt/homebox" "homebox_Linux_x86_64.tar.gz"
msg_info "Configuring Homebox"
chmod +x /opt/homebox/homebox
cat <<EOF >/opt/homebox/.env
# For possible environment variables check here: https://homebox.software/en/configure-homebox
HBOX_MODE=production
HBOX_WEB_PORT=7745
HBOX_WEB_HOST=0.0.0.0
EOF
echo "${RELEASE}" >"/opt/${APPLICATION}_version.txt"
msg_ok "Installed Homebox"
msg_ok "Configured Homebox"
msg_info "Creating Service"
cat <<EOF >/etc/systemd/system/homebox.service
@ -34,9 +33,9 @@ Description=Start Homebox Service
After=network.target
[Service]
WorkingDirectory=/opt
ExecStart=/opt/homebox
EnvironmentFile=/opt/.env
WorkingDirectory=/opt/homebox
ExecStart=/opt/homebox/homebox
EnvironmentFile=/opt/homebox/.env
Restart=on-failure
[Install]