From 55e9726d644ac840972e2153f82e35f155103674 Mon Sep 17 00:00:00 2001 From: lolwierd Date: Fri, 27 Mar 2026 20:19:29 +0530 Subject: [PATCH] feat: add install and domain scripts for erpnext --- erpnext/domain.sh | 21 +++++++++++++++ erpnext/install.sh | 64 ++++++++++++++++++++++++++++++++++++++++++++++ signoz/install.sh | 26 ++++++++++--------- 3 files changed, 99 insertions(+), 12 deletions(-) create mode 100644 erpnext/domain.sh create mode 100644 erpnext/install.sh diff --git a/erpnext/domain.sh b/erpnext/domain.sh new file mode 100644 index 0000000..3bd10fe --- /dev/null +++ b/erpnext/domain.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +APP_UPSTREAM_PORT="${EXC_APP_UPSTREAM_PORT:-8080}" +DOMAIN="${1}" + +if [ -z "${DOMAIN}" ]; then + echo "Error: URL argument is required. Example:" >&2 + echo "domain.sh sub.example.com" >&2 + exit 1 +fi + +cat > /etc/caddy/Caddyfile <&2 + echo "install.sh sub.example.com" >&2 + exit 1 +fi + +ERPNEXT_DIR="${APP_DIR}/${APP_NAME}" +STATE_DIR="${ERPNEXT_DIR}/.excloud" +COMPOSE_FILE="${ERPNEXT_DIR}/pwd.yml" +ADMIN_PASSWORD_FILE="${STATE_DIR}/admin-password" + +apt-get install -y caddy git openssl + +if git -C "${ERPNEXT_DIR}" rev-parse 2>/dev/null; then + echo "Git repo exists" +else + rm -rf "${ERPNEXT_DIR}" + git clone --depth 1 https://github.com/frappe/frappe_docker.git "${ERPNEXT_DIR}" +fi + +mkdir -p "${STATE_DIR}" + +if [ -f "${ADMIN_PASSWORD_FILE}" ]; then + ADMIN_PASSWORD="$(cat "${ADMIN_PASSWORD_FILE}")" +else + ADMIN_PASSWORD="$(openssl rand -hex 18)" + echo "${ADMIN_PASSWORD}" > "${ADMIN_PASSWORD_FILE}" +fi + +cp "${ERPNEXT_DIR}/pwd.yml" "${STATE_DIR}/pwd.yml.orig" +cp "${STATE_DIR}/pwd.yml.orig" "${COMPOSE_FILE}" + +sed -i "s/admin/${ADMIN_PASSWORD}/g" "${COMPOSE_FILE}" +sed -i "s/\"8080:8080\"/\"127.0.0.1:${APP_UPSTREAM_PORT}:8080\"/" "${COMPOSE_FILE}" + +docker compose -f "${COMPOSE_FILE}" up -d + +start_time="$(date +%s)" +while true; do + if curl -fsS "http://127.0.0.1:${APP_UPSTREAM_PORT}" >/dev/null 2>&1; then + break + fi + + if [ $(( $(date +%s) - start_time )) -ge 900 ]; then + echo "ERPNext did not become ready in time" >&2 + exit 1 + fi + + sleep 5 +done + +bash "${SCRIPT_DIR}/domain.sh" "${DOMAIN}" diff --git a/signoz/install.sh b/signoz/install.sh index 92f04ed..aebb8f7 100644 --- a/signoz/install.sh +++ b/signoz/install.sh @@ -18,28 +18,30 @@ fi JWT_SECRET=$(openssl rand -hex 16 | cut -c-32) SIGNOZ_DIR="${APP_DIR}/signoz" -JWT_SECRET_FILE="${SIGNOZ_DIR}/jwt-secret" - -mkdir -p "${SIGNOZ_DIR}" - -if [ -f "${JWT_SECRET_FILE}" ]; then - JWT_SECRET=$(cat "${JWT_SECRET_FILE}") -else - echo "${JWT_SECRET}" > "${JWT_SECRET_FILE}" -fi +STATE_DIR="${SIGNOZ_DIR}/.excloud" COMPOSE_FILE="${SIGNOZ_DIR}/deploy/docker/docker-compose.yaml" OTEL_SERVICE_PATH='.services["otel-collector"].ports' SIGNOZ_SERVICE_PATH=".services.signoz.ports" apt-get install -y caddy yq -if git -C ${SIGNOZ_DIR} rev-parse 2>/dev/null; then +if git -C "${SIGNOZ_DIR}" rev-parse 2>/dev/null; then echo "Git repo exists" else - git clone -b main https://github.com/SigNoz/signoz.git ${SIGNOZ_DIR} + rm -rf "${SIGNOZ_DIR}" + git clone -b main https://github.com/SigNoz/signoz.git "${SIGNOZ_DIR}" fi -cd ${SIGNOZ_DIR}/deploy/docker +mkdir -p "${STATE_DIR}" +JWT_SECRET_FILE="${STATE_DIR}/jwt-secret" + +if [ -f "${JWT_SECRET_FILE}" ]; then + JWT_SECRET=$(cat "${JWT_SECRET_FILE}") +else + echo "${JWT_SECRET}" > "${JWT_SECRET_FILE}" +fi + +cd "${SIGNOZ_DIR}/deploy/docker" set_port() { local port_pair="$1"