Add global production install and update commands

This commit is contained in:
Tiago
2026-09-29 12:37:37 -03:00
parent 11429790c3
commit be414c5c8f
5 changed files with 133 additions and 30 deletions
+43
View File
@@ -0,0 +1,43 @@
#!/usr/bin/env bash
set -euo pipefail
REPO_URL="${REPO_URL:-https://producao-gitea.0jo7zj.easypanel.host/tiago/Condominio_SeConectai.git}"
INSTALL_DIR="${INSTALL_DIR:-/opt/SeConectai_Condominios}"
BRANCH="${BRANCH:-main}"
DOMAIN="${DOMAIN:-condominio.seconectai.com.br}"
if [[ $# -lt 1 || -z "${1:-}" ]]; then
echo "Uso: seconectaicondominio.install SENHA_MASTER_INICIAL"
echo "Exemplo: seconectaicondominio.install 10031992"
exit 1
fi
MASTER_PASSWORD="$1"
if ! command -v git >/dev/null 2>&1; then
echo "Erro: git nao encontrado. Instale com: apt update && apt install -y git"
exit 1
fi
if ! command -v docker >/dev/null 2>&1; then
echo "Erro: Docker nao encontrado. Instale Docker antes de continuar."
exit 1
fi
mkdir -p "$(dirname "$INSTALL_DIR")"
if [[ -d "$INSTALL_DIR/.git" ]]; then
echo "Repositorio ja existe em $INSTALL_DIR. Atualizando codigo..."
git -C "$INSTALL_DIR" fetch origin "$BRANCH"
git -C "$INSTALL_DIR" checkout "$BRANCH"
git -C "$INSTALL_DIR" pull --ff-only origin "$BRANCH"
else
if [[ -e "$INSTALL_DIR" && -n "$(ls -A "$INSTALL_DIR" 2>/dev/null || true)" ]]; then
echo "Erro: $INSTALL_DIR ja existe e nao esta vazio."
exit 1
fi
git clone --branch "$BRANCH" "$REPO_URL" "$INSTALL_DIR"
fi
cd "$INSTALL_DIR"
DOMAIN="$DOMAIN" ./scripts/install-prod.sh "$MASTER_PASSWORD"