From c33cabc537f07ebdcecea561287d02aae51388f5 Mon Sep 17 00:00:00 2001 From: nachoparker Date: Wed, 14 Jun 2017 18:18:58 +0200 Subject: [PATCH] nc-init as a nextcloudpi-config option --- batch.sh | 2 +- docker/nextcloud.dockerfile | 2 +- docker/run-nc.sh | 2 +- etc/{ => nextcloudpi-config.d}/nc-init.sh | 29 ++++++++- etc/nextcloudpi-config.d/nc-nextcloud.sh | 72 ++++++++++++++++++++++- lamp.sh | 28 +-------- test-devel.sh | 2 +- 7 files changed, 101 insertions(+), 36 deletions(-) rename etc/{ => nextcloudpi-config.d}/nc-init.sh (78%) diff --git a/batch.sh b/batch.sh index fab79d713..6873deaca 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 7ab5672d1..1d24d6b9e 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 f07e72b37..e697b64c8 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/nextcloudpi-config.d/nc-init.sh similarity index 78% rename from etc/nc-init.sh rename to etc/nextcloudpi-config.d/nc-init.sh index df44b1888..e35b33675 100644 --- a/etc/nc-init.sh +++ b/etc/nextcloudpi-config.d/nc-init.sh @@ -18,10 +18,26 @@ ADMINUSER_=admin DBADMIN_=ncadmin DBPASSWD_=ownyourbits +DESCRIPTION="(Re)initiate Nextcloud to a clean configuration" -install() +show_info() { - ## RE-CREATE DATABASE TABLE (workaround to emulate DROP USER IF EXISTS ..;) + 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..." @@ -31,6 +47,7 @@ install() sleep 0.5 done + # 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 e2aeec2f4..9a39005e1 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 a844a8f6d..090c34da3 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"