From 2b9a92633820603bdc724fd593b69ea327e9747b Mon Sep 17 00:00:00 2001 From: Mischa Date: Sat, 13 Jun 2026 20:53:58 +0200 Subject: [PATCH] Pass Gitea credentials to remote-install, clean up after clone --- .env.example | 6 +++++- Makefile | 2 +- scripts/server-install.sh | 6 ++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/.env.example b/.env.example index 5096eae..e3429ad 100644 --- a/.env.example +++ b/.env.example @@ -1,3 +1,7 @@ SERVER=user@example.com WEBROOT=/home/example.com/public_html -USER_REPO=ssh://git@gitea.example.com:222/user/repo.git +USER_REPO=https://gitea.example.com/user/natascha-rieter.nl-user.git + +GITEA_HOST=gitea.example.com +GITEA_USER=natascha-deploy +GITEA_TOKEN=your-token-here diff --git a/Makefile b/Makefile index db2f0b4..1beed04 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ content-pull: # Remote remote-install: - ssh $(SERVER) "WEBROOT=$(WEBROOT) USER_REPO=$(USER_REPO) bash -s" < scripts/server-install.sh + ssh $(SERVER) "WEBROOT=$(WEBROOT) USER_REPO=$(USER_REPO) GITEA_HOST=$(GITEA_HOST) GITEA_USER=$(GITEA_USER) GITEA_TOKEN=$(GITEA_TOKEN) bash -s" < scripts/server-install.sh remote-install-plugins: ssh $(SERVER) "cd $(WEBROOT) && php bin/gpm install $(shell cat plugins.txt | tr '\n' ' ') -y" diff --git a/scripts/server-install.sh b/scripts/server-install.sh index b54d80f..6afd471 100755 --- a/scripts/server-install.sh +++ b/scripts/server-install.sh @@ -3,6 +3,9 @@ set -e : "${WEBROOT:?WEBROOT is not set}" : "${USER_REPO:?USER_REPO is not set}" +: "${GITEA_HOST:?GITEA_HOST is not set}" +: "${GITEA_USER:?GITEA_USER is not set}" +: "${GITEA_TOKEN:?GITEA_TOKEN 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 @@ -15,8 +18,11 @@ mv grav-admin/* grav-admin/.htaccess . rm -rf grav-admin grav-admin.zip echo "==> Cloning user repo" +printf 'machine %s\nlogin %s\npassword %s\n' "$GITEA_HOST" "$GITEA_USER" "$GITEA_TOKEN" > ~/.netrc +chmod 600 ~/.netrc rm -rf user git clone "$USER_REPO" user +rm ~/.netrc echo "==> Setting permissions" find "$WEBROOT" -type f -exec chmod 664 {} \;