From 5bbaa8bb8bbce2832b9871a8b26d45694aa5d406 Mon Sep 17 00:00:00 2001 From: Mischa Date: Sat, 13 Jun 2026 19:18:22 +0200 Subject: [PATCH] Add server make targets, install script, and .env setup Co-Authored-By: Claude Sonnet 4.6 --- .env.example | 3 +++ .gitignore | 3 +++ Makefile | 15 +++++++++++++++ scripts/server-install.sh | 25 +++++++++++++++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 .env.example create mode 100755 scripts/server-install.sh diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..5096eae --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +SERVER=user@example.com +WEBROOT=/home/example.com/public_html +USER_REPO=ssh://git@gitea.example.com:222/user/repo.git diff --git a/.gitignore b/.gitignore index 1b6e564..47883cd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ +# Environment +.env + # Grav CMS user/accounts/ user/data/ diff --git a/Makefile b/Makefile index 5eb1fcd..87513aa 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,7 @@ +-include .env +export + +# Local dev start: docker compose up -d @@ -9,8 +13,19 @@ setup: start install-plugins install-plugins: docker exec natascha_grav php /app/www/public/bin/gpm install $(shell cat plugins.txt | tr '\n' ' ') -y +# User repo deploy: git subtree push --prefix=user user-deploy main pull-content: git subtree pull --prefix=user user-deploy main --squash + +# Server +server-install: + ssh $(SERVER) "bash -s" < scripts/server-install.sh + +server-install-plugins: + ssh $(SERVER) "cd $(WEBROOT) && php bin/gpm install $(shell cat plugins.txt | tr '\n' ' ') -y" + +server-upgrade-grav: + ssh $(SERVER) "cd $(WEBROOT) && php bin/grav upgrade" diff --git a/scripts/server-install.sh b/scripts/server-install.sh new file mode 100755 index 0000000..b54d80f --- /dev/null +++ b/scripts/server-install.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -e + +: "${WEBROOT:?WEBROOT is not set}" +: "${USER_REPO:?USER_REPO is not set}" + +echo "==> Installing PHP extensions" +apt-get install -y php-curl php-gd php-mbstring php-xml php-zip php-yaml php-intl + +echo "==> Downloading Grav" +cd "$WEBROOT" +wget -q https://getgrav.org/download/core/grav-admin/latest -O grav-admin.zip +unzip -q grav-admin.zip +mv grav-admin/* grav-admin/.htaccess . +rm -rf grav-admin grav-admin.zip + +echo "==> Cloning user repo" +rm -rf user +git clone "$USER_REPO" user + +echo "==> Setting permissions" +find "$WEBROOT" -type f -exec chmod 664 {} \; +find "$WEBROOT" -type d -exec chmod 775 {} \; + +echo "==> Done. Visit your domain to complete setup."