e4e4de319d
Both api and admin2 are bundled with the Grav 2.0 zip and not available via GPM. Extract and install both during remote-install. Remove the ad-hoc remote-install-admin2 target — the main install now covers it. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vgmzx8VTTTmCskSpQtsLTr
67 lines
2.1 KiB
Bash
Executable File
67 lines
2.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
: "${WEBROOT:?WEBROOT is not set}"
|
|
: "${SITE_CONFIG_DIR:?SITE_CONFIG_DIR is not set}"
|
|
: "${USER_REPO:?USER_REPO is not set}"
|
|
: "${MAIN_REPO:?MAIN_REPO is not set}"
|
|
: "${GRAV_VERSION:?GRAV_VERSION is not set}"
|
|
: "${PLUGINS:?PLUGINS is not set}"
|
|
: "${GITEA_HOST:?GITEA_HOST is not set}"
|
|
: "${GITEA_USER:?GITEA_USER is not set}"
|
|
: "${GITEA_TOKEN:?GITEA_TOKEN is not set}"
|
|
|
|
trap 'rm -f ~/.netrc' EXIT
|
|
|
|
echo "==> Setting up credentials (temporary)"
|
|
printf 'machine %s\nlogin %s\npassword %s\n' "$GITEA_HOST" "$GITEA_USER" "$GITEA_TOKEN" > ~/.netrc
|
|
chmod 600 ~/.netrc
|
|
|
|
echo "==> Downloading Grav $GRAV_VERSION"
|
|
cd "$WEBROOT"
|
|
wget --no-verbose "https://github.com/getgrav/grav/releases/download/${GRAV_VERSION}/grav-admin-v${GRAV_VERSION}.zip" -O grav-admin.zip
|
|
unzip -oq grav-admin.zip
|
|
cp -rf grav-admin/. .
|
|
cp -rf grav-admin/user/plugins/admin2 /tmp/admin2-plugin
|
|
cp -rf grav-admin/user/plugins/api /tmp/api-plugin
|
|
rm -rf grav-admin grav-admin.zip
|
|
|
|
echo "==> Cloning user repo"
|
|
rm -rf user
|
|
git clone "$USER_REPO" user
|
|
|
|
echo "==> Cloning main config repo to $SITE_CONFIG_DIR"
|
|
if [ -d "$SITE_CONFIG_DIR/.git" ]; then
|
|
git -C "$SITE_CONFIG_DIR" pull
|
|
else
|
|
rm -rf "$SITE_CONFIG_DIR"
|
|
git clone "$MAIN_REPO" "$SITE_CONFIG_DIR"
|
|
fi
|
|
|
|
echo "==> Creating required directories"
|
|
mkdir -p user/plugins user/accounts user/data
|
|
cp -rf /tmp/admin2-plugin user/plugins/admin2
|
|
cp -rf /tmp/api-plugin user/plugins/api
|
|
rm -rf /tmp/admin2-plugin /tmp/api-plugin
|
|
|
|
echo "==> Installing plugins"
|
|
php bin/gpm install $PLUGINS -y
|
|
|
|
echo "==> Setting permissions"
|
|
find "$WEBROOT" -type f -exec chmod 664 {} \;
|
|
find "$WEBROOT" -type d -exec chmod 775 {} \;
|
|
|
|
echo "==> Removing temporary credentials"
|
|
rm -f ~/.netrc
|
|
|
|
echo ""
|
|
echo "==> Done."
|
|
echo ""
|
|
echo "NEXT STEP — add this server's SSH public key to both Gitea repos as a deploy key"
|
|
echo "so that 'make remote-fetch' and future git pulls work without credentials:"
|
|
echo ""
|
|
cat ~/.ssh/id_rsa.pub 2>/dev/null || cat ~/.ssh/id_ed25519.pub 2>/dev/null || \
|
|
echo " No SSH key found. Generate one on the server: ssh-keygen -t ed25519 -C 'server-deploy'"
|
|
echo ""
|
|
echo "Visit your domain to complete Grav setup."
|