diff options
-rwxr-xr-x | batch.sh | 2 | ||||
-rw-r--r-- | docker/nextcloud.dockerfile | 2 | ||||
-rwxr-xr-x | docker/run-nc.sh | 2 | ||||
-rw-r--r-- | etc/nextcloudpi-config.d/nc-init.sh (renamed from etc/nc-init.sh) | 29 | ||||
-rw-r--r-- | etc/nextcloudpi-config.d/nc-nextcloud.sh | 72 | ||||
-rw-r--r-- | lamp.sh | 28 | ||||
-rw-r--r-- | test-devel.sh | 2 |
7 files changed, 101 insertions, 36 deletions
@@ -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 <nacho@ownyourbits.com> 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/nextcloudpi-config.d/nc-init.sh index df44b188..e35b3367 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_ <<EOF DROP DATABASE IF EXISTS nextcloud; CREATE DATABASE nextcloud @@ -48,6 +65,7 @@ EOF echo "Setting up Nextcloud..." cd /var/www/nextcloud/ + rm -f config/config.php sudo -u www-data php occ maintenance:install --database \ "mysql" --database-name "nextcloud" --database-user "$DBADMIN_" --database-pass \ "$DBPASSWD_" --admin-user "$ADMINUSER_" --admin-pass "$DBPASSWD_" @@ -60,9 +78,14 @@ EOF # 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; } -configure(){ :; } +install(){ :; } cleanup() { :; } # License 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_ <<EOF +DROP DATABASE IF EXISTS nextcloud; +CREATE DATABASE nextcloud + CHARACTER SET utf8mb4 + COLLATE utf8mb4_unicode_ci; +GRANT USAGE ON *.* TO '$DBADMIN_'@'localhost' IDENTIFIED BY '$DBPASSWD_'; +DROP USER '$DBADMIN_'@'localhost'; +CREATE USER '$DBADMIN_'@'localhost' IDENTIFIED BY '$DBPASSWD_'; +GRANT ALL PRIVILEGES ON nextcloud.* TO $DBADMIN_@localhost; +EXIT +EOF + ## DOWNLOAD AND (OVER)WRITE NEXTCLOUD cd /var/www/ - wget -q https://download.nextcloud.com/server/releases/nextcloud-$VER_.tar.bz2 -O nextcloud.tar.bz2 + + echo "Downloading Nextcloud $VER_..." + wget -q https://download.nextcloud.com/server/releases/nextcloud-$VER_.tar.bz2 -O nextcloud.tar.bz2 || return 1 rm -rf nextcloud + + echo "Installing Nextcloud $VER_..." tar -xf nextcloud.tar.bz2 rm nextcloud.tar.bz2 @@ -84,7 +116,37 @@ configure() chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess fi - ## CONFIGURE NEXTCLOUD + # create and configure opcache dir + OPCACHEDIR=/var/www/nextcloud/data/.opcache + sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$OPCACHEDIR|" /etc/php/7.0/mods-available/opcache.ini + mkdir -p $OPCACHEDIR + chown -R www-data:www-data $OPCACHEDIR + + ## SET APACHE VHOST + cat > /etc/apache2/sites-available/nextcloud.conf <<'EOF' +<IfModule mod_ssl.c> + <VirtualHost _default_:443> + 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 + </VirtualHost> + <Directory /var/www/nextcloud/> + Options +FollowSymlinks + AllowOverride All + <IfModule mod_dav.c> + Dav off + </IfModule> + LimitRequestBody 0 + SSLRenegBufferSize 10486000 + </Directory> +</IfModule> +EOF + a2ensite nextcloud + echo "Setting up Apache..." + cat > /etc/apache2/sites-available/000-default.conf <<'EOF' <VirtualHost _default_:80> DocumentRoot /var/www/nextcloud @@ -96,6 +158,8 @@ cat > /etc/apache2/sites-available/000-default.conf <<'EOF' </VirtualHost> 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() @@ -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' -<IfModule mod_ssl.c> - <VirtualHost _default_:443> - 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 - </VirtualHost> - <Directory /var/www/nextcloud/> - Options +FollowSymlinks - AllowOverride All - <IfModule mod_dav.c> - Dav off - </IfModule> - LimitRequestBody 0 - SSLRenegBufferSize 10486000 - </Directory> -</IfModule> -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" |