diff --git a/ct/headers/snapotter b/ct/headers/snapotter new file mode 100644 index 000000000..0bbfb56c6 --- /dev/null +++ b/ct/headers/snapotter @@ -0,0 +1,6 @@ + _____ ____ __ __ + / ___/____ ____ _____ / __ \/ /_/ /____ _____ + \__ \/ __ \/ __ `/ __ \/ / / / __/ __/ _ \/ ___/ + ___/ / / / / /_/ / /_/ / /_/ / /_/ /_/ __/ / +/____/_/ /_/\__,_/ .___/\____/\__/\__/\___/_/ + /_/ diff --git a/ct/snapotter.sh b/ct/snapotter.sh new file mode 100644 index 000000000..9de26bd42 --- /dev/null +++ b/ct/snapotter.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +source <(curl -fsSL https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main/misc/build.func) +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://snapotter.com + +APP="SnapOtter" +var_tags="${var_tags:-media;image}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-20}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_unprivileged="${var_unprivileged:-1}" +var_arm64="${var_arm64:-no}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -d /opt/snapotter ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "snapotter" "snapotter-hq/SnapOtter"; then + msg_info "Stopping Service" + systemctl stop snapotter + msg_ok "Stopped Service" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "snapotter" "snapotter-hq/SnapOtter" "tarball" + + msg_info "Updating SnapOtter" + cd /opt/snapotter + $STD npm pkg delete scripts.prepare + $STD pnpm install --frozen-lockfile + $STD pnpm --filter @snapotter/web build + sed -i 's/mediapipe==0.10.21/mediapipe>=0.10.21/' /opt/snapotter/docker/feature-manifest.json + msg_ok "Updated SnapOtter" + + msg_info "Starting Service" + systemctl start snapotter + msg_ok "Started Service" + msg_ok "Updated successfully!" + 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}:1349${CL}" diff --git a/install/snapotter-install.sh b/install/snapotter-install.sh new file mode 100644 index 000000000..c45959f65 --- /dev/null +++ b/install/snapotter-install.sh @@ -0,0 +1,102 @@ +#!/usr/bin/env bash + +# Copyright (c) 2021-2026 community-scripts ORG +# Author: MickLesk (CanbiZ) +# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE +# Source: https://snapotter.com + +source /dev/stdin <<<"$FUNCTIONS_FILE_PATH" +color +verb_ip6 +catch_errors +setting_up_container +network_check +update_os + +msg_info "Installing Dependencies" +$STD apt install -y \ + imagemagick \ + ghostscript \ + potrace \ + libopenjp2-tools \ + libegl1 \ + libwayland-client0 \ + libwayland-cursor0 \ + libwayland-egl1 \ + libxkbcommon0 \ + libxkbcommon-x11-0 \ + libxcursor1 \ + python3 \ + python3-dev \ + gcc \ + g++ +msg_ok "Installed Dependencies" + +PYTHON_VERSION="3.11" setup_uv +NODE_VERSION="22" NODE_MODULE="pnpm" setup_nodejs +fetch_and_deploy_gh_release "caire" "esimov/caire" "prebuild" "latest" "/usr/local/bin" "caire-*-linux-amd64.tar.gz" +fetch_and_deploy_gh_release "snapotter" "snapotter-hq/SnapOtter" "prebuild" "latest" "/opt/snapotter" "snapotter-*-linux-amd64.tar.gz" + +msg_info "Setting up Python Environment" +mkdir -p /opt/snapotter_data/ai/models/rembg +$STD uv python install 3.11 +$STD uv venv --seed --python 3.11 /opt/snapotter_data/ai/venv +#if [[ -f /opt/snapotter/packages/ai/python/requirements.txt ]]; then +# $STD uv pip install \ +# --python /opt/snapotter_data/ai/venv/bin/python \ +# -r /opt/snapotter/packages/ai/python/requirements.txt +#fi +ln -sfn /opt/snapotter /app +msg_ok "Set up Python Environment" + +msg_info "Configuring SnapOtter" +mkdir -p /opt/snapotter_data/files +mkdir -p /tmp/snapotter-workspace + +cat </opt/snapotter_data/.env +PORT=1349 +NODE_ENV=production +DB_PATH=/opt/snapotter_data/snapotter.db +WORKSPACE_PATH=/tmp/snapotter-workspace +FILES_STORAGE_PATH=/opt/snapotter_data/files +PYTHON_VENV_PATH=/opt/snapotter_data/ai/venv +MODELS_PATH=/opt/snapotter_data/ai/models +DATA_DIR=/opt/snapotter_data +FEATURE_MANIFEST_PATH=/opt/snapotter/docker/feature-manifest.json +U2NET_HOME=/opt/snapotter_data/ai/models/rembg +AUTH_ENABLED=true +DEFAULT_USERNAME=admin +DEFAULT_PASSWORD=admin +LOG_LEVEL=info +TRUST_PROXY=true +FILE_MAX_AGE_HOURS=72 +CLEANUP_INTERVAL_MINUTES=60 +ANALYTICS_ENABLED=false +EOF +msg_ok "Configured SnapOtter" + +msg_info "Creating Service" +PNPM_BIN="$(command -v pnpm)" +cat </etc/systemd/system/snapotter.service +[Unit] +Description=SnapOtter Service +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/snapotter +EnvironmentFile=/opt/snapotter_data/.env +ExecStart=${PNPM_BIN} --filter @snapotter/api run start +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now snapotter +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc