initial
commit
7a83069283
|
@ -0,0 +1,6 @@
|
|||
archive/
|
||||
logs/
|
||||
*.env
|
||||
deploy/nextcloud
|
||||
deploy/opt
|
||||
build/mnt
|
|
@ -0,0 +1,6 @@
|
|||
# copy to .env and edit to suit
|
||||
NAME=nextcloud
|
||||
RUSER=ucommandit
|
||||
BUILD_SRC=../src
|
||||
APPEND_BUILD_ENV=./build.env
|
||||
|
|
@ -0,0 +1 @@
|
|||
udbuild "$@"
|
|
@ -0,0 +1,2 @@
|
|||
export UCI_SHELL=true
|
||||
export USER=nextcloud
|
|
@ -0,0 +1 @@
|
|||
udbuild -t publish $@
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
# trys the default environment .env
|
||||
# udbuild try -m opt -o "--cap-add SYS_ADMIN --device /dev/fuse" ${@:-shell} $@
|
||||
# udbuild try -m /var/www -h www -o --privileged ${@:-shell} $@
|
||||
# udbuild try -m /var/www -h www ${@:-shell} $@
|
||||
udbuild try -m opt ${@:-shell} $@
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
# must invoke docker compose with supplied scripts.
|
||||
# Best to copy this file to just .env and edit for your instance
|
||||
|
||||
COMPOSE_PROJECT_NAME=nextcloud
|
||||
|
||||
# https://timezonedb.com/time-zones
|
||||
TZ=America/Los_Angles
|
||||
|
||||
# NEXTCLOUD-MARIADB
|
||||
MYSQL_ROOT_PASSWORD=<pw>
|
||||
MYSQL_PASSWORD="<pw can be same>"
|
||||
MYSQL_DATABASE=nextcloud
|
||||
MYSQL_USER=nextcloud
|
||||
|
||||
# NEXTCLOUD
|
||||
TRUSTED_PROXIES="<ip where your reverse proxy runs>"
|
||||
NEXTCLOUD_DOMAIN="<domain of reverse proxy>"
|
||||
TRUSTED_DOMAINS="$NEXTCLOUD_DOMAIN,<machine domain running docker>,<IP of machine running docker>"
|
||||
# default set at onboarding, also can change password after onboarding
|
||||
NEXTCLOUD_ADMIN_USER=admin
|
||||
NEXTCLOUD_ADMIN_PASSWORD=admin
|
||||
|
||||
HOST_GROUP_ID=1001
|
||||
HOST_USER_ID=1001
|
||||
|
||||
# USING SENDGRID FOR SENDING EMAILS (gmail example)
|
||||
MAIL_DOMAIN=gmail.com
|
||||
MAIL_FROM_ADDRESS="<gmail address>"
|
||||
SMTP_SECURE=ssl
|
||||
SMTP_HOST=smtp.gmail.com
|
||||
SMTP_PORT=465
|
||||
SMTP_NAME="<just your google account name (no @gmail.com)>"
|
||||
SMTP_PASSWORD="<a 16 character app password generated from your google account>"
|
||||
|
||||
# DOCKER HOST Volume Bindings Parent Directory
|
||||
# use only if you need/want to bind the three <db,src,user-files> volumes elsewhere for easier access
|
||||
# will create up to three directories parent/nextcloud/<volume>
|
||||
# must pre make all the directories <parent>/nextcloud/<volume> == db,src,user-files with proper owner/group
|
||||
# use the provided script
|
||||
# must uncomment driver and driver opts in docker-compose.yml in the volumes stanza
|
||||
HOST_NEXTCLOUD_PARENT_DIR=$PWD/nextcloud
|
||||
HOST_NEXTCLOUD_SRC=${HOST_NEXTCLOUD_PARENT_DIR}/src
|
||||
HOST_NEXTCLOUD_USERFILES=${HOST_NEXTCLOUD_PARENT_DIR}/user-files
|
||||
HOST_NEXTCLOUD_DB=${HOST_NEXTCLOUD_PARENT_DIR}/db
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
[[ $1 = "-f" ]] && force=force && shift
|
||||
if [[ ! $(udbuild image exists -e ../build/.env) || $force ]] ; then
|
||||
echo $force building image
|
||||
pushd ../build || exit
|
||||
./build -p -e .env -a build.env $@
|
||||
popd
|
||||
echo done building image
|
||||
else
|
||||
echo using existing image, use -f to force rebuild
|
||||
fi
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
if dcp=$(./dcp $1); then
|
||||
eval "$dcp config"
|
||||
else
|
||||
echo no environment file ${1:-$ENV_FILE}
|
||||
fi
|
|
@ -0,0 +1,13 @@
|
|||
#!/bin/bash
|
||||
|
||||
dcp() {
|
||||
if envf=$(./env_file $1); then
|
||||
export ENV_FILE=$envf
|
||||
echo "export ENV_FILE=$envf; docker compose --env-file $envf "
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# # if script was executed then call the function
|
||||
(return 0 2>/dev/null) || dcp $@
|
|
@ -0,0 +1,5 @@
|
|||
rsync -r ../src/init/rootfs/opt/lib/ opt/lib/
|
||||
rsync -r ../src/init/rootfs/opt/supervisor/ opt/supervisor/
|
||||
rsync -r ../src/init/rootfs/opt/bin/ opt/bin/
|
||||
rsync -r ../src/init/rootfs/opt/env/ opt/env/
|
||||
rsync -r ../src/init/rootfs/opt/caddy/conf/ opt/caddy/conf
|
|
@ -0,0 +1,31 @@
|
|||
version: '3'
|
||||
services:
|
||||
nextcloud:
|
||||
image: ucommandit/nextcloud
|
||||
container_name: ${NEXTCLOUD_NAME:-nextcloud}
|
||||
entrypoint: /opt/bin/boot
|
||||
hostname: ${NEXTCLOUD_NAME:-nextcloud}
|
||||
# restart: ${RESTART:-unless-stopped}
|
||||
env_file: ${ENV_FILE}
|
||||
ports:
|
||||
- "${NEXTCLOUD_PORT:-8080}:8080"
|
||||
- "${SUPERVISOR_PORT:-9001}:9001"
|
||||
volumes:
|
||||
# - nextcloud:/opt/nextcloud
|
||||
- opt:/opt
|
||||
|
||||
|
||||
volumes:
|
||||
# nextcloud:
|
||||
# driver: local
|
||||
# driver_opts:
|
||||
# o: bind
|
||||
# type: none
|
||||
# device: ${PWD}/nextcloud
|
||||
opt:
|
||||
driver: local
|
||||
driver_opts:
|
||||
o: bind
|
||||
type: none
|
||||
device: ${PWD}/opt
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
#!/bin/bash
|
||||
env_file () {
|
||||
env=${1:-.env}
|
||||
[[ -f "${env}" ]] && { echo $env; return 0; } # || echo not $env
|
||||
[[ -f "${env}.env" ]] && { echo "${env}.env"; return 0; } # || echo not ${env}.env
|
||||
[[ -f "${env}/.env" ]] && { echo "${env}/.env"; return 0; } # || echo not ${env}/.env
|
||||
return 1
|
||||
}
|
||||
|
||||
# # if script was executed then call the function
|
||||
(return 0 2>/dev/null) || env_file $@
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
./run $1 install $2
|
|
@ -0,0 +1 @@
|
|||
tail -f opt/nextcloud/logs/start.log
|
|
@ -0,0 +1,40 @@
|
|||
# must invoke docker compose with supplied scripts.
|
||||
# Best to copy this file to just .env and edit for your instance
|
||||
|
||||
COMPOSE_PROJECT_NAME=nextcloud
|
||||
NAME=$COMPOSE_PROJECT_NAME
|
||||
|
||||
# NEXTCLOUD_DEV=true
|
||||
# default command is start
|
||||
# NEXTCLOUD_CMD=install
|
||||
|
||||
# https://timezonedb.com/time-zones
|
||||
TZ=America/Los_Angles
|
||||
#ISO 3166-1 country codes
|
||||
# NEXTCLOUD_REGION=US
|
||||
|
||||
# mariadb/mysql, defaults, no need to change this db is not exposed outside container
|
||||
# MYSQL_ROOT_PASSWORD=nextcloud1234
|
||||
# MYSQL_HOST=nextcloud
|
||||
# MYSQL_PASSWORD=nextcloud1234
|
||||
# MYSQL_DATABASE=nextcloud
|
||||
# MYSQL_USER=nextcloud
|
||||
|
||||
# NEXTCLOUD
|
||||
TRUSTED_PROXIES="<ip where your reverse proxy runs>"
|
||||
NEXTCLOUD_DOMAIN="<domain of reverse proxy>"
|
||||
TRUSTED_DOMAINS="$NEXTCLOUD_DOMAIN <machine domain running docker> <IP of machine running docker>"
|
||||
# defaults, password can be changed after install
|
||||
# NEXTCLOUD_ADMIN_USER=admin
|
||||
# NEXTCLOUD_ADMIN_PASSWORD=admin
|
||||
|
||||
|
||||
# USING SENDGRID FOR SENDING EMAILS (gmail example)
|
||||
MAIL_DOMAIN=gmail.com
|
||||
MAIL_FROM_ADDRESS="<gmail address>"
|
||||
SMTP_SECURE=ssl
|
||||
SMTP_HOST=smtp.gmail.com
|
||||
SMTP_PORT=465
|
||||
SMTP_NAME="<just your google account name (no @gmail.com)>"
|
||||
SMTP_PASSWORD="<a 16 character app password generated from your google account>"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
./stop $@
|
||||
./start $@
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
if dcp=$(./dcp $1); then
|
||||
shift 1
|
||||
eval "export NEXTCLOUD_CMD=idle; $dcp run --rm --name nextcloud_runner nextcloud nextcloud $*"
|
||||
else
|
||||
echo no environment file ${1:-$ENV_FILE}
|
||||
fi
|
|
@ -0,0 +1,16 @@
|
|||
#!/bin/bash
|
||||
|
||||
source ./confirm
|
||||
if envf=$(./env_file $1) ; then
|
||||
source $envf
|
||||
echo "SUPER DANGER you are requesting to SCRUB the installation"
|
||||
echo scrub removes both containers and volumes and then deletes ALL bound host directories
|
||||
echo $HOST_NEXTCLOUD_APP $HOST_NEXTCLOUD_USERFILES $HOST_NEXTCLOUD_DB
|
||||
echo If bound directories are not backed up you WILL LOSE ALL the installation including user data permenently, proceed with caution
|
||||
if confirm -s DANGER, continue; then
|
||||
./clean $1
|
||||
sudo rm -rf $HOST_NEXTCLOUD_APP $HOST_NEXTCLOUD_USERFILES $HOST_NEXTCLOUD_DB
|
||||
else
|
||||
echo no environment file $1
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,2 @@
|
|||
#!/bin/bash
|
||||
./run "$1" shell
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
if dcp=$(./dcp $1); then
|
||||
eval "$dcp up $2"
|
||||
else
|
||||
echo no environment file passed ${1:-$ENV_FILE}
|
||||
fi
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
if dcp=$(./dcp $1); then
|
||||
eval "$dcp down"
|
||||
else
|
||||
echo no environment file $1
|
||||
fi
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/bash
|
||||
if envf=$(./env_file $1) ; then
|
||||
source $envf
|
||||
docker exec -it ${NEXTCLOUD_NAME:-nextcloud} /opt/bin/entrypoint nextcloud shell
|
||||
else
|
||||
echo no environment file $1
|
||||
fi
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
[[ $1 ]] && ENV_FILE=${1}.env || ENV_FILE=.env
|
||||
export ENV_FILE; docker-compose --env-file $ENV_FILE down
|
||||
docker-compose pull
|
||||
export ENV_FILE; docker-compose --env-file $ENV_FILE up --remove-orphans -d
|
||||
yes | docker image prune
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/bash
|
||||
[[ $1 = "-f" ]] && force=force && shift
|
||||
if [[ ! $(udbuild image exists -e ../build/.env) || $force ]] ; then
|
||||
echo $force building image
|
||||
pushd ../build || exit
|
||||
./build -p -e .env -a build.env $@
|
||||
popd
|
||||
echo done building image
|
||||
else
|
||||
echo using existing image, use -f to force rebuild
|
||||
fi
|
||||
|
|
@ -0,0 +1 @@
|
|||
docker exec try-ucommandit-nextcloud /opt/bin/entrypoint nextcloud "$@"
|
|
@ -0,0 +1 @@
|
|||
docker exec -it try-ucommandit-nextcloud /opt/bin/entrypoint shell
|
|
@ -0,0 +1 @@
|
|||
docker-compose up
|
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
# # check for image and build
|
||||
source ./build $1
|
||||
[[ $force ]] && shift 1
|
||||
mkdir dopt
|
||||
udbuild try -e ../build/.env -f nextcloud.env -m opt -h dopt -o '-p 8080:8080' -k shell
|
|
@ -0,0 +1,5 @@
|
|||
rsync -r ../src/rootfs/opt/lib/ opt/lib/
|
||||
rsync -r ../src/rootfs/opt/supervisor/ opt/supervisor/
|
||||
rsync -r ../src/rootfs/opt/bin/ opt/bin/
|
||||
rsync -r ../src/rootfs/opt/env/ opt/env/
|
||||
rsync -r ../src/rootfs/opt/caddy/conf/ opt/caddy/conf
|
|
@ -0,0 +1,43 @@
|
|||
version: '3'
|
||||
services:
|
||||
nextcloud-app:
|
||||
image: ucommandit/nextcloud
|
||||
container_name: try-ucommandit-nextcloud
|
||||
# use exec to substitute shell script at PID 1 ?
|
||||
entrypoint: ['exec /opt/bin/boot']
|
||||
hostname: compose-uci-nextcloud
|
||||
env_file: nextcloud.env
|
||||
volumes:
|
||||
# - nextcloud:/opt/nextcloud
|
||||
- opt:/opt
|
||||
ports:
|
||||
- 8080:8080
|
||||
- 9001:9001
|
||||
|
||||
volumes:
|
||||
# db:
|
||||
# driver: local
|
||||
# driver_opts:
|
||||
# o: bind
|
||||
# type: none
|
||||
# device: ${HOST_NEXTCLOUD_DB}
|
||||
|
||||
opt:
|
||||
driver: local
|
||||
driver_opts:
|
||||
o: bind
|
||||
type: none
|
||||
device: ${PWD}/opt
|
||||
|
||||
# nextcloud:
|
||||
# driver: local
|
||||
# driver_opts:
|
||||
# o: bind
|
||||
# type: none
|
||||
# device: ${PWD}/nextcloud
|
||||
# user-files:
|
||||
# driver: local
|
||||
# driver_opts:
|
||||
# o: bind
|
||||
# type: none
|
||||
# device: ${HOST_NEXTCLOUD_USERFILES}
|
|
@ -0,0 +1,59 @@
|
|||
# must invoke docker compose with supplied scripts.
|
||||
# Best to copy this file to just .env and edit for your instance
|
||||
|
||||
COMPOSE_PROJECT_NAME=nextcloud
|
||||
|
||||
# https://timezonedb.com/time-zones
|
||||
TZ=America/Los_Angles
|
||||
|
||||
# default is sqlite, mariadb or mysql, postgres
|
||||
# SQL_DB_TYPE=mysql
|
||||
|
||||
# sqlite default db name
|
||||
# SQLITE_DATABASE=nextcloud-db
|
||||
|
||||
# mariadb/mysql
|
||||
# MYSQL_ROOT_PASSWORD=nextcloud1234
|
||||
# MYSQL_HOST=nextcloud
|
||||
# MYSQL_PASSWORD=nextcloud1234
|
||||
# MYSQL_DATABASE=nextcloud
|
||||
# MYSQL_USER=nextcloud
|
||||
|
||||
# postgres
|
||||
# MYSQL_ROOT_PASSWORD=nextcloud1234
|
||||
# MYSQL_PASSWORD=nextcloud1234
|
||||
# MYSQL_DATABASE=nextcloud
|
||||
# MYSQL_USER=nextcloud
|
||||
|
||||
|
||||
|
||||
# NEXTCLOUD
|
||||
TRUSTED_PROXIES="<ip where your reverse proxy runs>"
|
||||
NEXTCLOUD_DOMAIN="<domain of reverse proxy>"
|
||||
TRUSTED_DOMAINS="$NEXTCLOUD_DOMAIN,<machine domain running docker>,<IP of machine running docker>"
|
||||
# default set at onboarding, also can change password after onboarding
|
||||
# IMPORTANT! if not set here then source backup script will use 'admin' as user by default
|
||||
NEXTCLOUD_ADMIN_USER=admin
|
||||
NEXTCLOUD_ADMIN_PASSWORD=admin
|
||||
|
||||
|
||||
# USING SENDGRID FOR SENDING EMAILS (gmail example)
|
||||
MAIL_DOMAIN=gmail.com
|
||||
MAIL_FROM_ADDRESS="<gmail address>"
|
||||
SMTP_SECURE=ssl
|
||||
SMTP_HOST=smtp.gmail.com
|
||||
SMTP_PORT=465
|
||||
SMTP_NAME="<just your google account name (no @gmail.com)>"
|
||||
SMTP_PASSWORD="<a 16 character app password generated from your google account>"
|
||||
|
||||
# volumes can be found at /var/lib/docker/volumes but can be bound else via below
|
||||
# DOCKER HOST Volume Bindings Parent Directory
|
||||
# use only if you need/want to bind the three <db,src,user-files> volumes elsewhere for easier access
|
||||
# will create up to three directories parent/nextcloud/<volume>
|
||||
# must pre make all the directories <parent>/nextcloud/<volume> == db,src,user-files
|
||||
# must uncomment driver and driver opts in docker-compose.yml in the volumes stanza
|
||||
# HOST_NEXTCLOUD_PARENT_DIR=/data
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
if [[ -d opt ]]; then
|
||||
echo "want to scrub scurb $PWD/opt and the volume test-opt (yes) ?"
|
||||
read ans
|
||||
if [[ $ans == "yes" ]]; then
|
||||
echo scrubbing ./opt/*;
|
||||
rm -rf ./opt/*
|
||||
docker container stop try-ucommandit-nextcloud 2>/dev/null
|
||||
docker container rm try-ucommandit-nextcloud 2> /dev/null
|
||||
echo removing docker volume test-opt
|
||||
docker volume rm test_opt
|
||||
else
|
||||
echo scrub aborted
|
||||
fi
|
||||
else
|
||||
echo no directory opt to scrub, making one
|
||||
mkdir opt
|
||||
fi
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
# # check for image and build
|
||||
source ./build $1
|
||||
[[ $force ]] && shift 1
|
||||
./try -k "$@" nextcloud shell
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
# # check for image and build
|
||||
source ./build $1
|
||||
[[ $force ]] && shift 1
|
||||
./try -k nextcloud idle
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
# # check for image and build
|
||||
source ./build $1
|
||||
[[ $force ]] && shift 1
|
||||
./try -k nextcloud stop
|
|
@ -0,0 +1 @@
|
|||
docker exec -t try-ucommandit-nextcloud /bin/bash -l
|
|
@ -0,0 +1,5 @@
|
|||
#!/bin/bash
|
||||
# # check for image and build
|
||||
source ./build $1
|
||||
[[ $force ]] && shift 1
|
||||
udbuild try -e ../build/.env -f nextcloud.env -m opt -h opt -o '-p 8080:8080' -o '-p 9001:9001' -o '--dns=10.0.0.1' "$@"
|
|
@ -0,0 +1,31 @@
|
|||
|
||||
# UCI NEXTCLOUD DOCKER IMAGE
|
||||
|
||||
## Building
|
||||
|
||||
## Testing
|
||||
|
||||
## Publishing
|
||||
|
||||
## Deploying
|
||||
|
||||
## Notes
|
||||
|
||||
https://www.reddit.com/r/NextCloud/comments/15fhs8n/additional_config_files_seems_to_load_but_then/
|
||||
|
||||
Looks like I finally answered my own question after reading this comment
|
||||
|
||||
**Any file located in NC\_Installation\_dir/config/ ending with .config.php will be merged and stored as config.php**
|
||||
|
||||
from this post
|
||||
|
||||
[https://help.nextcloud.com/t/did-you-know-anysetting-config-php/141618](https://help.nextcloud.com/t/did-you-know-anysetting-config-php/141618)
|
||||
|
||||
*it seems as if these additional config files are not necessarily read at runtime as the docs seem to indicate rather they get read and merged at some point.*
|
||||
|
||||
Well, after goofing around with `occ` I discovered that if one set/delete a dummy key/value all the rest of the configs are then merged into `config.php`. Further if I want to "update" I can delete a key using occ, update a key in that additional config file then once again set/delete a dummy key/value and the changes will be merged back into config.php. With all the values "hardcoded" into `config.php` nextcloud no longer complains about `trusted_domains`.
|
||||
|
||||
So this then is my "solution". After I do `maintenance:install` I just set/delete a dummy key/value and my custom key/values form my additional config files are merged. Apparently `maintenance:install` does not perform this merging*.*
|
||||
|
||||
occ config:system:set --value true update_config
|
||||
occ config:system:delete update_config
|
|
@ -0,0 +1,141 @@
|
|||
#!/bin/bash
|
||||
echo -e "********** Nextcloud Setup and Install ***************"
|
||||
|
||||
source $LIB_DIR/verbose.lib
|
||||
source $ENV_DIR/run.env
|
||||
|
||||
install -m 770 -o $NEXTCLOUD_USER -g $NEXTCLOUD_USER -d /run/nextcloud
|
||||
install -m 660 -o $NEXTCLOUD_USER -g $NEXTCLOUD_USER /dev/null /run/nextcloud/fastcgi.sock
|
||||
|
||||
chown -R $USER:$USER $NEXTCLOUD_HOME
|
||||
chmod -R o-rwX $NEXTCLOUD_HOME
|
||||
|
||||
which php
|
||||
PHP_VERSION=$(readlink $(which php))
|
||||
PHP_INI_DIR=/etc/$PHP_VERSION
|
||||
PHP_VERSION="${PHP_VERSION#php}"
|
||||
|
||||
ln -s $(which php-fpm$PHP_VERSION) /bin/php-fpm
|
||||
|
||||
echo -e "export PHP_INI_DIR=$PHP_INI_DIR\nexport PHP_VERSION=$PHP_VERSION" >> $ENV_DIR/php.env
|
||||
cat $ENV_DIR/php.env
|
||||
|
||||
cat <<PHP > $PHP_INI_DIR/conf.d/03-opcache-recommended.ini
|
||||
opcache.enable=1
|
||||
opcache.interned_strings_buffer=32
|
||||
opcache.max_accelerated_files=10000
|
||||
opcache.memory_consumption=128
|
||||
opcache.save_comments=1
|
||||
opcache.revalidate_freq=60
|
||||
opcache.jit=1255
|
||||
opcache.jit_buffer_size=128M
|
||||
PHP
|
||||
|
||||
cat <<PHP > $PHP_INI_DIR/conf.d/03-mysql.ini
|
||||
[mysql]
|
||||
mysql.allow_local_infile=On
|
||||
mysql.allow_persistent=On
|
||||
mysql.cache_size=2000
|
||||
mysql.max_persistent=-1
|
||||
mysql.max_links=-1
|
||||
mysql.default_port=
|
||||
mysql.default_socket=/run/nextcloud/db.sock
|
||||
mysql.default_host=localhost
|
||||
mysql.default_user=${MYSQL_USER:-nextcloud}
|
||||
mysql.default_password=${MYSQL_PASSWORD:-nextcloud1234}
|
||||
mysql.connect_timeout=60
|
||||
mysql.trace_mode=Off
|
||||
|
||||
[Pdo_mysql]
|
||||
pdo_mysql.default_socket=/opt/nextcloud/db/db.sock
|
||||
PHP
|
||||
|
||||
cat <<PHP > "${PHP_INI_DIR}/conf.d/03-ext-apcu.ini"
|
||||
[apcu]
|
||||
|
||||
apc.enable_cli=1
|
||||
PHP
|
||||
|
||||
cat <<PHP > $PHP_INI_DIR/conf.d/03-nextcloud.ini
|
||||
memory_limit=${PHP_MEMORY_LIMIT}
|
||||
upload_max_filesize=${PHP_UPLOAD_LIMIT}
|
||||
post_max_size=${PHP_UPLOAD_LIMIT}
|
||||
PHP
|
||||
|
||||
rm $PHP_INI_DIR/php-fpm.d/www.conf
|
||||
|
||||
cat <<PHP > $PHP_INI_DIR/php-fpm.d/nextcloud.conf
|
||||
[global]
|
||||
error_log = $NEXTCLOUD_LOGS_DIR/php-fpm.err
|
||||
log_level = ${PHP_LOG_LEVEL:-warning}
|
||||
emergency_restart_threshold = 10
|
||||
emergency_restart_interval = 1m
|
||||
process_control_timeout = 10s
|
||||
|
||||
[nextcloud]
|
||||
user = $NEXTCLOUD_USER
|
||||
group = $NEXTCLOUD_USER
|
||||
chdir = $NEXTCLOUD_SRC_DIR
|
||||
listen = /run/nextcloud/fastcgi.sock
|
||||
listen.mode = 0660
|
||||
listen.owner = $NEXTCLOUD_USER
|
||||
listen.group = $NEXTCLOUD_USER
|
||||
|
||||
pm = dynamic
|
||||
pm.max_children = 20
|
||||
pm.process_idle_timeout = 120s
|
||||
pm.max_requests = 500
|
||||
pm.status_path =
|
||||
pm.start_servers = 3
|
||||
pm.min_spare_servers = 2
|
||||
pm.max_spare_servers = 15
|
||||
|
||||
ping.path = /ping
|
||||
|
||||
env[PATH] = /usr/local/bin:/usr/bin:/bin
|
||||
env[TMP] = /tmp
|
||||
env[TMPDIR] = /tmp
|
||||
env[TEMP] = /tmp
|
||||
|
||||
php_admin_flag[file_uploads] = true
|
||||
php_admin_value[memory_limit] = 512M
|
||||
php_admin_value[post_max_size] = 513M
|
||||
php_admin_value[upload_max_filesize] = 513M
|
||||
php_admin_value[session.save_path] = /var/tmp/nextcloud
|
||||
php_admin_value[sys_temp_dir] = /var/tmp/nextcloud
|
||||
php_admin_value[upload_tmp_dir] = /var/tmp/nextcloud
|
||||
php_admin_flag[log_errors] = on
|
||||
php_admin_value[error_log] = $NEXTCLOUD_LOGS_DIR/admin.php.error.log
|
||||
php_admin_value[opcache.error_log] = $NEXTCLOUD_LOGS_DIR/admin.opcache.php.error.log
|
||||
php_admin_flag[output_buffering] = false
|
||||
php_admin_value[disable_functions] = exec,passthru,system,proc_open,curl_multi_exec,show_source
|
||||
php_admin_flag[opcache.enable_cli] = true
|
||||
php_admin_flag[opcache.save_comments] = true
|
||||
php_admin_value[opcache.interned_strings_buffer] = 8
|
||||
php_admin_value[opcache.max_accelerated_files] = 10000
|
||||
php_admin_value[opcache.memory_consumption] = 128
|
||||
php_admin_value[opcache.revalidate_freq] = 1
|
||||
|
||||
catch_workers_output = yes
|
||||
slowlog = $NEXTCLOUD_LOGS_DIR/slow.log
|
||||
access.log = $NEXTCLOUD_LOGS_DIR/access.log
|
||||
PHP
|
||||
|
||||
# ls -la $PHP_INI_DIR/conf.d
|
||||
ls -la $PHP_INI_DIR/php-fpm.d
|
||||
# cat $PHP_INI_DIR/conf.d/03-opcache-recommended.ini
|
||||
# cat "${PHP_INI_DIR}/conf.d/03-docker-php-ext-apcu.ini"
|
||||
# cat $PHP_INI_DIR/conf.d/03-nextcloud.ini
|
||||
cat $PHP_INI_DIR/php-fpm.d/nextcloud.conf
|
||||
|
||||
# allow only occ as part of nextcloud
|
||||
rm -f /usr/bin/occ
|
||||
|
||||
source $LIB_DIR/caddy.lib
|
||||
mkdir -p $CADDY_HOME/bin $CADDY_HOME/settings $CADDY_HOME/data
|
||||
chown -R $USER:$USER $REDIS_HOME
|
||||
chown -R $USER:$USER $CADDY_HOME
|
||||
|
||||
echo "vm.overcommit_memory = 1" | sudo tee /etc/sysctl.d/nextcloud-memory-overcommit.conf
|
||||
|
||||
echo -e "********** Done: Nextcloud Setup and Install ***************"
|
|
@ -0,0 +1,20 @@
|
|||
# php version estatablished in php.env via run.env
|
||||
|
||||
echo "----- Installing php version $PHP_VERSION specific system packages in $file ---------------"
|
||||
while IFS= read -r pkg || [ -n "$pkg" ]; do
|
||||
echo installing: php$PHP_VERSION-$pkg
|
||||
silence $INSTALL_PKGS php$PHP_VERSION-$pkg
|
||||
done < ./php-ver.mods
|
||||
echo "done ----- Installing System Packages from $file ---------------"
|
||||
|
||||
echo adding php version specific modules based on php version installed: $PHP_VERSION
|
||||
silence $INSTALL_PKGS php$PHP_VERSION-pecl-imagick
|
||||
silence $INSTALL_PKGS php$PHP_VERSION-pdo_mysql
|
||||
silence $INSTALL_PKGS php$PHP_VERSION-pecl-redis
|
||||
silence $INSTALL_PKGS php$PHP_VERSION-pecl-apcu
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
pecl-imagick
|
||||
pdo_mysql
|
||||
pecl-redis
|
||||
pecl-apcu
|
||||
sysvsem
|
|
@ -0,0 +1,4 @@
|
|||
jq
|
||||
rsync
|
||||
envsubst
|
||||
supervisor
|
|
@ -0,0 +1,2 @@
|
|||
php
|
||||
php-fpm
|
|
@ -0,0 +1,4 @@
|
|||
nextcloud
|
||||
nextcloud-initscript
|
||||
caddy
|
||||
redis
|
|
@ -0,0 +1,4 @@
|
|||
nextcloud-sqlite
|
||||
mariadb
|
||||
mariadb-client
|
||||
nextcloud-mysql
|
|
@ -0,0 +1,6 @@
|
|||
nextcloud-files_pdfviewer
|
||||
nextcloud-text
|
||||
nextcloud-notifications
|
||||
nextcloud-files_videoplayer
|
||||
nextcloud-files_external
|
||||
nextcloud-default-apps
|
|
@ -0,0 +1,83 @@
|
|||
#!/bin/bash
|
||||
|
||||
# do not add code here for non-interative login shell
|
||||
# rather put additional non-interactive profile script code in files in /etc/profile.d
|
||||
|
||||
# this files is sourced for all login shells and also interactive non-login shells via /etc/bash.bashrc
|
||||
# more info see http://www.linuxfromscratch.org/blfs/view/svn/postlfs/profile.html
|
||||
|
||||
# interactive non-login and login shells will call the BASH_SHELL_LOAD script below
|
||||
# non-interative login shells only source /etc/profile.d
|
||||
# in profile.d is 03-startup.sh which will call
|
||||
# any of the scripts in a repo's startup subdirectory
|
||||
# non-interactive non-login shells are not handled here only via /etc/bash.bashrc
|
||||
# interactive login
|
||||
|
||||
|
||||
([ -n "$SSH_CONNECTION" ] || [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]) && export SSH_SESSION=true
|
||||
[[ $- == *i* ]] && export SHELL_INTERACTIVE=true
|
||||
shopt -q login_shell && export SHELL_LOGIN=true
|
||||
[ $EUID -eq 0 ] && export USER_ROOT=true
|
||||
|
||||
# uncomment for debugging non-interactive login shell, i.e. $ . /etc/profile
|
||||
#unset SHELL_INTERACTIVE
|
||||
|
||||
#uncomment these for debugging.
|
||||
# echo ---- sourcing system /etc/profile ---
|
||||
# [[ $USER_ROOT ]] && echo 'Root User' || echo 'Non Root User'
|
||||
# [[ $SHELL_INTERACTIVE ]] && echo 'Interactive' || echo 'Not interactive'
|
||||
# [[ $SHELL_LOGIN ]] && echo 'Login shell' || echo 'Not login shell'
|
||||
# [[ $SSH_SESSION ]] && echo ssh remote user || echo local user
|
||||
# echo ---------------------
|
||||
|
||||
# Set the initial path
|
||||
export PATH=/bin:/usr/bin:/usr/local/bin
|
||||
# set directory for base shell repo
|
||||
export BASH_SHELL_BASE=/shell
|
||||
# now bootstrap by souring the shell repo envinroment
|
||||
source $BASH_SHELL_BASE/shell.env
|
||||
# set $BASH_SAFE_MODE=true in shell.env to disable UCI interactive shell from loading
|
||||
# TODO see if $NO_BASH_SHELL_SSH=true in user or host directory (at the remote machine)
|
||||
# if so don't source the load command below and make just a simple prompt.
|
||||
if [[ $SHELL_INTERACTIVE ]]; then
|
||||
if [[ ! $BASH_SAFE_MODE ]]; then
|
||||
# echo interactive shell loading $BASH_SHELL_LOAD
|
||||
source "$BASH_SHELL_LOAD"
|
||||
else
|
||||
# safe mode
|
||||
# just set a simple prompt instead
|
||||
NORMAL="\[\e[0m\]"
|
||||
RED="\[\e[1;31m\]"
|
||||
GREEN="\[\e[1;32m\]"
|
||||
YELLOW='\e[1;33m'
|
||||
if [[ $EUID == 0 ]] ; then
|
||||
PS1="${YELLOW}SAFE:$RED\u [ $NORMAL\w$RED ]# $NORMAL"
|
||||
else
|
||||
PS1="${YELLOW}SAFE:$GREEN \u [ $NORMAL\w$GREEN ]\$ $NORMAL"
|
||||
fi
|
||||
unset RED GREEN NORMAL YELLOW
|
||||
fi
|
||||
else
|
||||
# this is non-interactive login (e.g. at user machine login)
|
||||
if [[ $EUID -ne 0 ]] && [[ ! $SSH_SESSION ]]; then
|
||||
export LOGIN_LOG=$HOME/logs/login.log
|
||||
mkdir -p $HOME/logs
|
||||
touch $LOGIN_LOG
|
||||
llog () {
|
||||
echo "$@" >> $LOGIN_LOG 2>&1
|
||||
}
|
||||
export -f llog
|
||||
llog "$(env | grep BASH)"
|
||||
echo "$(date)" > $LOGIN_LOG
|
||||
llog "non-interactive login shell for $USER"
|
||||
if [ -d /etc/profile.d ]; then
|
||||
for i in /etc/profile.d/*.sh; do
|
||||
if [ -r $i ]; then
|
||||
llog "sourcing $i"
|
||||
source $i
|
||||
fi
|
||||
done
|
||||
unset i
|
||||
fi
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,6 @@
|
|||
# root login setup only, put in if block
|
||||
if [ $EUID -eq 0 ] ; then # if root user
|
||||
echo login profile, root specific setup
|
||||
export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin
|
||||
unset HISTFILE
|
||||
fi
|
|
@ -0,0 +1,10 @@
|
|||
# this runs startups for bash shell base system
|
||||
# don't run statup if user logs in via su
|
||||
if [ "$SHELL" = "/bin/bash" ] && [ "${BASH_SHELL_STARTUP}" ] && [ "$(ps -o comm= $PPID)" != "su" ]; then
|
||||
# uncomment for debugging
|
||||
if [[ -f $BASH_SHELL_STARTUP ]] && [[ $EUID -ne 0 ]]; then
|
||||
llog "sourcing startup script $BASH_SHELL_STARTUP"
|
||||
# (${BASH_SHELL_STARTUP}) &
|
||||
source ${BASH_SHELL_STARTUP}
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,27 @@
|
|||
#!/bin/bash
|
||||
source /opt/core_run.env
|
||||
source $LIB_DIR/nextcloud.lib
|
||||
export BOOT=true
|
||||
|
||||
ps -ea
|
||||
|
||||
exec nextcloud supstart -n
|
||||
|
||||
# get this to be process zero
|
||||
# /usr/bin/python3 /usr/bin/supervisord -c /opt/supervisor/supervisord.conf -n
|
||||
|
||||
|
||||
# # catch shutdown signals
|
||||
# trap nextcloud shutdown SIGTERM SIGHUP SIGQUIT SIGINT
|
||||
# # wait $RUNIT
|
||||
# sleep 5
|
||||
# ps -ea
|
||||
|
||||
# echo "killing any other processes (zombie) still running in the container"
|
||||
# for _pid in $(ps -eo pid | grep -v PID | tr -d ' ' | grep -v '^1$' | head -n -6); do
|
||||
# timeout 5 /bin/sh -c "kill $_pid && wait $_pid || kill -9 $_pid"
|
||||
# done
|
||||
|
||||
# https://docs.docker.com/config/containers/multi-service_container/
|
||||
# https://github.com/phusion/baseimage-docker
|
||||
# https://computingforgeeks.com/use-tini-init-system-in-docker-containers/#google_vignette
|
|
@ -0,0 +1,55 @@
|
|||
#!/bin/bash
|
||||
|
||||
source $LIB_DIR/nextcloud.lib
|
||||
|
||||
nextcloud () {
|
||||
|
||||
if ! { [[ $(installed) ]] || [[ $NEXTCLOUD_DEV ]] || [[ $NEXTCLOUD_INSTALLING ]]; }; then
|
||||
if ! { [[ $1 == "install" ]] || [[ $1 == "supstart" ]] || [[ $1 == "start" ]] || [[ $1 == "installed" ]]; }; then
|
||||
echo "nextcloud not installed, only valid nextcloud subcommands are 'supstart', 'start', 'installed' or 'install '"
|
||||
echo exiting now from passed subcommand: $1
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
cmd=$1
|
||||
case "$cmd" in
|
||||
idle) ;&
|
||||
shell) ;&
|
||||
install) ;&
|
||||
installed) ;&
|
||||
caddy) ;&
|
||||
db) ;&
|
||||
redis) ;&
|
||||
upgrade) ;&
|
||||
stop) ;&
|
||||
reinstall) ;&
|
||||
redis) ;&
|
||||
start) ;&
|
||||
run) ;&
|
||||
suprld) ;&
|
||||
supctl) ;&
|
||||
supstart) ;&
|
||||
supstop) ;&
|
||||
config_update) ;&
|
||||
app) ;&
|
||||
config) ;&
|
||||
occ) ;&
|
||||
func);&
|
||||
version);&
|
||||
config)
|
||||
shift 1
|
||||
$cmd "$@"
|
||||
;;
|
||||
*)
|
||||
occ "$@"
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
# # if script was executed then call the function
|
||||
(return 0 2>/dev/null) || nextcloud "$@"
|
|
@ -0,0 +1,52 @@
|
|||
:8080 {
|
||||
redir /.well-known/webfinger /index.php/.well-known/webfinger 301
|
||||
redir /.well-known/carddav /remote.php/dav 301
|
||||
redir /.well-known/caldav /remote.php/dav 301
|
||||
|
||||
header {
|
||||
# enable HSTS
|
||||
Strict-Transport-Security max-age=31536000;
|
||||
}
|
||||
|
||||
# .htaccess / data / config / ... shouldn't be accessible from outside
|
||||
@forbidden {
|
||||
path /.htaccess
|
||||
path /data/*
|
||||
path /config/*
|
||||
path /db_structure
|
||||
path /.xml
|
||||
path /README
|
||||
path /3rdparty/*
|
||||
path /lib/*
|
||||
path /templates/*
|
||||
path /occ
|
||||
path /console.php
|
||||
}
|
||||
respond @forbidden 404
|
||||
|
||||
@collabora {
|
||||
path /browser/* # Browser is the client part of LibreOffice Online
|
||||
path /hosting/discovery # WOPI discovery URL
|
||||
path /hosting/capabilities # Show capabilities as json
|
||||
path /cool/* # Main websocket, uploads/downloads, presentations
|
||||
}
|
||||
|
||||
reverse_proxy @collabora collabora:9980 {
|
||||
header_up Host {$NEXTCLOUD_DOMAIN}
|
||||
transport http {
|
||||
tls_insecure_skip_verify
|
||||
}
|
||||
}
|
||||
|
||||
log {
|
||||
output file {$NEXTCLOUD_LOGS_DIR}/nextcloud-caddy.log
|
||||
}
|
||||
|
||||
root * {$NEXTCLOUD_SRC_DIR}
|
||||
# php_fastcgi :9000 {
|
||||
php_fastcgi unix//run/nextcloud/fastcgi.sock {
|
||||
env front_controller_active true # Remove index.php form url
|
||||
root {$NEXTCLOUD_SRC_DIR}
|
||||
}
|
||||
file_server
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
#!/bin/bash
|
||||
|
||||
caddy_add_packages () {
|
||||
local ifile; local bin; local pkgs; local pkg; local ipkgs
|
||||
clean () {
|
||||
local tmp;local tmp2; local append
|
||||
if [[ -f $1 ]]; then
|
||||
tmp=$(sed '/^[[:space:]]*#[^!]/d; /#$/d' $1)
|
||||
else
|
||||
tmp=$1
|
||||
fi
|
||||
echo "$tmp $2" | xargs -n1 | sort -u | xargs | sed "s# # #g"
|
||||
|
||||
}
|
||||
[[ -f $1 ]] && pkgs=" $(clean $1)"
|
||||
[[ $BUILDING && -f $BUILD_DIR/caddy.pkgs ]] && pkgs=$(clean $BUILD_DIR/caddy.pkgs "$pkgs")
|
||||
# echo pkgs after build
|
||||
# echo $pkgs
|
||||
[[ -f $CADDY_CONF/caddy.pkgs ]] && pkgs=$(clean $CADDY_CONF/caddy.pkgs "$pkgs")
|
||||
# echo pkgs after conf
|
||||
# echo $pkgs
|
||||
[[ ! $pkgs ]] && echo "no packages requested, nothing to do" && return 0
|
||||
echo "--- packages requested to install ----"
|
||||
echo $pkgs
|
||||
echo "-----------"
|
||||
ifile=${CADDY_HOME}/bin/installed.pkgs
|
||||
# uncomment for testing
|
||||
# /bin/cp installed.pkgs $ifile
|
||||
[[ -f $ifile ]] && ipkgs=$(clean $ifile)
|
||||
echo "--- currently installed packages ----"
|
||||
[[ $ipkgs ]] && echo $ipkgs || echo NONE
|
||||
echo "-----------"
|
||||
for pkg in $ipkgs; do
|
||||
# echo installed packaged $pkg
|
||||
pkgs=${pkgs/${pkg}/};
|
||||
done
|
||||
[[ ! $(clean $pkgs) ]] && echo "no new packages to add, nothing to do" && return 0
|
||||
echo "--- packages that need adding ----"
|
||||
echo $pkgs
|
||||
echo "-----------"
|
||||
bin=${2:-$CADDY_BIN}
|
||||
bin=${bin:-$(command -v caddy)}
|
||||
# [[ ! $bin ]] && echo no caddy binary found && return 1
|
||||
[[ ! -x $bin ]] && echo ERROR: can not add packages, no caddy binary found at $bin && return 1
|
||||
echo "------- ADDING CADDY PACKAGES ------------"
|
||||
if ! $bin add-package $pkgs >/dev/null 2>&1; then
|
||||
echo Error: Aborting further package installs and reverting to last good binary
|
||||
return 2
|
||||
else
|
||||
echo packages
|
||||
echo $pkgs
|
||||
echo added successfully
|
||||
echo $pkgs >> $CADDY_HOME/bin/installed.pkgs
|
||||
echo "---"
|
||||
echo currently installed packages
|
||||
cat $CADDY_HOME/bin/installed.pkgs
|
||||
echo installed modules from these packages
|
||||
$bin list-modules | sed '1,/Standard modules/d;/Non-standard modules/,$d'
|
||||
echo "-----------------------------------"
|
||||
fi
|
||||
}
|
||||
|
||||
caddy_get_conf () {
|
||||
local conf
|
||||
cd $CADDY_CONF || { echo could not enter conf directory in container; return 2; }
|
||||
if [[ $1 ]];then
|
||||
[[ -f $1 ]] && conf=$1 || conf=$1.conf
|
||||
else
|
||||
conf=.Caddyfile
|
||||
fi
|
||||
echo "$CADDY_CONF/$conf"
|
||||
}
|
||||
|
||||
|
||||
caddy () {
|
||||
|
||||
if [[ ! $CADDY_HOME ]]; then
|
||||
echo caddy run environment is NOT set
|
||||
echo this is an error as the image build should set this
|
||||
echo attempting to recover by sourcing the environment now
|
||||
echo at $ENV_DIR/caddy.env
|
||||
if [[ -f $ENV_DIR/caddy.env ]]; then
|
||||
source $ENV_DIR/caddy.env
|
||||
else
|
||||
echo default environment can not be sourced at $ENV_DIR/caddy.env
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
[[ ! $CADDY_BIN ]] && CADDY_BIN is not set unable to find caddy binary
|
||||
[ ! -f "$CADDY_BIN" ] && echo caddy binary file at $CADDY_BIN does not exist && return 1
|
||||
[ ! -x "$CADDY_BIN" ] && echo caddy binary file $CADDY_BIN is not executable && return 1
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
;&
|
||||
stop)
|
||||
;&
|
||||
validate)
|
||||
;&
|
||||
run)
|
||||
cmd=$1;shift 1
|
||||
conf=$(caddy_get_conf $1)
|
||||
if [[ -f $conf ]]; then
|
||||
# echo checking for any run time packages to add...
|
||||
# caddy_add_packages
|
||||
echo running: $CADDY_BIN $cmd --config $conf --adapter caddyfile
|
||||
$CADDY_BIN $cmd --config $conf --adapter caddyfile
|
||||
else
|
||||
echo no configuration file found at $conf in the container
|
||||
echo make sure you have mounted one from the host into /opt/caddy/conf
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
$CADDY_BIN "$@"
|
||||
|
||||
esac
|
||||
|
||||
}
|
|
@ -0,0 +1,239 @@
|
|||
#!/bin/bash
|
||||
|
||||
shell () {
|
||||
/bin/bash -c "cd ${DEFAULT_DIR:-/}; exec bash -l"
|
||||
}
|
||||
|
||||
func () {
|
||||
local func=$1
|
||||
shift 1
|
||||
$func $@
|
||||
}
|
||||
|
||||
run() {
|
||||
if [ "$(id -u)" = 0 ]; then
|
||||
sudo -u "${NEXTCLOUD_USER:-nextcloud}" bash -c "source /opt/core_run.env; $*"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
idle () {
|
||||
sleep infinity
|
||||
}
|
||||
|
||||
config_update() {
|
||||
echo config.php update
|
||||
backup=$NEXTCLOUD_CONFIG_DIR/config.$(date +%F-%H-%M-%S).php
|
||||
echo making copy of config.php to $backup
|
||||
/bin/cp $NEXTCLOUD_CONFIG_FILE $backup
|
||||
echo "merging additional configurations into config.php now"
|
||||
ls -la $NEXTCLOUD_CONFIG_DIR/*.config.php
|
||||
[[ $NEXTCLOUD_DEV ]] && mv -f $NEXTCLOUD_CONFIG_DIR/config.org.php $NEXTCLOUD_CONFIG_FILE && echo dev mode original config.php used
|
||||
# echo current settings
|
||||
# if [[ $1 ]]; then grep -A6 $1 $NEXTCLOUD_CONFIG_FILE; else cat $NEXTCLOUD_CONFIG_FILE; fi
|
||||
nextcloud occ config:system:delete configs_merged &>/dev/null
|
||||
nextcloud occ config:system:set --value true update_config &>/dev/null
|
||||
nextcloud occ config:system:delete update_config &>/dev/null
|
||||
if nextcloud occ config:system:get configs_merged &>/dev/null; then
|
||||
echo configuration files merged successfully
|
||||
echo "***************************"
|
||||
if [[ $1 ]]; then grep -A6 $1 $NEXTCLOUD_CONFIG_FILE; else cat $NEXTCLOUD_CONFIG_FILE; fi
|
||||
echo "***************************"
|
||||
else
|
||||
echo failed to merge configuration files
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
start () {
|
||||
if nextcloud installed; then
|
||||
if nextcloud supstart; then
|
||||
if nextcloud db start; then
|
||||
sleep 5
|
||||
if nextcloud db online nextcloud; then
|
||||
nextcloud supctl start caddy
|
||||
nextcloud redis start
|
||||
nextcloud supctl start php-fpm
|
||||
sleep 5
|
||||
if nextcloud supctl status mysql caddy redis php-fpm; then
|
||||
nextcloud config_update
|
||||
echo nextcloud services are all online
|
||||
ps -ea
|
||||
echo "------------------------"
|
||||
echo Success! Nextcloud is online
|
||||
[[ $NEXTCLOUD_DOMAIN ]] && echo at $NEXTCLOUD_DOMAIN
|
||||
echo "------------------------"
|
||||
else
|
||||
echo FATAL! unable to bring nextcloud online
|
||||
nextcloud stop
|
||||
fi
|
||||
else
|
||||
echo unable to access the nextcloud database: ${MYSQL_DATABASE:-nextcloud}
|
||||
echo FATAL! can not start nextcloud
|
||||
nextcloud db stop
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo unable to start mysql server
|
||||
echo FATAL! can not start nextcloud
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo "unable to start supervisor, can't start nextcloud"
|
||||
fi
|
||||
else
|
||||
if [[ ! $NEXTCLOUD_DEV ]]; then
|
||||
echo unable to start nextcloud because it is not installed
|
||||
echo installing now...
|
||||
nextcloud install
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
supctl () {
|
||||
/usr/bin/supervisorctl -c $SUPERVISOR_CONF "$@"
|
||||
}
|
||||
|
||||
suprld () {
|
||||
supctl reload
|
||||
}
|
||||
|
||||
supstart () {
|
||||
if ! supctl pid > /dev/null ; then
|
||||
echo supervisord was not running, starting now
|
||||
[[ $1 == -n ]] && echo running in foreground || echo running as daemon
|
||||
BOOT=${BOOT:-false} /usr/bin/supervisord -c $SUPERVISOR_CONF $@
|
||||
else
|
||||
echo supervisor already running
|
||||
fi
|
||||
}
|
||||
|
||||
supstop () {
|
||||
if supctl pid > /dev/null ; then
|
||||
echo killing supervisord at $(cat $SUPERVISOR_HOME/supervisor.pid)
|
||||
kill -s SIGTERM $(cat $SUPERVISOR_HOME/supervisor.pid)
|
||||
sleep 2
|
||||
ps -ea
|
||||
else
|
||||
echo supervisord was not running so not stopping
|
||||
fi
|
||||
}
|
||||
|
||||
stop () {
|
||||
nextcloud supctl stop "${@:-all}"
|
||||
}
|
||||
|
||||
occ () {
|
||||
local _occ=$NEXTCLOUD_SRC_DIR/occ
|
||||
[[ ! -f $_occ ]] && echo "FATAL! no occ command found in $NEXTCLOUD_SRC_DIR" && return 1
|
||||
sudo -u nextcloud -E php $_occ "$@"
|
||||
}
|
||||
|
||||
config () {
|
||||
nextcloud occ config:list --private | grep -A5 -B5 $1
|
||||
}
|
||||
|
||||
install () {
|
||||
|
||||
if [[ ! -f $NEXTCLOUD_SRC_DIR/installed || $NEXTCLOUD_DEV ]]; then
|
||||
if nextcloud supstart > /dev/null; then
|
||||
echo installing nextcloud with args: $@
|
||||
. $LIB_DIR/install/install.sh "$@"
|
||||
else
|
||||
echo unable to run supervisord, thus unable to install nextcloud
|
||||
fi
|
||||
else
|
||||
echo nextcloud already installed
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
upgrade () {
|
||||
if [[ -f $NEXTCLOUD_SRC_DIR/installed ]]; then
|
||||
local cur=$(version)
|
||||
local src=$(version source)
|
||||
echo checking for upgrade from $cur to $src
|
||||
if upgradable $src $cur; then
|
||||
echo upgradable, beginning upgrade process
|
||||
else
|
||||
echo not upgradable
|
||||
if [[ "$cur" == "$src" ]]; then
|
||||
echo same versions nothing to upgrade
|
||||
echo to upgrade pull/build an updated docker image
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo "nextcloud not installed, can not upgrade"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
reinstall () {
|
||||
|
||||
if [[ $(installed) ]]; then
|
||||
if [[ $1 == 'yes' ]]; then
|
||||
echo nextcloud install force
|
||||
else
|
||||
echo reinstall requested.
|
||||
echo because reinstall will potentially trash your current install
|
||||
echo "you need to make sure you have backups of the app (source), the database, and user-files"
|
||||
echo " and then issue the command 'nextcloud reinstall yes"
|
||||
fi
|
||||
else
|
||||
echo nextcloud not installed so reinstall will now do install
|
||||
install
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
app () {
|
||||
|
||||
case "$1" in
|
||||
remove) ;&
|
||||
uninstall)
|
||||
shift 1
|
||||
acmd=remove
|
||||
;;
|
||||
install)
|
||||
shift 1
|
||||
;&
|
||||
*)
|
||||
acmd=install
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
if [[ $1 == "-c" ]]; then
|
||||
shift 1
|
||||
echo installing custom application at $1
|
||||
if wget $1 -O /tmp/ncapp; then
|
||||
app=$(tar -tf /tmp/ncapp | grep -Ex '([^/]+/){1}')
|
||||
app=${app%/}
|
||||
echo $app
|
||||
if [[ $app ]] ; then
|
||||
echo custom app downloaded is $app
|
||||
tar -zxf /tmp/ncapp -C $NEXTCLOUD_APPS_DIR
|
||||
rm /tmp/ncapp
|
||||
nextcloud occ app:enable $app
|
||||
else
|
||||
echo unable to determine the app being installed from at $1
|
||||
fi
|
||||
else
|
||||
echo unable to download nextcloud app at $1
|
||||
fi
|
||||
else
|
||||
apps="$@"
|
||||
for app in $apps; do
|
||||
echo attempting to $acmd nextcloud app $app ...
|
||||
if nextcloud occ app:$acmd $app; then
|
||||
echo nextcloud app $app was successfully ${acmd}ed
|
||||
else
|
||||
echo WARNING: unable to $acmd nextcloud app $app
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
|
|
@ -0,0 +1,123 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
db () {
|
||||
|
||||
case "$1" in
|
||||
init)
|
||||
source $LIB_DIR/install/mysql.lib
|
||||
echo "Intialzing MySQL server"
|
||||
if mysql_init; then
|
||||
echo mysql server successfully intialized
|
||||
else
|
||||
echo FATAL: mysql initialization failed
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
start)
|
||||
nextcloud supstart
|
||||
if nextcloud supctl status mysql 1> /dev/null; then
|
||||
echo MySQL service already online
|
||||
else
|
||||
nextcloud supctl start mysql 1>/dev/null;
|
||||
sleep 4
|
||||
if nextcloud supctl status mysql 1>/dev/null; then
|
||||
echo mysql service online
|
||||
else
|
||||
echo ERROR: unable to start mysql service
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
nextcloud supctl restart mysql
|
||||
;;
|
||||
stop)
|
||||
if nextcloud supctl status mysql; then
|
||||
nextcloud supctl stop mysql;
|
||||
else
|
||||
echo msyql server was not running, nothing to stop
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
mkncdb)
|
||||
source $LIB_DIR/install/mysql.lib
|
||||
mysql_create_nextcloud_db
|
||||
;;
|
||||
online)
|
||||
shift 1
|
||||
case "$1" in
|
||||
core)
|
||||
;&
|
||||
nextcloud)
|
||||
if [[ $1 == "core" ]]; then
|
||||
dcmd="$DB_CLIENT_BIN $DB_SERVER_OPTS -uroot mysql"
|
||||
else
|
||||
dcmd="nextcloud run $DB_CLIENT_BIN $DB_SERVER_OPTS $MYSQL_DATABASE"
|
||||
fi
|
||||
echo checking status of database $MYSQL_DATABASE
|
||||
if nextcloud db online 1> /dev/null ; then
|
||||
# echo DEBUG: command to run $dcmd
|
||||
if timeout 10s bash -c "source /opt/bin/nextcloud; _db_online $dcmd" ; then
|
||||
echo database $1 is online
|
||||
return 0
|
||||
else
|
||||
echo database $1 is offline
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo database server is not online so can not check status of database $1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo checking to see if db server is online
|
||||
if nextcloud supctl status mysql >/dev/null ; then
|
||||
echo mysql server daemon is running
|
||||
return 0
|
||||
else
|
||||
echo mysql server daemon is offline
|
||||
sleep 1
|
||||
return 1
|
||||
fi
|
||||
|
||||
esac
|
||||
|
||||
;;
|
||||
root)
|
||||
if db online mysql; then
|
||||
shift 1
|
||||
# -e \"$*\"
|
||||
cmd="$DB_CLIENT_BIN $DB_SERVER_OPTS -uroot mysql"
|
||||
if [[ $* ]]; then
|
||||
echo $*
|
||||
query="$*"
|
||||
echo $query
|
||||
$cmd <<< $query
|
||||
else
|
||||
$cmd
|
||||
fi
|
||||
else
|
||||
echo mysql server is offline or no root mysql database has been created
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
cmd="nextcloud run $DB_CLIENT_BIN $DB_SERVER_OPTS $MYSQL_DATABASE"
|
||||
echo $cmd
|
||||
[[ $* ]] && $cmd <<< "$*" || $cmd
|
||||
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
_db_online () {
|
||||
# echo $@
|
||||
if $@ <<< "select 1" >/dev/null 2>&1 ; then
|
||||
return 0
|
||||
else
|
||||
sleep 1
|
||||
# echo trying to connect to database
|
||||
_db_online $@
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
|
@ -0,0 +1,163 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
# return true if specified directory is empty
|
||||
directory_empty() {
|
||||
[ -z "$(ls -A "$1/")" ]
|
||||
}
|
||||
|
||||
# usage: file_env VAR [DEFAULT]
|
||||
# ie: file_env 'XYZ_DB_PASSWORD' 'example'
|
||||
# (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of
|
||||
# "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature)
|
||||
# file_env() {
|
||||
# local var="$1"
|
||||
# local fileVar="${var}_FILE"
|
||||
# local def="${2:-}"
|
||||
# local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//")
|
||||
# local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//")
|
||||
# if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then
|
||||
# echo >&2 "error: both $var and $fileVar are set (but are exclusive)"
|
||||
# exit 1
|
||||
# fi
|
||||
# if [ -n "${varValue}" ]; then
|
||||
# export "$var"="${varValue}"
|
||||
# elif [ -n "${fileVarValue}" ]; then
|
||||
# export "$var"="$(cat "${fileVarValue}")"
|
||||
# elif [ -n "${def}" ]; then
|
||||
# export "$var"="$def"
|
||||
# fi
|
||||
# unset "$fileVar"
|
||||
# }
|
||||
|
||||
version () {
|
||||
local ver
|
||||
if [[ $1 == "image" ]]; then
|
||||
ver=$(php -d display_errors="0" -r 'require "'$NEXTCLOUD_INSTALL_FROM_DIR'/version.php"; echo implode(".",$OC_Version);' 2>/dev/null)
|
||||
if [[ ! $ver ]]; then
|
||||
echo "SUPER FATAL ERROR NO NEXTCLOUD ALPINE IMAGE SOURCE FOUND AT $NEXTCLOUD_INSTALL_FROM_DIR"
|
||||
return 1
|
||||
else
|
||||
echo $ver
|
||||
fi
|
||||
else
|
||||
ver=$(php -d display_errors="0" -r 'require "'$NEXTCLOUD_SRC_DIR'/version.php"; echo implode(".",$OC_Version);' 2>/dev/null)
|
||||
if [[ ! $ver ]]; then
|
||||
unset NEXTCLOUD_INSTALLED
|
||||
return 1
|
||||
else
|
||||
echo $ver
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
installed () {
|
||||
if [[ -f $NEXTCLOUD_HOME/installed ]]; then
|
||||
echo $(cat $NEXTCLOUD_HOME/installed)
|
||||
return 0
|
||||
else
|
||||
# echo "WARNING: nextcloud not installed, run 'nextcloud install'"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
upgradable () {
|
||||
# printf '%s\n' $1 $2 | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4
|
||||
# | head -n 1
|
||||
[ "$(printf '%s\n' $1 $2 | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ]
|
||||
}
|
||||
|
||||
process_template () {
|
||||
|
||||
if [[ -f "$1.tmpl" ]]; then
|
||||
cat "$1.tmpl" | grep -v '^#' | grep -v "^$" | sed -n '/^\s*$/!p' | envsubst > "$1"
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# TODO PHP
|
||||
|
||||
list_php_settings () {
|
||||
cat $PHP_INI_DIR/$1 | grep -v '^;' | grep -v '^$'
|
||||
}
|
||||
|
||||
list_php_modules () {
|
||||
# php -r "print_r(get_loaded_extensions());"
|
||||
php -m
|
||||
}
|
||||
|
||||
edit_phpfpm_config () {
|
||||
nano /etc/php$PHP_VERSION/php-fpm.d/nextcloud.conf
|
||||
}
|
||||
|
||||
config_array() {
|
||||
local idx=0
|
||||
local item
|
||||
local key=$1
|
||||
shift 1
|
||||
# TODO count items first and set idx accordingly
|
||||
for item in "$@" ; do
|
||||
item=$(echo "$item" | sed -e 's/^["]*//' -e 's/["]*$//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' )
|
||||
nextcloud occ config:system:set $key $idx --value=$item
|
||||
idx=$(($idx+1))
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
config_add_array() {
|
||||
local idx=0
|
||||
local item
|
||||
local key=$1
|
||||
shift 1
|
||||
# TODO count items first and set idx accordingly
|
||||
for item in "$@" ; do
|
||||
item=$(echo "$item" | sed -e 's/^["]*//' -e 's/["]*$//' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' )
|
||||
nextcloud occ config:system:set $key $idx --value=$item
|
||||
idx=$(($idx+1))
|
||||
done
|
||||
}
|
||||
|
||||
config () {
|
||||
local sub=$1
|
||||
shift 1
|
||||
case $sub in
|
||||
list)
|
||||
nextcloud config:list --private system
|
||||
;;
|
||||
get)
|
||||
if ! nextcloud config:system:get $1; then
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
del)
|
||||
nextcloud config:system:delete $1
|
||||
;;
|
||||
array)
|
||||
shift 1
|
||||
config_add_array "$@"
|
||||
echo $(nextcloud occ config:system:get $1)
|
||||
;;
|
||||
set)
|
||||
if ! nextcloud occ config:system:set $1 --value=$2 ; then
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
sub=$1
|
||||
nextcloud occ config:$sub "$@"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
docker_latest_image() {
|
||||
image=$1
|
||||
major=${2:-1}
|
||||
tokenUri="https://auth.docker.io/token"
|
||||
data=("service=registry.docker.io" "scope=repository:$image:pull")
|
||||
token="$(curl --silent --get --data-urlencode ${data[0]} --data-urlencode ${data[1]} $tokenUri | jq --raw-output '.token')"
|
||||
listUri="https://registry-1.docker.io/v2/$image/tags/list"
|
||||
curl --silent --get -H "Accept: application/json" -H "Authorization: Bearer $token" $listUri \
|
||||
| jq --raw-output ".tags[] | select(. | startswith(\"$major.\"))" | sort -V | sed -n \$p
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
/config/
|
||||
/apps/
|
||||
/themes/
|
||||
/apps-appstore/
|
|
@ -0,0 +1,127 @@
|
|||
#!/bin/bash
|
||||
|
||||
nc_scrub () {
|
||||
if [[ $1 == "yes" ]]; then
|
||||
rm -rf $NEXTCLOUD_SRC_DIR/*
|
||||
rm -rf $NEXTCLOUD_DATA_DIR/*
|
||||
rm -rf $NEXTCLOUD_THEMES_DIR/*
|
||||
rm $NEXTCLOUD_CONFIG_FILE
|
||||
else
|
||||
echo nc_scrub is super dangerous function, you must use 'nc_scrub yes' in order to actually scrub the install
|
||||
fi
|
||||
}
|
||||
|
||||
install_failed () {
|
||||
unset NEXTCLOUD_INSTALLING
|
||||
echo doing cleanup from failed install
|
||||
}
|
||||
|
||||
if [[ -f $NEXTCLOUD_SRC_DIR/version.php || -f $NEXTCLOUD_CONFIG_FILE ]]; then
|
||||
echo this is not a clean install there are files in $NEXTCLOUD_SRC_DIR
|
||||
echo or $NEXTCLOUD_CONFIG_FILE exists
|
||||
echo to avoid possibly overwriting the configuration/install by mistake
|
||||
echo "this install is aborted, use 'nextcloud update' instead"
|
||||
[[ ! ( $NEXTCLOUD_DEV || $1 == "force" ) ]] && return 1 || echo dev or force mode, continuing install
|
||||
fi
|
||||
|
||||
export NEXTCLOUD_INSTALLING=true
|
||||
|
||||
if [[ ! -f $NEXTCLOUD_SRC_DIR/version.php ]]; then
|
||||
export NEXTCLOUD_APPS_DIR=$NEXTCLOUD_HOME/apps
|
||||
echo copying nextcloud source at $NEXTCLOUD_INSTALL_FROM_DIR to the instance directory $NEXTCLOUD_SRC_DIR
|
||||
rsync -rlD --chown=$NEXTCLOUD_USER:$NEXTCLOUD_USER --exclude-from=$LIB_DIR/install/install.exclude $NEXTCLOUD_INSTALL_FROM_DIR/ $NEXTCLOUD_SRC_DIR/
|
||||
echo copying nextcloud apps at $NEXTCLOUD_INSTALL_FROM_DIR/apps to the apps directory $NEXTCLOUD_APPS_DIR
|
||||
rsync -rlD --chown=$NEXTCLOUD_USER:$NEXTCLOUD_USER $NEXTCLOUD_INSTALL_FROM_DIR/apps/ $NEXTCLOUD_APPS_DIR/
|
||||
echo copying nextcloud themes at $NEXTCLOUD_INSTALL_FROM_DIR/themes to themes directory $NEXTCLOUD_THEMES_DIR
|
||||
rsync -rlD --chown=$NEXTCLOUD_USER:$NEXTCLOUD_USER $NEXTCLOUD_INSTALL_FROM_DIR/themes/ $NEXTCLOUD_THEMES_DIR/
|
||||
|
||||
rm $NEXTCLOUD_SRC_DIR/apps-appstore
|
||||
rm $NEXTCLOUD_SRC_DIR/config
|
||||
|
||||
ln -s $NEXTCLOUD_APPS_DIR $NEXTCLOUD_SRC_DIR/apps
|
||||
ln -s $NEXTCLOUD_THEMES_DIR $NEXTCLOUD_SRC_DIR/themes
|
||||
ln -s $NEXTCLOUD_CONFIG_DIR $NEXTCLOUD_SRC_DIR/config
|
||||
else
|
||||
echo source files already installed, skipping source files copy
|
||||
fi
|
||||
|
||||
# --database=DATABASE Supported database type [default: "sqlite"]
|
||||
# --database-name=DATABASE-NAME Name of the database
|
||||
# --database-host=DATABASE-HOST Hostname of the database [default: "localhost"]
|
||||
# --database-port=DATABASE-PORT Port the database is listening on
|
||||
# --database-user=DATABASE-USER User name to connect to the database
|
||||
# --database-pass[=DATABASE-PASS] Password of the database user
|
||||
# --database-table-space[=DATABASE-TABLE-SPACE] Table space of the database (oci only)
|
||||
# --admin-user=ADMIN-USER User name of the admin account [default: "admin"]
|
||||
# --admin-pass=ADMIN-PASS Password of the admin account
|
||||
# --admin-email[=ADMIN-EMAIL] E-Mail of the admin account
|
||||
# --data-dir=DATA-DIR
|
||||
|
||||
install_options="--admin-user ${NEXTCLOUD_ADMIN_USER:-admin} --admin-pass ${NEXTCLOUD_ADMIN_PASSWORD:-admin} --admin-email ${NEXTCLOUD_ADMIN_EMAIL:-xxx@gmail.com} "
|
||||
install_options+=" --data-dir $NEXTCLOUD_DATA_DIR"
|
||||
|
||||
# DB setup and admin user are set via autoconfig.php
|
||||
|
||||
if [[ $NEXTCLOUD_DEV ]]; then
|
||||
nextcloud stop
|
||||
sleep 3
|
||||
echo dev mode, moving config.php and deleting nextcloud db
|
||||
mv $NEXTCLOUD_HOME/config/config.php $NEXTCLOUD_HOME/config/config.php.sav 2>/dev/null
|
||||
/bin/rm -rf $NEXTCLOUD_HOME/user-files/*
|
||||
mv $NEXTCLOUD_HOME/db/mysql.conf.tmpl /tmp/
|
||||
/bin/rm -rf $NEXTCLOUD_HOME/db/*
|
||||
mv /tmp/mysql.conf.tmpl $NEXTCLOUD_HOME/db
|
||||
fi
|
||||
|
||||
# set database
|
||||
source $LIB_DIR/db.lib
|
||||
echo intializing mysql server databases for nextcloud use...be patient
|
||||
if ! db init; then echo unable to initialze mysql database, thus nextcloud install failed; return 1; fi
|
||||
echo bringing now ready mysql server online to complete nextcloud installation
|
||||
nextcloud db start
|
||||
sleep 5
|
||||
if nextcloud supctl status mysql; then
|
||||
if nextcloud db online nextcloud; then
|
||||
install_options+=" --database mysql --database-name $MYSQL_DATABASE --database-user nextcloud --database-pass nextcloud --database-host localhost:/run/nextcloud/db.sock"
|
||||
echo initializing nextcloud via maintence:install...please wait
|
||||
cmd="sudo -u nextcloud $NEXTCLOUD_SRC_DIR/occ maintenance:install $install_options"
|
||||
[[ $NEXTCLOUD_DEV ]] && echo DEBUG: $cmd
|
||||
if $cmd; then
|
||||
/bin/cp $NEXTCLOUD_CONFIG_FILE $NEXTCLOUD_CONFIG_DIR/config.init.php
|
||||
echo SUCCESS: maintenance:install succeeded! Nextcloud is installed
|
||||
echo installed version $(version) on > $NEXTCLOUD_HOME/installed
|
||||
echo $(date) >> $NEXTCLOUD_HOME/installed
|
||||
cat $NEXTCLOUD_HOME/installed
|
||||
echo "**** NOTE: default administrator login is user:${NEXTCLOUD_ADMIN_USER:-admin} password: ${NEXTCLOUD_ADMIN_PASSWORD:-admin} ***"
|
||||
echo merging config files into config.php
|
||||
echo starting nextcloud now
|
||||
if nextcloud start; then
|
||||
unset NEXTCLOUD_INSTALLING
|
||||
if [[ $NEXTCLOUD_APPS ]]; then
|
||||
echo installing nextcloud apps from list
|
||||
echo $NEXTCLOUD_APPS
|
||||
nextcloud app install $NEXTCLOUD_APPS
|
||||
echo "done installing apps"
|
||||
fi
|
||||
else
|
||||
echo FATAL! could not bring up nextcloud after successfull install
|
||||
install_failed
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo FATAL! - Install was not successful
|
||||
install_failed
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo nextcloud database never came online
|
||||
echo FATAL! unable to finish nextcloud installation
|
||||
install_failed
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo FATAL! unable to bring up mysql database, install FAILED
|
||||
install_failed
|
||||
return 1
|
||||
fi
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
#!/bin/bash
|
||||
|
||||
# ENVIRONENT VARIABLES as get in db.env
|
||||
# as set in $ENV_DIR/mysql.env
|
||||
# export DB_HOME=$NEXTCLOUD_DB_DIR
|
||||
# export DB_CONF=$DB_HOME/mysql.conf
|
||||
# export DB_SERVER_BIN="$(which mysqld)"
|
||||
# export DB_SERVER_BIN="$(which mysqld)"
|
||||
# export DB_CLIENT_BIN="$(which mysql)"
|
||||
# export DB_SERVER_OPTS=" --defaults-file=$DB_CONF"
|
||||
# export MYSQL_DATABASE=${MYSQL_DATABASE:-nextcloud}
|
||||
# export MYSQL_USER=${MYSQL_USER:-nextcloud}
|
||||
# export MYSQL_ROOT_PASSWORD=${MYSQL_PASSWORD:-nextcloud1234}
|
||||
# export MYSQL_PASSWORD=${MYSQL_PASSWORD:-$MYSQL_ROOT_PASSWORD}
|
||||
|
||||
mysql_init () {
|
||||
|
||||
if nextcloud func process_template $DB_CONF; then
|
||||
if [ -d $DB_HOME/mysql ]; then
|
||||
echo "MySQL system DB $DB_HOME/mysql already present, skipping initial creation"
|
||||
else
|
||||
echo "MySQL data directory not found, creating initial mysql DBs"
|
||||
chown -R nextcloud:nextcloud $DB_HOME
|
||||
# mysql_install_db is a mysql cli command
|
||||
if mysql_install_db $DB_SERVER_OPTS >/dev/null; then
|
||||
echo mysql system DBs succesfully created
|
||||
if nextcloud db start; then
|
||||
if nextcloud db online mysql; then
|
||||
echo creating additional root user with root password
|
||||
$DB_CLIENT_BIN $DB_SERVER_OPTS -uroot << EOF
|
||||
CREATE USER 'root'@'%' IDENTIFIED BY '$MYSQL_ROOT_PASSWORD';
|
||||
GRANT ALL PRIVILEGES on *.* to 'root'@'%';
|
||||
FLUSH privileges;
|
||||
EOF
|
||||
echo creating empty nextcloud DB...
|
||||
if mysql_create_nextcloud_db; then
|
||||
echo Success!
|
||||
echo MySQL initialzed for Nextcloud on $(date) > $DB_HOME/installed
|
||||
cat $DB_HOME/installed
|
||||
else
|
||||
echo FATAL: unable to to create user and database nextcloud
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo FATAL: could not access mysql system database
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo FATAL: could not start mysql daemon
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
echo FATAL: unable to make mysql system DB.
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
else
|
||||
echo unable to make mysql.conf from template in $DB_HOME
|
||||
return 1
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
||||
mysql_create_nextcloud_db () {
|
||||
|
||||
echo creating nextcloud db user and database
|
||||
$DB_CLIENT_BIN $DB_SERVER_OPTS -uroot << EOF
|
||||
CREATE DATABASE IF NOT EXISTS $MYSQL_DATABASE CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
|
||||
GRANT ALL PRIVILEGES on $MYSQL_DATABASE.* to 'nextcloud'@'localhost';
|
||||
CREATE USER '$MYSQL_USER'@'%' IDENTIFIED BY '$MYSQL_PASSWORD';
|
||||
GRANT ALL PRIVILEGES on $MYSQL_DATABASE.* to '$MYSQL_USER'@'%';
|
||||
FLUSH privileges;
|
||||
EOF
|
||||
sleep 5
|
||||
if nextcloud db online nextcloud; then
|
||||
echo "nextcloud database successfully created"
|
||||
else
|
||||
echo FATAL! error attemping to create nextcloud database with mysql
|
||||
return 1
|
||||
fi
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/bash
|
||||
source $LIB_DIR/verbose.lib
|
||||
source $LIB_DIR/helpers.lib
|
||||
source $LIB_DIR/db.lib
|
||||
source $LIB_DIR/redis.lib
|
||||
source $LIB_DIR/caddy.lib
|
||||
source $LIB_DIR/cmds.lib
|
||||
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
#!/bin/bash
|
||||
redis () {
|
||||
|
||||
[[ ! -f "$REDIS_CONF" ]] && nextcloud func process_template $REDIS_CONF
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
if nextcloud supctl status redis 1> /dev/null; then
|
||||
echo Redis server already running
|
||||
else
|
||||
nextcloud supctl start redis;
|
||||
fi
|
||||
;;
|
||||
restart)
|
||||
nextcloud supctl restart redis
|
||||
;;
|
||||
stop)
|
||||
if nextcloud supctl status mysql; then
|
||||
nextcloud supctl stop mysql;
|
||||
else
|
||||
echo msyql server was not running, nothing to stop
|
||||
return 0
|
||||
fi
|
||||
;;
|
||||
init)
|
||||
if ! nextcloud func process_template $REDIS_CONF; then
|
||||
echo unable to make $REDIS_CONF
|
||||
fi
|
||||
;;
|
||||
|
||||
esac
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
/config/
|
||||
/data/
|
||||
/custom_apps/
|
||||
/themes/
|
||||
/version.php
|
||||
/nextcloud-init-sync.lock
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
$CONFIG = array (
|
||||
'apps_paths' => array (
|
||||
0 => array (
|
||||
'path' => OC::$SERVERROOT.'/apps',
|
||||
'url' => '/apps',
|
||||
'writable' => true,
|
||||
),
|
||||
),
|
||||
);
|
|
@ -0,0 +1,11 @@
|
|||
<?php
|
||||
$CONFIG = array(
|
||||
'memcache.local' => '\OC\Memcache\APCu',
|
||||
'memcache.distributed' => '\OC\Memcache\Redis',
|
||||
'memcache.locking' => '\OC\Memcache\Redis',
|
||||
'redis' => array(
|
||||
'host' => '/run/nextcloud/redis.sock',
|
||||
'port' => 0,
|
||||
'timeout' => 0.0,
|
||||
),
|
||||
);
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
$CONFIG = array (
|
||||
'logfile' =>getenv('NEXTCLOUD_LOGS_DIR') ?: '/opt/nextcloud/logs'.'/nextcloud.log',
|
||||
'default_phone_region' => getenv('NEXTCLOUD_REGION') ?: 'US',
|
||||
'configs_merged' => true,
|
||||
);
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
$overwriteHost = getenv('OVERWRITEHOST');
|
||||
if ($overwriteHost) {
|
||||
$CONFIG['overwritehost'] = $overwriteHost;
|
||||
}
|
||||
|
||||
$overwriteProtocol = getenv('NEXTCLOUD_DOMAIN');
|
||||
if ($overwriteProtocol) {
|
||||
$CONFIG['overwriteprotocol'] = 'https';
|
||||
}
|
||||
|
||||
$overwriteCliUrl ="https://" . getenv('NEXTCLOUD_DOMAIN');
|
||||
if ($overwriteCliUrl) {
|
||||
$CONFIG['overwrite.cli.url'] = $overwriteCliUrl;
|
||||
}
|
||||
|
||||
$overwriteWebRoot = getenv('OVERWRITEWEBROOT');
|
||||
if ($overwriteWebRoot) {
|
||||
$CONFIG['overwritewebroot'] = $overwriteWebRoot;
|
||||
}
|
||||
|
||||
$overwriteCondAddr = getenv('OVERWRITECONDADDR');
|
||||
if ($overwriteCondAddr) {
|
||||
$CONFIG['overwritecondaddr'] = $overwriteCondAddr;
|
||||
}
|
||||
|
||||
$trustedProxies = getenv('NEXTCLOUD_TRUSTED_PROXIES');
|
||||
if ($trustedProxies) {
|
||||
$CONFIG['trusted_proxies'] = array_filter(array_map('trim', explode(' ', $trustedProxies)));
|
||||
$CONFIG['forwarded_for_headers'] => array('HTTP_X_FORWARDED_FOR'),
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
<?php
|
||||
if (getenv('SMTP_HOST') && getenv('MAIL_FROM_ADDRESS') && getenv('MAIL_DOMAIN')) {
|
||||
$CONFIG = array (
|
||||
'mail_smtpmode' => 'smtp',
|
||||
'mail_smtphost' => getenv('SMTP_HOST'),
|
||||
'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25),
|
||||
'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '',
|
||||
'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || (getenv('SMTP_PASSWORD_FILE') && file_exists(getenv('SMTP_PASSWORD_FILE')))),
|
||||
'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN',
|
||||
'mail_smtpname' => getenv('SMTP_NAME') ?: '',
|
||||
'mail_from_address' => getenv('MAIL_FROM_ADDRESS'),
|
||||
'mail_domain' => getenv('MAIL_DOMAIN'),
|
||||
);
|
||||
|
||||
if (getenv('SMTP_PASSWORD_FILE') && file_exists(getenv('SMTP_PASSWORD_FILE'))) {
|
||||
$CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE')));
|
||||
} elseif (getenv('SMTP_PASSWORD')) {
|
||||
$CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD');
|
||||
} else {
|
||||
$CONFIG['mail_smtppassword'] = '';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?php
|
||||
$trustedDomains = getenv('NEXTCLOUD_TRUSTED_DOMAINS');
|
||||
if ($trustedDomains) {
|
||||
$trustedDomains = "0.0.0.0 localhost " . $trustedDomains;
|
||||
$CONFIG['trusted_domains'] = array_filter(array_map('trim', explode(' ', $trustedDomains)));
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
[server]
|
||||
skip_name_resolve = 1
|
||||
innodb_buffer_pool_size = 128M
|
||||
innodb_flush_log_at_trx_commit = 2
|
||||
innodb_log_buffer_size = 32M
|
||||
innodb_max_dirty_pages_pct = 90
|
||||
query_cache_type = 1
|
||||
query_cache_limit = 2M
|
||||
query_cache_min_res_unit = 2k
|
||||
query_cache_size = 64M
|
||||
tmp_table_size= 64M
|
||||
max_heap_table_size= 64M
|
||||
slow_query_log = 1
|
||||
slow_query_log_file = $NEXTCLOUD_LOGS_DIR/db-slow.log
|
||||
long_query_time = 1
|
||||
general_log_file = $NEXTCLOUD_LOGS_DIR/db.log
|
||||
general_log = 1
|
||||
|
||||
[client]
|
||||
default-character-set = utf8mb4
|
||||
user = nextcloud
|
||||
socket = /run/nextcloud/db.sock
|
||||
|
||||
[mariadb]
|
||||
user = nextcloud
|
||||
pid-file = /run/nextcloud/db.pid
|
||||
socket = /run/nextcloud/db.sock
|
||||
datadir = $DB_HOME
|
||||
lc-messages-dir = $DB_HOME/messages
|
||||
bind-address = 127.0.0.1
|
||||
character_set_server = utf8mb4
|
||||
collation_server = utf8mb4_general_ci
|
||||
transaction_isolation = READ-COMMITTED
|
||||
log-bin = 1
|
||||
binlog_format = ROW
|
||||
innodb_file_per_table=1
|
||||
|
||||
[mysqld_safe]
|
||||
log-error=$NEXTCLOUD_LOGS_DIR/mysql_safe.err
|
||||
# pid-file=$DB_HOME/mysqld.pid
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
phpinfo();
|
||||
?>
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
//simple counter to test sessions. should increment on each page reload.
|
||||
session_start();
|
||||
$count = isset($_SESSION['count']) ? $_SESSION['count'] : 1;
|
||||
|
||||
echo $count;
|
||||
|
||||
$_SESSION['count'] = ++$count;
|
|
@ -0,0 +1,11 @@
|
|||
[program:caddy]
|
||||
command=%(ENV_CADDY_BIN)s run --config %(ENV_CADDY_CONF)s/.Caddyfile --adapter caddyfile
|
||||
stopsignal=QUIT
|
||||
autostart=false
|
||||
;autorestart=unexpected
|
||||
priority=2
|
||||
user=nextcloud
|
||||
stdout_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/supervisor/caddy.log
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/supervisor/caddy.err
|
||||
stderr_logfile_maxbytes=0
|
|
@ -0,0 +1,10 @@
|
|||
[program:mysql]
|
||||
command=/usr/bin/pidproxy /run/nextcloud/db.pid /usr/bin/mysqld_safe %(ENV_DB_SERVER_OPTS)s
|
||||
autostart=false
|
||||
;autorestart=unexpected
|
||||
priority=1
|
||||
user=nextcloud
|
||||
stdout_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/supervisor/mysql.log
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/supervisor/mysql.err
|
||||
stderr_logfile_maxbytes=0
|
|
@ -0,0 +1,10 @@
|
|||
[program:nextcloud]
|
||||
priority=1
|
||||
command=/opt/bin/nextcloud start
|
||||
stdout_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/start.log
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/start.err
|
||||
stderr_logfile_maxbytes=0
|
||||
autostart=%(ENV_BOOT)s
|
||||
autorestart=false
|
||||
startsecs=0
|
|
@ -0,0 +1,24 @@
|
|||
[program:php-fpm]
|
||||
command = /bin/php-fpm -g /run/nextcloud/php-fpm.pid -F
|
||||
autostart=false
|
||||
; autorestart=unexpected
|
||||
priority=3
|
||||
user=nextcloud
|
||||
stdout_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/supervisor/php-fpm.log
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/supervisor/php-fpm.err
|
||||
stderr_logfile_maxbytes=0
|
||||
|
||||
|
||||
; [program:php-fpm]
|
||||
; command = /bin/php-fpm --force-stderr --nodaemonize --fpm-config
|
||||
; autostart=false
|
||||
; ;autorestart=true
|
||||
; priority=5
|
||||
; stdout_events_enabled=true
|
||||
; stderr_events_enabled=true
|
||||
; stdout_logfile=/dev/stdout
|
||||
; stdout_logfile_maxbytes=0
|
||||
; stderr_logfile=/dev/stderr
|
||||
; stderr_logfile_maxbytes=0
|
||||
; stopsignal=QUIT
|
|
@ -0,0 +1,10 @@
|
|||
[program:redis]
|
||||
command=%(ENV_REDIS_BIN)s %(ENV_REDIS_CONF)s
|
||||
directory=%(ENV_REDIS_HOME)s
|
||||
autostart=false
|
||||
priority=1
|
||||
user=nextcloud
|
||||
stdout_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/supervisor/redis.log
|
||||
stdout_logfile_maxbytes=0
|
||||
stderr_logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/supervisor/redis.err
|
||||
stderr_logfile_maxbytes=0
|
|
@ -0,0 +1,24 @@
|
|||
[unix_http_server]
|
||||
file=/run/nextcloud/supervisor.sock
|
||||
; chown=nextcloud:nextcloud
|
||||
|
||||
[inet_http_server] ; inet (TCP) server disabled by default
|
||||
port=0.0.0.0:9001 ; (ip_address:port specifier, *:port for all iface)
|
||||
;username=user ; (default is no username (open server))
|
||||
;password=123 ; (default is no password (open server))
|
||||
|
||||
[supervisord]
|
||||
;nodaemon=true
|
||||
user=root
|
||||
logfile=%(ENV_NEXTCLOUD_LOGS_DIR)s/supervisor.log
|
||||
pidfile=%(ENV_SUPERVISOR_HOME)s/supervisor.pid
|
||||
childlogdir=%(ENV_NEXTCLOUD_LOGS_DIR)s
|
||||
|
||||
[rpcinterface:supervisor]
|
||||
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
|
||||
|
||||
[supervisorctl]
|
||||
serverurl=unix:///run/nextcloud/supervisor.sock
|
||||
|
||||
[include]
|
||||
files = %(ENV_SUPERVISOR_HOME)s/*.ini
|
Loading…
Reference in New Issue