diff --git a/batch.sh b/batch.sh index ed5283e79..4048a02d4 100755 --- a/batch.sh +++ b/batch.sh @@ -12,15 +12,16 @@ source etc/library.sh # initializes $IMGNAME IP=$1 # First argument is the QEMU Raspbian IP address +NC_SCRIPT=etc/nextcloudpi-config.d/nc-nextcloud.sh IMGBASE="NextCloudPi_$( date "+%m-%d-%y" )_base.img" NO_CONFIG=1 NO_HALT_STEP=1 ./install-nextcloud.sh $IP $IMGBASE +NO_CONFIG=1 ./installer.sh $NC_SCRIPT $IP $( ls -1t *.img | head -1 ) NO_CONFIG=1 ./installer.sh nextcloudpi.sh $IP $( ls -1t *.img | head -1 ) -NO_CONFIG=1 ./installer.sh nextcloud.sh $IP $( ls -1t *.img | head -1 ) IMGFILE=$( ls -1t *.img | head -1 ) -IMGOUT=$( basename "$IMGFILE" _base ).img +IMGOUT=$( basename "$IMGFILE" _base_nc-nextcloud_nextcloudpi.img ).img pack_image "$IMGFILE" "$IMGOUT" md5sum $( ls -1t *.img | head -1 ) diff --git a/etc/nextcloudpi-config.d/NFS.sh b/etc/nextcloudpi-config.d/NFS.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/dnsmasq.sh b/etc/nextcloudpi-config.d/dnsmasq.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/fail2ban.sh b/etc/nextcloudpi-config.d/fail2ban.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/letsencrypt.sh b/etc/nextcloudpi-config.d/letsencrypt.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/modsecurity.sh b/etc/nextcloudpi-config.d/modsecurity.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/nc-database.sh b/etc/nextcloudpi-config.d/nc-database.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/nc-datadir.sh b/etc/nextcloudpi-config.d/nc-datadir.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/nc-httpsonly.sh b/etc/nextcloudpi-config.d/nc-httpsonly.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/nc-limits.sh b/etc/nextcloudpi-config.d/nc-limits.sh old mode 100755 new mode 100644 diff --git a/nextcloud.sh b/etc/nextcloudpi-config.d/nc-nextcloud.sh similarity index 70% rename from nextcloud.sh rename to etc/nextcloudpi-config.d/nc-nextcloud.sh index e9228312a..9524f981e 100755 --- a/nextcloud.sh +++ b/etc/nextcloudpi-config.d/nc-nextcloud.sh @@ -8,32 +8,68 @@ # # Usage: # -# ./installer.sh nextcloud.sh () +# ./installer.sh nc-nextcloud () # # See installer.sh instructions for details # # More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/ # -VER=11.0.3 +VER_=11.0.3 ADMINUSER_=admin DBADMIN_=ncadmin DBPASSWD_=ownyourbits MAXFILESIZE_=768M MAXTRANSFERTIME_=3600 OPCACHEDIR=/var/www/nextcloud/data/.opcache +DESCRIPTION="Install any NextCloud version" -install() +show_info() { + [ -d /var/www/nextcloud ] && \ + whiptail --yesno \ + --backtitle "NextCloudPi configuration" \ + --title "NextCloud installation" \ +"This new installation will cleanup current +NextCloud instance, including files and database. + +** perform backup before proceding ** + +You can use nc-backup " \ + 20 90 +} + +install() { :; } + +configure() +{ + service apache2 stop + + # RE-CREATE DATABASE TABLE (workaround to emulate DROP USER IF EXISTS ..;) + sleep 40 # TODO wait for mysql to be up + mysql -u root -p$DBPASSWD_ < /etc/apache2/sites-available/000-default.conf <<'EOF' DocumentRoot /var/www/nextcloud @@ -77,32 +114,6 @@ cat > /etc/apache2/sites-available/000-default.conf <<'EOF' EOF - mkdir -p /usr/lib/systemd/system - cat > /usr/lib/systemd/system/nextcloud-domain.service <<'EOF' -[Unit] -Description=Register Current IP as Nextcloud trusted domain -Requires=network.target -After=mysql.service - -[Service] -ExecStart=/bin/bash /usr/local/bin/nextcloud-domain.sh - -[Install] -WantedBy=multi-user.target -EOF - systemctl enable nextcloud-domain - - cat > /usr/local/bin/nextcloud-domain.sh <<'EOF' -#!/bin/bash -IFACE=$( ip r | grep "default via" | awk '{ print $5 }' ) -IP=$( ip a | grep "global $IFACE" | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 ) -cd /var/www/nextcloud -sudo -u www-data php occ config:system:set trusted_domains 1 --value=$IP -EOF -} - -configure() -{ cd /var/www/nextcloud/ sudo -u www-data php occ maintenance:install --database \ @@ -123,14 +134,18 @@ configure() echo "*/15 * * * * php -f /var/www/nextcloud/cron.php" > /tmp/crontab_http crontab -u www-data /tmp/crontab_http rm /tmp/crontab_http + + # Initial Trusted Domain + local IFACE=$( ip r | grep "default via" | awk '{ print $5 }' ) + local IP=$( ip a | grep "global $IFACE" | grep -oP '\d{1,3}(.\d{1,3}){3}' | head -1 ) + sudo -u www-data php occ config:system:set trusted_domains 1 --value=$IP + cd - + + service apache2 start } cleanup() { - [ "$STATE" != "1" ] && return - apt-get autoremove - apt-get clean - rm /var/lib/apt/lists/* -r rm -f /home/pi/.bash_history systemctl disable ssh diff --git a/etc/nextcloudpi-config.d/nc-ramlogs.sh b/etc/nextcloudpi-config.d/nc-ramlogs.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/nc-scan-auto.sh b/etc/nextcloudpi-config.d/nc-scan-auto.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/nc-scan.sh b/etc/nextcloudpi-config.d/nc-scan.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/nc-swapfile.sh b/etc/nextcloudpi-config.d/nc-swapfile.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/nc-update.sh b/etc/nextcloudpi-config.d/nc-update.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/nc-wifi.sh b/etc/nextcloudpi-config.d/nc-wifi.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/no-ip.sh b/etc/nextcloudpi-config.d/no-ip.sh old mode 100755 new mode 100644 diff --git a/etc/nextcloudpi-config.d/unattended-upgrades.sh b/etc/nextcloudpi-config.d/unattended-upgrades.sh old mode 100755 new mode 100644 diff --git a/nextcloudpi.sh b/nextcloudpi.sh index 1d364120c..9ce623f87 100644 --- a/nextcloudpi.sh +++ b/nextcloudpi.sh @@ -121,7 +121,6 @@ configure() { :; } cleanup() { - [ "$STATE" != "1" ] && return apt-get autoremove apt-get clean rm /var/lib/apt/lists/* -r