diff --git a/ct/headers/trek b/ct/headers/trek new file mode 100644 index 000000000..f02f11b4e --- /dev/null +++ b/ct/headers/trek @@ -0,0 +1,6 @@ + __________ ________ __ + /_ __/ __ \/ ____/ //_/ + / / / /_/ / __/ / ,< + / / / _, _/ /___/ /| | +/_/ /_/ |_/_____/_/ |_| + diff --git a/ct/trek.sh b/ct/trek.sh new file mode 100644 index 000000000..0e3f679a9 --- /dev/null +++ b/ct/trek.sh @@ -0,0 +1,84 @@ +#!/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://github.com/mauriceboe/TREK + +APP="TREK" +var_tags="${var_tags:-travel;planning;collaboration}" +var_cpu="${var_cpu:-2}" +var_ram="${var_ram:-2048}" +var_disk="${var_disk:-8}" +var_os="${var_os:-debian}" +var_version="${var_version:-13}" +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/trek ]]; then + msg_error "No ${APP} Installation Found!" + exit + fi + + if check_for_gh_release "trek" "mauriceboe/TREK"; then + msg_info "Stopping Service" + systemctl stop trek + msg_ok "Stopped Service" + + msg_info "Backing up Data" + cp /opt/trek/server/.env /opt/trek.env.bak + mv /opt/trek/data /opt/trek-data.bak + mv /opt/trek/uploads /opt/trek-uploads.bak + msg_ok "Backed up Data" + + CLEAN_INSTALL=1 fetch_and_deploy_gh_release "trek" "mauriceboe/TREK" "tarball" + + msg_info "Building Client" + cd /opt/trek/client + $STD npm ci + $STD npm run build + mkdir -p /opt/trek/server/public + cp -r /opt/trek/client/dist/* /opt/trek/server/public/ + cp -r /opt/trek/client/public/fonts /opt/trek/server/public/fonts 2>/dev/null || true + msg_ok "Built Client" + + msg_info "Installing Server Dependencies" + cd /opt/trek/server + $STD npm ci + msg_ok "Installed Server Dependencies" + + msg_info "Restoring Data" + mv /opt/trek-data.bak /opt/trek/data + mv /opt/trek-uploads.bak /opt/trek/uploads + rm -rf /opt/trek/server/data /opt/trek/server/uploads + ln -s /opt/trek/data /opt/trek/server/data + ln -s /opt/trek/uploads /opt/trek/server/uploads + cp /opt/trek.env.bak /opt/trek/server/.env + rm -f /opt/trek.env.bak + msg_ok "Restored Data" + + msg_info "Starting Service" + systemctl start trek + 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}:3000${CL}" diff --git a/install/trek-install.sh b/install/trek-install.sh new file mode 100644 index 000000000..535597f8a --- /dev/null +++ b/install/trek-install.sh @@ -0,0 +1,79 @@ +#!/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/mauriceboe/TREK + +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 build-essential +msg_ok "Installed Dependencies" + +NODE_VERSION="22" setup_nodejs +fetch_and_deploy_gh_release "trek" "mauriceboe/TREK" "tarball" + +msg_info "Building Client" +cd /opt/trek/client +$STD npm ci +$STD npm run build +msg_ok "Built Client" + +msg_info "Setting up Server" +cd /opt/trek/server +$STD npm ci +mkdir -p /opt/trek/server/public +cp -r /opt/trek/client/dist/* /opt/trek/server/public/ +cp -r /opt/trek/client/public/fonts /opt/trek/server/public/fonts 2>/dev/null || true +mkdir -p /opt/trek/{data/logs,uploads/{files,covers,avatars,photos}} +rm -rf /opt/trek/server/data /opt/trek/server/uploads +ln -s /opt/trek/data /opt/trek/server/data +ln -s /opt/trek/uploads /opt/trek/server/uploads +ENCRYPTION_KEY=$(openssl rand -hex 32) +ADMIN_EMAIL="admin@trek.local" +ADMIN_PASSWORD=$(openssl rand -base64 18 | tr -dc 'A-Za-z0-9' | head -c 16) +cat </opt/trek/server/.env +NODE_ENV=production +PORT=3000 +ENCRYPTION_KEY=${ENCRYPTION_KEY} +ADMIN_EMAIL=${ADMIN_EMAIL} +ADMIN_PASSWORD=${ADMIN_PASSWORD} +COOKIE_SECURE=false +FORCE_HTTPS=false +LOG_LEVEL=info +TZ=UTC +EOF +chmod 600 /opt/trek/server/.env +msg_ok "Set up Server" + +msg_info "Creating Service" +cat </etc/systemd/system/trek.service +[Unit] +Description=TREK Travel Planner +After=network.target + +[Service] +Type=simple +User=root +WorkingDirectory=/opt/trek/server +EnvironmentFile=/opt/trek/server/.env +ExecStart=/usr/bin/node --import tsx src/index.ts +Restart=on-failure +RestartSec=5 + +[Install] +WantedBy=multi-user.target +EOF +systemctl enable -q --now trek +msg_ok "Created Service" + +motd_ssh +customize +cleanup_lxc