From 796c31eae40add05ff7970c089d4d6d7c2ab00b8 Mon Sep 17 00:00:00 2001 From: "push-app-to-main[bot]" <203845782+push-app-to-main[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 12:58:47 +0200 Subject: [PATCH] babybuddy (#4619) * 'Add new script' * Update babybuddy.sh * add license --------- Co-authored-by: push-app-to-main[bot] <203845782+push-app-to-main[bot]@users.noreply.github.com> Co-authored-by: CanbiZ <47820557+MickLesk@users.noreply.github.com> --- ct/babybuddy.sh | 86 ++++++++++++++++++++++ ct/headers/babybuddy | 6 ++ frontend/public/json/babybuddy.json | 40 +++++++++++ install/babybuddy-install.sh | 108 ++++++++++++++++++++++++++++ 4 files changed, 240 insertions(+) create mode 100644 ct/babybuddy.sh create mode 100644 ct/headers/babybuddy create mode 100644 frontend/public/json/babybuddy.json create mode 100644 install/babybuddy-install.sh diff --git a/ct/babybuddy.sh b/ct/babybuddy.sh new file mode 100644 index 000000000..741dbc84f --- /dev/null +++ b/ct/babybuddy.sh @@ -0,0 +1,86 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/babybuddy/babybuddy + +APP="Baby Buddy" +var_tags="${var_tags:-baby}" +var_disk="${var_disk:-5}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_os="${var_os:-debian}" +var_version="${var_version:-12}" +var_unprivileged="${var_unprivileged:-1}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + if [[ ! -d /opt/babybuddy ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + RELEASE=$(curl -fsSL https://api.github.com/repos/babybuddy/babybuddy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') + if [[ ! -f /opt/${APP}_version.txt ]] || [[ "${RELEASE}" != "$(cat /opt/babybuddy_version.txt)" ]]; then + setup_uv + + msg_info "Stopping Services" + systemctl stop nginx + systemctl stop uwsgi + msg_ok "Services Stopped" + + msg_info "Cleaning old files" + cp babybuddy/settings/production.py /tmp/production.py.bak + find . -mindepth 1 -maxdepth 1 ! -name '.venv' -exec rm -rf {} + + msg_ok "Cleaned old files" + + msg_info "Updating ${APP} to v${RELEASE}" + temp_file=$(mktemp) + curl -fsSL "https://github.com/babybuddy/babybuddy/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" + cd /opt/babybuddy + tar zxf "$temp_file" --strip-components=1 -C /opt/babybuddy + mv /tmp/production.py.bak babybuddy/settings/production.py + cd /opt/babybuddy + source .venv/bin/activate + $STD uv pip install -r requirements.txt + $STD python manage.py migrate + echo "${RELEASE}" >/opt/${APP}_version.txt + msg_ok "Updated ${APP} to v${RELEASE}" + + msg_info "Fixing permissions" + chown -R www-data:www-data /opt/data + chmod 640 /opt/data/db.sqlite3 + chmod 750 /opt/data + msg_ok "Permissions fixed" + + msg_info "Starting Services" + systemctl start uwsgi + systemctl start nginx + msg_ok "Services Started" + + msg_info "Cleaning up" + rm -f "$temp_file" + msg_ok "Cleaned" + msg_ok "Updated Successfully" + else + msg_ok "No update required. ${APP} is already at v${RELEASE}" + fi + exit +} + +start +build_container +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}${CL}" diff --git a/ct/headers/babybuddy b/ct/headers/babybuddy new file mode 100644 index 000000000..6beae6a6b --- /dev/null +++ b/ct/headers/babybuddy @@ -0,0 +1,6 @@ + ____ __ ____ __ __ + / __ )____ _/ /_ __ __ / __ )__ ______/ /___/ /_ __ + / __ / __ `/ __ \/ / / / / __ / / / / __ / __ / / / / + / /_/ / /_/ / /_/ / /_/ / / /_/ / /_/ / /_/ / /_/ / /_/ / +/_____/\__,_/_.___/\__, / /_____/\__,_/\__,_/\__,_/\__, / + /____/ /____/ diff --git a/frontend/public/json/babybuddy.json b/frontend/public/json/babybuddy.json new file mode 100644 index 000000000..ee4f3e705 --- /dev/null +++ b/frontend/public/json/babybuddy.json @@ -0,0 +1,40 @@ +{ + "name": "Baby Buddy", + "slug": "babybuddy", + "categories": [ + 23 + ], + "date_created": "2025-05-16", + "type": "ct", + "updateable": true, + "privileged": false, + "interface_port": 80, + "documentation": "https://docs.baby-buddy.net/", + "website": "https://github.com/babybuddy/babybuddy", + "logo": "https://raw.githubusercontent.com/selfhst/icons/refs/heads/main/svg/baby-buddy.svg", + "config_path": "/opt/babybuddy/babybuddy/production.py", + "description": "Baby Buddy is an open-source web application designed to assist caregivers in tracking various aspects of a baby's daily routine, including sleep, feedings, diaper changes, tummy time, and more. By recording this data, caregivers can better understand and anticipate their baby's needs, reducing guesswork in daily care. The application offers a user-friendly dashboard for data entry and visualization, supports multiple users, and provides features like timers and reminders. Additionally, Baby Buddy can be integrated with platforms like Home Assistant and Grafana for enhanced functionality.", + "install_methods": [ + { + "type": "default", + "script": "ct/babybuddy.sh", + "resources": { + "cpu": 2, + "ram": 2048, + "hdd": 5, + "os": "debian", + "version": "12" + } + } + ], + "default_credentials": { + "username": "admin", + "password": "admin" + }, + "notes": [ + { + "text": "for private SSL setup visit: `https://github.com/babybuddy/babybuddy/blob/master/docs/setup/ssl.md`", + "type": "info" + } + ] +} diff --git a/install/babybuddy-install.sh b/install/babybuddy-install.sh new file mode 100644 index 000000000..424edaa11 --- /dev/null +++ b/install/babybuddy-install.sh @@ -0,0 +1,108 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2025 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://github.com/babybuddy/babybuddy + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt-get install -y \ + uwsgi \ + uwsgi-plugin-python3 \ + libopenjp2-7-dev \ + libpq-dev \ + nginx \ + python3 +msg_ok "Installed Dependencies" + +setup_uv + +msg_info "Installing Babybuddy" +RELEASE=$(curl -fsSL https://api.github.com/repos/babybuddy/babybuddy/releases/latest | grep "tag_name" | awk '{print substr($2, 3, length($2)-4) }') +temp_file=$(mktemp) +mkdir -p /opt/{babybuddy,data} +curl -fsSL "https://github.com/babybuddy/babybuddy/archive/refs/tags/v${RELEASE}.tar.gz" -o "$temp_file" +tar zxf "$temp_file" --strip-components=1 -C /opt/babybuddy +cd /opt/babybuddy +$STD uv venv .venv +$STD source .venv/bin/activate +$STD uv pip install -r requirements.txt +cp babybuddy/settings/production.example.py babybuddy/settings/production.py +SECRET_KEY=$(openssl rand -base64 32 | tr -dc 'a-zA-Z0-9' | cut -c1-32) +ALLOWED_HOSTS=$(hostname -I | tr ' ' ',' | sed 's/,$//')",127.0.0.1,localhost" +sed -i \ + -e "s/^SECRET_KEY = \"\"/SECRET_KEY = \"$SECRET_KEY\"/" \ + -e "s/^ALLOWED_HOSTS = \[\"\"\]/ALLOWED_HOSTS = \[$(echo \"$ALLOWED_HOSTS\" | sed 's/,/\",\"/g')\]/" \ + babybuddy/settings/production.py + +export DJANGO_SETTINGS_MODULE=babybuddy.settings.production +$STD python manage.py migrate +chown -R www-data:www-data /opt/data +chmod 640 /opt/data/db.sqlite3 +chmod 750 /opt/data +msg_ok "Installed Babybuddy" + +msg_info "Configuring uWSGI" +cat </etc/uwsgi/apps-available/babybuddy.ini +[uwsgi] +plugins = python3 +project = babybuddy +base_dir = /opt/babybuddy +chdir = %(base_dir) +virtualenv = %(base_dir)/.venv +module = %(project).wsgi:application +env = DJANGO_SETTINGS_MODULE=%(project).settings.production +master = True +vacuum = True +socket = /var/run/uwsgi/app/babybuddy/socket +chmod-socket = 660 +uid = www-data +gid = www-data +EOF +ln -sf /etc/uwsgi/apps-available/babybuddy.ini /etc/uwsgi/apps-enabled/babybuddy.ini +service uwsgi restart +msg_ok "Configured uWSGI" + +msg_info "Configuring NGINX" +cat </etc/nginx/sites-available/babybuddy +upstream babybuddy { + server unix:///var/run/uwsgi/app/babybuddy/socket; +} + +server { + listen 80; + server_name _; + + location / { + uwsgi_pass babybuddy; + include uwsgi_params; + } + + location /media { + alias /opt/data/media; + } +} +EOF + +ln -sf /etc/nginx/sites-available/babybuddy /etc/nginx/sites-enabled/babybuddy +rm /etc/nginx/sites-enabled/default +systemctl enable -q --now nginx +service nginx reload +msg_ok "Configured NGINX" + +motd_ssh +customize + +msg_info "Cleaning up" +rm -f "$temp_file" +$STD apt-get -y autoremove +$STD apt-get -y autoclean +msg_ok "Cleaned"