Add post-clone install.sh (cleanup + chown + occ app:enable), document it in both READMEs
This commit is contained in:
@@ -15,13 +15,23 @@ As nextcloudd has no native support for asynchronous operations, due to the use
|
|||||||
## Install
|
## Install
|
||||||
|
|
||||||
No build step required (plain PHP + vanilla JS). Clone straight into the
|
No build step required (plain PHP + vanilla JS). Clone straight into the
|
||||||
target server's `apps/` directory and enable it:
|
target server's `apps/` directory and run the install script:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /var/www/nextcloud/apps
|
cd /var/www/nextcloud/apps
|
||||||
git clone https://github.com/fanategorius/occweb.git
|
git clone https://github.com/fanategorius/occweb.git
|
||||||
chown -R www-data:www-data occweb # match your web server user
|
bash occweb/install.sh
|
||||||
sudo -u www-data php /var/www/nextcloud/occ app:enable occweb
|
```
|
||||||
|
|
||||||
|
`install.sh` removes the dev/CI-only files that don't belong in a running
|
||||||
|
install (`tests/`, `.travis.yml`, `phpunit*.xml`, `composer.json`,
|
||||||
|
`composer.lock`, `Makefile`), `chown -R`s the app directory to the web
|
||||||
|
server user, and runs `occ app:enable`. It assumes Nextcloud lives at
|
||||||
|
`/var/www/nextcloud` and the web server user is `www-data`; pass different
|
||||||
|
values as arguments if that's not the case:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash occweb/install.sh /path/to/nextcloud custom-web-user
|
||||||
```
|
```
|
||||||
|
|
||||||
`occ app:enable` takes care of registering the app's version correctly, so
|
`occ app:enable` takes care of registering the app's version correctly, so
|
||||||
@@ -32,9 +42,13 @@ place.
|
|||||||
Before installing, check your Nextcloud version against the range in
|
Before installing, check your Nextcloud version against the range in
|
||||||
`appinfo/info.xml` (`dependencies/nextcloud`, currently `min-version`/
|
`appinfo/info.xml` (`dependencies/nextcloud`, currently `min-version`/
|
||||||
`max-version`) — `occ app:enable` refuses to enable an app outside that
|
`max-version`) — `occ app:enable` refuses to enable an app outside that
|
||||||
range. If you're offline or without GitHub access, build a tarball instead
|
range.
|
||||||
with `make dist` (uses the included Makefile) and extract it into `apps/`
|
|
||||||
on the target server.
|
Note: `install.sh` deletes files that are tracked in git. If you plan to
|
||||||
|
keep this install up to date with `git pull` instead of re-cloning, be
|
||||||
|
aware that a future upstream change to one of the removed files could make
|
||||||
|
a plain `git pull` refuse to merge — it will tell you so, and you can
|
||||||
|
`git checkout -- <file>` to recover it if that happens.
|
||||||
|
|
||||||
## SQL query mode
|
## SQL query mode
|
||||||
|
|
||||||
|
|||||||
+20
-6
@@ -23,13 +23,23 @@ websockets), а отсутствие настоящей асинхронност
|
|||||||
## Установка
|
## Установка
|
||||||
|
|
||||||
Сборка не нужна (чистый PHP + vanilla JS). Клонируйте прямо в `apps/`
|
Сборка не нужна (чистый PHP + vanilla JS). Клонируйте прямо в `apps/`
|
||||||
целевого сервера и включите приложение:
|
целевого сервера и запустите установочный скрипт:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
cd /var/www/nextcloud/apps
|
cd /var/www/nextcloud/apps
|
||||||
git clone https://github.com/fanategorius/occweb.git
|
git clone https://github.com/fanategorius/occweb.git
|
||||||
chown -R www-data:www-data occweb # укажите вашего пользователя веб-сервера
|
bash occweb/install.sh
|
||||||
sudo -u www-data php /var/www/nextcloud/occ app:enable occweb
|
```
|
||||||
|
|
||||||
|
`install.sh` удаляет dev/CI-файлы, не нужные для работающей установки
|
||||||
|
(`tests/`, `.travis.yml`, `phpunit*.xml`, `composer.json`, `composer.lock`,
|
||||||
|
`Makefile`), выставляет `chown -R` на пользователя веб-сервера и выполняет
|
||||||
|
`occ app:enable`. По умолчанию считает, что Nextcloud лежит в
|
||||||
|
`/var/www/nextcloud`, а пользователь веб-сервера — `www-data`; если у вас
|
||||||
|
иначе, передайте своими аргументами:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
bash occweb/install.sh /path/to/nextcloud custom-web-user
|
||||||
```
|
```
|
||||||
|
|
||||||
`occ app:enable` сам корректно проставит версию приложения в базе, поэтому
|
`occ app:enable` сам корректно проставит версию приложения в базе, поэтому
|
||||||
@@ -39,9 +49,13 @@ sudo -u www-data php /var/www/nextcloud/occ app:enable occweb
|
|||||||
|
|
||||||
Перед установкой сверьте версию вашего Nextcloud с диапазоном в
|
Перед установкой сверьте версию вашего Nextcloud с диапазоном в
|
||||||
`appinfo/info.xml` (`dependencies/nextcloud`, `min-version`/`max-version`)
|
`appinfo/info.xml` (`dependencies/nextcloud`, `min-version`/`max-version`)
|
||||||
— `occ app:enable` откажется включать приложение вне этого диапазона. Если
|
— `occ app:enable` откажется включать приложение вне этого диапазона.
|
||||||
нет доступа к GitHub — соберите tar.gz через `make dist` (есть готовый
|
|
||||||
Makefile) и распакуйте его в `apps/` на целевом сервере.
|
Учтите: `install.sh` удаляет файлы, отслеживаемые в git. Если планируете
|
||||||
|
дальше обновлять эту установку через `git pull`, а не пере-клонированием —
|
||||||
|
имейте в виду, что будущее изменение одного из удалённых файлов в апстриме
|
||||||
|
может привести к отказу `git pull` смёржить изменения. Git сам сообщит об
|
||||||
|
этом, и файл можно вернуть командой `git checkout -- <file>`.
|
||||||
|
|
||||||
## Режим SQL-запросов
|
## Режим SQL-запросов
|
||||||
|
|
||||||
|
|||||||
Executable
+59
@@ -0,0 +1,59 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# Post-clone install script for occweb.
|
||||||
|
#
|
||||||
|
# Usage (from nextcloud/apps/):
|
||||||
|
# git clone https://github.com/fanategorius/occweb.git
|
||||||
|
# bash occweb/install.sh [nextcloud-root] [web-user]
|
||||||
|
#
|
||||||
|
# Defaults: nextcloud-root=/var/www/nextcloud, web-user=www-data
|
||||||
|
#
|
||||||
|
# What it does:
|
||||||
|
# 1. Removes dev/CI-only files that aren't needed to run the app
|
||||||
|
# (tests, CI config, PHPUnit config, composer files, Makefile).
|
||||||
|
# 2. chown -R's the app directory to the web server user.
|
||||||
|
# 3. Enables the app via occ.
|
||||||
|
#
|
||||||
|
# Note: this deletes files that are tracked in git. If you plan to keep
|
||||||
|
# updating this install with `git pull`, be aware that a future upstream
|
||||||
|
# change to one of the removed files could make a plain `git pull` refuse
|
||||||
|
# to merge (it will tell you so, and you can `git checkout -- <file>` to
|
||||||
|
# recover it, or re-clone instead of pulling).
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
NEXTCLOUD_ROOT="${1:-/var/www/nextcloud}"
|
||||||
|
WEB_USER="${2:-www-data}"
|
||||||
|
|
||||||
|
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
|
APP_NAME="$(basename "$APP_DIR")"
|
||||||
|
|
||||||
|
echo "==> App directory: $APP_DIR"
|
||||||
|
echo "==> App name: $APP_NAME"
|
||||||
|
echo "==> Nextcloud root: $NEXTCLOUD_ROOT"
|
||||||
|
echo "==> Web server user: $WEB_USER"
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [ ! -f "$NEXTCLOUD_ROOT/occ" ]; then
|
||||||
|
echo "error: $NEXTCLOUD_ROOT/occ not found — pass the correct Nextcloud root as the first argument." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "==> Removing dev/CI-only files not needed at runtime"
|
||||||
|
rm -rf \
|
||||||
|
"$APP_DIR/tests" \
|
||||||
|
"$APP_DIR/.travis.yml" \
|
||||||
|
"$APP_DIR/phpunit.xml" \
|
||||||
|
"$APP_DIR/phpunit.integration.xml" \
|
||||||
|
"$APP_DIR/composer.json" \
|
||||||
|
"$APP_DIR/composer.lock" \
|
||||||
|
"$APP_DIR/Makefile"
|
||||||
|
|
||||||
|
echo "==> Setting ownership to $WEB_USER:$WEB_USER"
|
||||||
|
sudo chown -R "$WEB_USER:$WEB_USER" "$APP_DIR"
|
||||||
|
|
||||||
|
echo "==> Enabling $APP_NAME"
|
||||||
|
sudo -u "$WEB_USER" php "$NEXTCLOUD_ROOT/occ" app:enable "$APP_NAME"
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "==> Done. $APP_NAME is installed and enabled."
|
||||||
Reference in New Issue
Block a user