From c33cabc537f07ebdcecea561287d02aae51388f5 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Wed, 14 Jun 2017 18:18:58 +0200 Subject: nc-init as a nextcloudpi-config option --- batch.sh | 2 +- docker/nextcloud.dockerfile | 2 +- docker/run-nc.sh | 2 +- etc/nc-init.sh | 83 ------------------------ etc/nextcloudpi-config.d/nc-init.sh | 106 +++++++++++++++++++++++++++++++ etc/nextcloudpi-config.d/nc-nextcloud.sh | 72 ++++++++++++++++++++- lamp.sh | 28 +------- test-devel.sh | 2 +- 8 files changed, 181 insertions(+), 116 deletions(-) delete mode 100644 etc/nc-init.sh create mode 100644 etc/nextcloudpi-config.d/nc-init.sh diff --git a/batch.sh b/batch.sh index fab79d71..6873deac 100755 --- a/batch.sh +++ b/batch.sh @@ -13,7 +13,7 @@ source etc/library.sh # initializes $IMGNAME IP=$1 # First argument is the QEMU Raspbian IP address NC_INSTALL=etc/nextcloudpi-config.d/nc-nextcloud.sh -NC_CONFIG=etc/nc-init.sh +NC_CONFIG=etc/nextcloudpi-config.d/nc-init.sh IMGBASE="NextCloudPi_$( date "+%m-%d-%y" )_base.img" diff --git a/docker/nextcloud.dockerfile b/docker/nextcloud.dockerfile index 7ab5672d..1d24d6b9 100644 --- a/docker/nextcloud.dockerfile +++ b/docker/nextcloud.dockerfile @@ -7,7 +7,7 @@ MAINTAINER Ignacio Núñez Hernanz SHELL ["/bin/bash", "-c"] -COPY etc/library.sh etc/nc-init.sh etc/nextcloudpi-config.d/nc-nextcloud.sh /usr/local/etc/ +COPY etc/library.sh etc/nextcloudpi-config.d/nc-init.sh etc/nextcloudpi-config.d/nc-nextcloud.sh /usr/local/etc/ RUN apt-get update; apt-get install --no-install-recommends -y wget ca-certificates; \ source /usr/local/etc/library.sh; set +x; activate_script /usr/local/etc/nc-nextcloud.sh; \ diff --git a/docker/run-nc.sh b/docker/run-nc.sh index f07e72b3..e697b64c 100755 --- a/docker/run-nc.sh +++ b/docker/run-nc.sh @@ -31,7 +31,7 @@ test -d /data/app || { # INIT DATABASE AND NEXTCLOUD CONFIG source /usr/local/etc/library.sh - install_script /usr/local/etc/nc-init.sh + activate_script /usr/local/etc/nextcloudpi-config.d/nc-init.sh # COPY DATADIR TO /data, WHICH WILL BE IN A PERSISTENT VOLUME cd /var/www/nextcloud/ diff --git a/etc/nc-init.sh b/etc/nc-init.sh deleted file mode 100644 index df44b188..00000000 --- a/etc/nc-init.sh +++ /dev/null @@ -1,83 +0,0 @@ -#!/bin/bash - -# Init NextCloud database and perform initial configuration -# Tested with 2017-03-02-raspbian-jessie-lite.img -# -# Copyleft 2017 by Ignacio Nunez Hernanz -# GPL licensed (see end of file) * Use at your own risk! -# -# Usage: -# -# ./installer.sh nc-init.sh () -# -# See installer.sh instructions for details -# -# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ -# - -ADMINUSER_=admin -DBADMIN_=ncadmin -DBPASSWD_=ownyourbits - -install() -{ - ## RE-CREATE DATABASE TABLE (workaround to emulate DROP USER IF EXISTS ..;) - - echo "Setting up database..." - - # wait for mariadb - while :; do - [[ -S /var/run/mysqld/mysqld.sock ]] && break - sleep 0.5 - done - - mysql -u root -p$DBPASSWD_ < '\''\\\\OC\\\\Memcache\\\\APCu'\'',' /var/www/nextcloud/config/config.php - - # 4 Byte UTF8 support - sudo -u www-data php occ config:system:set mysql.utf8mb4 --type boolean --value="true" -} - -configure(){ :; } -cleanup() { :; } - -# License -# -# This script is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This script is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this script; if not, write to the -# Free Software Foundation, Inc., 59 Temple Place, Suite 330, -# Boston, MA 02111-1307 USA diff --git a/etc/nextcloudpi-config.d/nc-init.sh b/etc/nextcloudpi-config.d/nc-init.sh new file mode 100644 index 00000000..e35b3367 --- /dev/null +++ b/etc/nextcloudpi-config.d/nc-init.sh @@ -0,0 +1,106 @@ +#!/bin/bash + +# Init NextCloud database and perform initial configuration +# Tested with 2017-03-02-raspbian-jessie-lite.img +# +# Copyleft 2017 by Ignacio Nunez Hernanz +# GPL licensed (see end of file) * Use at your own risk! +# +# Usage: +# +# ./installer.sh nc-init.sh () +# +# See installer.sh instructions for details +# +# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ +# + +ADMINUSER_=admin +DBADMIN_=ncadmin +DBPASSWD_=ownyourbits +DESCRIPTION="(Re)initiate Nextcloud to a clean configuration" + +show_info() +{ + whiptail --yesno \ + --backtitle "NextCloudPi configuration" \ + --title "Clean NextCloud configuration" \ +"This action will configure NextCloud to NextCloudPi defaults. + +** YOUR CONFIGURATION WILL BE LOST ** + +" \ + 20 90 +} + +configure() +{ + systemctl stop apache2; + + ## RE-CREATE DATABASE TABLE + + echo "Setting up database..." + + # wait for mariadb + while :; do + [[ -S /var/run/mysqld/mysqld.sock ]] && break + sleep 0.5 + done + + # workaround to emulate DROP USER IF EXISTS ..;) + mysql -u root -p$DBPASSWD_ < '\''\\\\OC\\\\Memcache\\\\APCu'\'',' /var/www/nextcloud/config/config.php + + # 4 Byte UTF8 support + sudo -u www-data php occ config:system:set mysql.utf8mb4 --type boolean --value="true" + + # Default trusted domain ( only from nextcloudpi-config ) + test -f /usr/local/bin/nextcloud-domain.sh && bash /usr/local/bin/nextcloud-domain.sh + + systemctl start apache2; +} + +install(){ :; } +cleanup() { :; } + +# License +# +# This script is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This script is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this script; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place, Suite 330, +# Boston, MA 02111-1307 USA diff --git a/etc/nextcloudpi-config.d/nc-nextcloud.sh b/etc/nextcloudpi-config.d/nc-nextcloud.sh index 6152759c..59d4a7ff 100644 --- a/etc/nextcloudpi-config.d/nc-nextcloud.sh +++ b/etc/nextcloudpi-config.d/nc-nextcloud.sh @@ -19,6 +19,8 @@ VER_=12.0.0 MAXFILESIZE_=2G MEMORYLIMIT_=768M MAXTRANSFERTIME_=3600 +DBADMIN_=ncadmin +DBPASSWD_=ownyourbits DESCRIPTION="Install any NextCloud version" export DEBIAN_FRONTEND=noninteractive @@ -32,6 +34,8 @@ show_info() "This new installation will cleanup current NextCloud instance, including files and database. +You can later use nc-init to configure to NextCloudPi defaults + ** perform backup before proceding ** You can use nc-backup " \ @@ -42,10 +46,38 @@ install() { :; } configure() { + systemctl stop apache2; + + ## RE-CREATE DATABASE TABLE + + # wait for mariadb + while :; do + [[ -S /var/run/mysqld/mysqld.sock ]] && break + sleep 0.5 + done + + echo "Setting up database..." + # workaround to emulate DROP USER IF EXISTS ..;) + mysql -u root -p$DBPASSWD_ < /etc/apache2/sites-available/nextcloud.conf <<'EOF' + + + DocumentRoot /var/www/nextcloud + CustomLog /var/www/nextcloud/data/access.log combined + ErrorLog /var/www/nextcloud/data/error.log + SSLEngine on + SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem + SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key + + + Options +FollowSymlinks + AllowOverride All + + Dav off + + LimitRequestBody 0 + SSLRenegBufferSize 10486000 + + +EOF + a2ensite nextcloud + echo "Setting up Apache..." + cat > /etc/apache2/sites-available/000-default.conf <<'EOF' DocumentRoot /var/www/nextcloud @@ -96,6 +158,8 @@ cat > /etc/apache2/sites-available/000-default.conf <<'EOF' EOF + echo "Setting up system..." + ## SET LIMITS sed -i "s/post_max_size=.*/post_max_size=$MAXFILESIZE_/" /var/www/nextcloud/.user.ini sed -i "s/upload_max_filesize=.*/upload_max_filesize=$MAXFILESIZE_/" /var/www/nextcloud/.user.ini @@ -109,6 +173,10 @@ EOF echo "*/15 * * * * php -f /var/www/nextcloud/cron.php" > /tmp/crontab_http crontab -u www-data /tmp/crontab_http rm /tmp/crontab_http + + systemctl start apache2; + + echo "Don't forget to run nc-init" } cleanup() diff --git a/lamp.sh b/lamp.sh index e2aeec2f..9a39005e 100644 --- a/lamp.sh +++ b/lamp.sh @@ -21,7 +21,6 @@ # DBPASSWD_=ownyourbits -OPCACHEDIR=/var/www/nextcloud/data/.opcache APTINSTALL="apt-get install -y --no-install-recommends" export DEBIAN_FRONTEND=noninteractive @@ -96,16 +95,14 @@ EOF zend_extension=opcache.so opcache.enable=1 opcache.enable_cli=1 -opcache.file_cache=$OPCACHEDIR; opcache.fast_shutdown=1 opcache.interned_strings_buffer=8 opcache.max_accelerated_files=10000 opcache.memory_consumption=128 opcache.save_comments=1 opcache.revalidate_freq=1 +opcache.file_cache=/tmp; EOF - mkdir -p $OPCACHEDIR - chown -R www-data:www-data $OPCACHEDIR a2enmod http2 a2enconf http2 @@ -127,29 +124,6 @@ EOF sed -i '/\[mysqld\]/ainnodb_large_prefix=on' /etc/mysql/mariadb.conf.d/50-server.cnf sed -i '/\[mysqld\]/ainnodb_file_per_table=1' /etc/mysql/mariadb.conf.d/50-server.cnf sed -i '/\[mysqld\]/ainnodb_file_format=barracuda' /etc/mysql/mariadb.conf.d/50-server.cnf - - cat > /etc/apache2/sites-available/nextcloud.conf <<'EOF' - - - DocumentRoot /var/www/nextcloud - CustomLog /var/www/nextcloud/data/access.log combined - ErrorLog /var/www/nextcloud/data/error.log - SSLEngine on - SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem - SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key - - - Options +FollowSymlinks - AllowOverride All - - Dav off - - LimitRequestBody 0 - SSLRenegBufferSize 10486000 - - -EOF - a2ensite nextcloud } configure() { :; } diff --git a/test-devel.sh b/test-devel.sh index a844a8f6..090c34da 100644 --- a/test-devel.sh +++ b/test-devel.sh @@ -20,7 +20,7 @@ install() { echo -e "Downloading updates" rm -rf /tmp/ncp-update-tmp - git clone -q --depth 1 -b devel https://github.com/nextcloud/nextcloudpi.git /tmp/ncp-update-tmp + git clone -q -b devel https://github.com/nextcloud/nextcloudpi.git /tmp/ncp-update-tmp cd /tmp/ncp-update-tmp echo -e "Performing updates" -- cgit v1.2.3