diff --git a/ct/engram.sh b/ct/engram.sh new file mode 100644 index 000000000..87a68653b --- /dev/null +++ b/ct/engram.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash +_cs_boot="${COMMUNITY_SCRIPTS_CORE_DIR:-$(dirname "${BASH_SOURCE[0]}")/../../core}/core/build.func" +source "$_cs_boot" 2>/dev/null || source <(curl -fsSL "${COMMUNITY_SCRIPTS_CORE_URL:-https://raw.githubusercontent.com/community-scripts/core/main}/core/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://github.com/Gentleman-Programming/engram + +APP="Engram" +var_tags="${var_tags:-ai;mcp;memory}" +var_cpu="${var_cpu:-1}" +var_ram="${var_ram:-1024}" +var_disk="${var_disk:-4}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +var_arm64="${var_arm64:-yes}" +var_unprivileged="${var_unprivileged:-1}" + +export var_cloud_token="${var_cloud_token:-}" +export var_admin_token="${var_admin_token:-}" +export var_allowed_projects="${var_allowed_projects:-}" + +header_info "$APP" +variables +color +catch_errors + +function update_script() { + header_info + check_container_storage + check_container_resources + + if [[ ! -f /opt/engram/engram ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "engram" "Gentleman-Programming/engram"; then + msg_info "Stopping Engram" + systemctl stop engram + msg_ok "Stopped Engram" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "engram" "Gentleman-Programming/engram" "prebuild" "latest" "/opt/engram" "engram_*_linux_$(arch_resolve).tar.gz" + + msg_info "Starting Engram" + systemctl start engram + msg_ok "Started Engram" + 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 "${GATEWAY}${BGN}https://${IP}/dashboard/${CL}" +echo -e "${INFO}${YW}Sync and admin tokens: /opt/engram_data/.env (inside the container)${CL}" diff --git a/install/engram-install.sh b/install/engram-install.sh new file mode 100644 index 000000000..1a6c381b1 --- /dev/null +++ b/install/engram-install.sh @@ -0,0 +1,96 @@ +#!/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://github.com/Gentleman-Programming/engram + +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 nginx +msg_ok "Installed Dependencies" + +PG_VERSION="16" setup_postgresql +PG_DB_NAME="engram" PG_DB_USER="engram" setup_postgresql_db + +fetch_and_deploy_gh_release "engram" "Gentleman-Programming/engram" "prebuild" "latest" "/opt/engram" "engram_*_linux_$(arch_resolve).tar.gz" + +msg_info "Configuring Engram Cloud" +ln -sf /opt/engram/engram /usr/local/bin/engram +mkdir -p /opt/engram_data +cat </opt/engram_data/.env +ENGRAM_DATABASE_URL=postgres://engram:${PG_DB_PASS}@127.0.0.1:5432/engram?sslmode=disable +ENGRAM_CLOUD_HOST=127.0.0.1 +ENGRAM_PORT=18080 +ENGRAM_CLOUD_TOKEN=${var_cloud_token:-$(random_password 48)} +ENGRAM_CLOUD_ADMIN=${var_admin_token:-$(random_password 48)} +ENGRAM_JWT_SECRET=$(random_password 64) +ENGRAM_CLOUD_TOKEN_PEPPER=$(random_password 64) +ENGRAM_CLOUD_ALLOWED_PROJECTS=${var_allowed_projects:-*} +EOF +chmod 600 /opt/engram_data/.env +msg_ok "Configured Engram Cloud" + +create_self_signed_cert "engram" + +msg_info "Configuring Nginx" +cat <<'EOF' >/etc/nginx/sites-available/engram +server { + listen 80 default_server; + server_name _; + return 301 https://$host$request_uri; +} + +server { + listen 443 ssl default_server; + server_name _; + client_max_body_size 32m; + + ssl_certificate /etc/ssl/engram/engram.crt; + ssl_certificate_key /etc/ssl/engram/engram.key; + + location / { + proxy_pass http://127.0.0.1:18080; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto https; + proxy_read_timeout 300s; + } +} +EOF +nginx_enable_site "engram" +msg_ok "Configured Nginx" + +msg_info "Creating Service" +cat </etc/systemd/system/engram.service +[Unit] +Description=Engram Cloud +After=network-online.target postgresql.service +Wants=network-online.target postgresql.service + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/engram_data +EnvironmentFile=/opt/engram_data/.env +ExecStart=/opt/engram/engram cloud serve +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now engram +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc