Refactor mealie.sh for configuration and startup improvements

Updated CPU and RAM defaults, improved backup process, and modified start.sh script to use 'uv run'.
This commit is contained in:
CanbiZ 2025-11-25 14:00:14 +01:00 committed by GitHub
parent 6d393074c5
commit ac4daa27a9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -7,8 +7,8 @@ source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxV
APP="Mealie" APP="Mealie"
var_tags="${var_tags:-recipes}" var_tags="${var_tags:-recipes}"
var_cpu="${var_cpu:-5}" var_cpu="${var_cpu:-2}"
var_ram="${var_ram:-4096}" var_ram="${var_ram:-2048}"
var_disk="${var_disk:-10}" var_disk="${var_disk:-10}"
var_os="${var_os:-debian}" var_os="${var_os:-debian}"
var_version="${var_version:-13}" var_version="${var_version:-13}"
@ -36,44 +36,55 @@ function update_script() {
systemctl stop mealie systemctl stop mealie
msg_ok "Stopped Service" msg_ok "Stopped Service"
msg_info "Backing up configuration" msg_info "Backing up Configuration"
mkdir -p /opt/mealie_bak cp -f /opt/mealie/mealie.env /opt/mealie/mealie.env.bak
cp -f /opt/mealie/mealie.env /opt/mealie_bak/mealie.env.bak cp -f /opt/mealie/start.sh /opt/mealie/start.sh.bak
cp -f /opt/mealie/start.sh /opt/mealie_bak/start.sh.bak
msg_ok "Backup completed" msg_ok "Backup completed"
CLEAN_INSTALL=1 fetch_and_deploy_gh_release "mealie" "mealie-recipes/mealie" "tarball" "latest" "/opt/mealie" fetch_and_deploy_gh_release "mealie" "mealie-recipes/mealie" "tarball" "latest" "/opt/mealie"
msg_info "Rebuilding Frontend" msg_info "Installing Python Dependencies with uv"
cd /opt/mealie
$STD uv sync --frozen --extra pgsql
msg_ok "Installed Python Dependencies"
msg_info "Building Frontend"
export NUXT_TELEMETRY_DISABLED=1 export NUXT_TELEMETRY_DISABLED=1
cd /opt/mealie/frontend cd /opt/mealie/frontend
$STD yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --network-timeout 1000000 $STD yarn install --prefer-offline --frozen-lockfile --non-interactive --production=false --network-timeout 1000000
$STD yarn generate $STD yarn generate
msg_ok "Built Frontend"
msg_info "Copying Built Frontend"
mkdir -p /opt/mealie/mealie/frontend
cp -r /opt/mealie/frontend/dist/* /opt/mealie/mealie/frontend/ cp -r /opt/mealie/frontend/dist/* /opt/mealie/mealie/frontend/
msg_ok "Frontend rebuilt" msg_ok "Copied Frontend"
msg_info "Updating Python Dependencies" msg_info "Updating NLTK Data"
mkdir -p /nltk_data/
cd /opt/mealie cd /opt/mealie
$STD uv sync --frozen --extra pgsql $STD uv run python -m nltk.downloader -d /nltk_data averaged_perceptron_tagger_eng
msg_ok "Dependencies updated" msg_ok "Updated NLTK Data"
msg_info "Restoring configuration" msg_info "Restoring Configuration"
grep -q "^SECRET=" /opt/mealie_bak/mealie.env.bak || echo "SECRET=$(openssl rand -hex 32)" >>/opt/mealie_bak/mealie.env.bak mv -f /opt/mealie/mealie.env.bak /opt/mealie/mealie.env
grep -q "^MEALIE_HOME=" /opt/mealie_bak/mealie.env.bak || echo "MEALIE_HOME=/opt/mealie" >>/opt/mealie_bak/mealie.env.bak
grep -q "^NLTK_DATA=" /opt/mealie_bak/mealie.env.bak || echo "NLTK_DATA=/nltk_data" >>/opt/mealie_bak/mealie.env.bak
mv -f /opt/mealie_bak/mealie.env.bak /opt/mealie/mealie.env # Update start.sh to use uv run instead of direct venv path
mv -f /opt/mealie_bak/start.sh.bak /opt/mealie/start.sh cat <<'STARTEOF' >/opt/mealie/start.sh
#!/bin/bash
set -a
source /opt/mealie/mealie.env
set +a
exec uv run mealie
STARTEOF
chmod +x /opt/mealie/start.sh chmod +x /opt/mealie/start.sh
sed -i 's|exec .*|source /opt/mealie/.venv/bin/activate\nexec uv run mealie|' /opt/mealie/start.sh
msg_ok "Configuration restored" msg_ok "Configuration restored"
msg_info "Starting Service" msg_info "Starting Service"
systemctl start mealie systemctl start mealie
msg_ok "Started Service" msg_ok "Started Service"
msg_ok "Updated successfully" msg_ok "Update Successful"
fi fi
exit exit
} }