Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/nextcloudpi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornachoparker <nacho@ownyourbits.com>2018-05-24 20:28:28 +0300
committernachoparker <nacho@ownyourbits.com>2018-05-27 21:32:36 +0300
commit06c07d33ee3a3154e41a3d7eca4fd778e0400267 (patch)
treeaa923b3a214711b57cc92d28a561c7a3cf17c1d3
parent027a2a02bddfad3152d00de6b2134a9d8b21edbf (diff)
Rework raspbian build system
-rw-r--r--.dockerignore4
-rw-r--r--.gitignore7
-rw-r--r--README.md2
-rw-r--r--armbian.sh21
-rw-r--r--build-SD-odroid.sh11
-rwxr-xr-xbuild-SD.sh86
-rwxr-xr-xbuild-raspi.sh108
-rw-r--r--buildlib.sh267
-rw-r--r--docker-armhf/nextcloud/Dockerfile5
-rw-r--r--docker-armhf/nextcloudplus/Dockerfile15
-rw-r--r--docker/nextcloud/Dockerfile5
-rw-r--r--docker/nextcloudplus/Dockerfile15
-rw-r--r--etc/ncp-config.d/NFS.sh5
-rw-r--r--etc/ncp-config.d/SSH.sh2
-rw-r--r--etc/ncp-config.d/UFW.sh6
-rw-r--r--etc/ncp-config.d/dnsmasq.sh5
-rw-r--r--etc/ncp-config.d/fail2ban.sh5
-rw-r--r--etc/ncp-config.d/freeDNS.sh8
-rw-r--r--etc/ncp-config.d/letsencrypt.sh6
-rw-r--r--etc/ncp-config.d/modsecurity.sh6
-rw-r--r--etc/ncp-config.d/nc-admin.sh5
-rw-r--r--etc/ncp-config.d/nc-audit.sh6
-rw-r--r--etc/ncp-config.d/nc-automount.sh6
-rw-r--r--etc/ncp-config.d/nc-autoupdate-nc.sh5
-rw-r--r--etc/ncp-config.d/nc-autoupdate-ncp.sh5
-rw-r--r--etc/ncp-config.d/nc-backup-auto.sh6
-rw-r--r--etc/ncp-config.d/nc-backup.sh6
-rw-r--r--etc/ncp-config.d/nc-database.sh6
-rw-r--r--etc/ncp-config.d/nc-datadir.sh6
-rw-r--r--etc/ncp-config.d/nc-fix-permissions.sh5
-rw-r--r--etc/ncp-config.d/nc-format-USB.sh5
-rw-r--r--etc/ncp-config.d/nc-forward-ports.sh5
-rw-r--r--etc/ncp-config.d/nc-httpsonly.sh6
-rw-r--r--etc/ncp-config.d/nc-info.sh5
-rw-r--r--etc/ncp-config.d/nc-init.sh6
-rw-r--r--etc/ncp-config.d/nc-limits.sh6
-rw-r--r--etc/ncp-config.d/nc-nextcloud.sh10
-rw-r--r--etc/ncp-config.d/nc-notify-updates.sh5
-rw-r--r--etc/ncp-config.d/nc-passwd.sh5
-rw-r--r--etc/ncp-config.d/nc-ramlogs.sh6
-rw-r--r--etc/ncp-config.d/nc-restore.sh6
-rw-r--r--etc/ncp-config.d/nc-rsync-auto.sh6
-rw-r--r--etc/ncp-config.d/nc-rsync.sh6
-rw-r--r--etc/ncp-config.d/nc-scan-auto.sh5
-rw-r--r--etc/ncp-config.d/nc-scan.sh5
-rw-r--r--etc/ncp-config.d/nc-snapshot-auto.sh6
-rw-r--r--etc/ncp-config.d/nc-snapshot-sync.sh6
-rw-r--r--etc/ncp-config.d/nc-snapshot.sh6
-rw-r--r--etc/ncp-config.d/nc-static-IP.sh5
-rw-r--r--etc/ncp-config.d/nc-swapfile.sh6
-rw-r--r--etc/ncp-config.d/nc-update-nextcloud.sh6
-rw-r--r--etc/ncp-config.d/nc-update.sh6
-rw-r--r--etc/ncp-config.d/nc-webui.sh5
-rw-r--r--etc/ncp-config.d/nc-wifi.sh6
-rw-r--r--etc/ncp-config.d/nc-zram.sh6
-rw-r--r--etc/ncp-config.d/no-ip.sh6
-rw-r--r--etc/ncp-config.d/samba.sh5
-rw-r--r--etc/ncp-config.d/unattended-upgrades.sh5
-rw-r--r--install.sh8
-rwxr-xr-xinstaller.sh9
-rw-r--r--ncp.sh (renamed from nextcloudplus.sh)16
-rw-r--r--post-inst.sh53
-rw-r--r--prepare.sh73
-rw-r--r--raspbian-cleanup.sh98
64 files changed, 398 insertions, 665 deletions
diff --git a/.dockerignore b/.dockerignore
index 23760651..51aa7c5e 100644
--- a/.dockerignore
+++ b/.dockerignore
@@ -1,5 +1,7 @@
torrent/
-partial/
+tmp/
+cache/
+output/
qemu-raspbian-network/
armbian/
*.img
diff --git a/.gitignore b/.gitignore
index 981ff30f..0d444d35 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,10 @@
.*.swp
-*.img
-*.bz2
.idea/
qemu-raspbian-network/
+output/
+cache/
torrent/
armbian/
+raspbian_root
+raspbian_boot
+docker-armhf/raspbian_docker.img
diff --git a/README.md b/README.md
index 86d6fe72..d51eb7f9 100644
--- a/README.md
+++ b/README.md
@@ -63,8 +63,6 @@ This code also generates the [NextCloudPi docker images](https://hub.docker.com/
* Security audits with Lynis and Debsecan ( NEW 07-02-2018 )
* ZRAM ( NEW 19-03-2018 )
-Any extra can be installed independently in a running Raspbian instance through SSH. See `installer.sh`
-
Extras can be activated and configured using the web interface at HTTPS port 4443
diff --git a/armbian.sh b/armbian.sh
index ca259fad..2efdf80b 100644
--- a/armbian.sh
+++ b/armbian.sh
@@ -2,7 +2,7 @@
# arguments: $RELEASE $LINUXFAMILY $BOARD $BUILD_DESKTOP
-# This is the image customization script for NextCloudPlus on Armbian
+# This is the image customization script for NextCloudPi on Armbian
#
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
@@ -27,28 +27,9 @@ touch /.ncp-image
# install NCP
curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | bash
-# permit root login in SSH
-sed -i 's|^PermitRootLogin .*|PermitRootLogin yes|' /etc/ssh/sshd_config
-
# force change root password at first login (again)
chage -d 0 root
-# cleanup
-apt-get autoremove -y
-apt-get clean
-rm /var/lib/apt/lists/* -r
-rm /.ncp-image
-
-# cleanup all NCP options
-source /usr/local/etc/library.sh
-cd /usr/local/etc/ncp-config.d/
-for script in *.sh; do
- cleanup_script $script
-done
-
-# enable randomize passwords
-systemctl enable nc-provisioning
-
# License
#
diff --git a/build-SD-odroid.sh b/build-SD-odroid.sh
index f8358d76..5956b167 100644
--- a/build-SD-odroid.sh
+++ b/build-SD-odroid.sh
@@ -8,6 +8,8 @@
# Usage: ./build-SD-odroid.sh <DHCP QEMU image IP>
#
+IMG="NextCloudPi_OdroidHC2_$( date "+%m-%d-%y" ).img"
+
set -e
# get armbian
@@ -31,13 +33,12 @@ armbian/compile.sh docker \
NO_APT_CACHER=no
# pack image
-IMGNAME="NextCloudPlus_OdroidHC2_$( date "+%m-%d-%y" )"
-IMGFILE="$( ls -1t armbian/output/images/*.img | head -1 )"
-pack_image "$IMGFILE" "$IMGNAME.img"
+TAR=output/"$( basename "$IMG" .img ).tar.bz2"
+pack_image "$IMG" "$TAR"
# testing
# TODO
# uploading
-create_torrent "${IMGNAME}.tar.bz2"
-upload_ftp "$IMGNAME" || true
+create_torrent "$TAR"
+upload_ftp "$( basename "$TAR" .tar.bz2 )"
diff --git a/build-SD.sh b/build-SD.sh
deleted file mode 100755
index b1671e18..00000000
--- a/build-SD.sh
+++ /dev/null
@@ -1,86 +0,0 @@
-#!/bin/bash
-
-# Batch creation of NextCloudPlus image
-#
-# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
-# GPL licensed (see end of file) * Use at your own risk!
-#
-# Usage: ./batch.sh <DHCP QEMU image IP>
-#
-
-set -e
-source buildlib.sh # initializes $IMGNAME
-
-IP=$1 # First argument is the QEMU Raspbian IP address
-
-
-[[ "$FTPPASS" == "" ]] && {
- echo -e "\e[1mNo FTPPASS variable found, FTP won't work.\nYou probably want to cancel now\e[0m"
- sleep 5
-}
-
-## BUILDING
-
-NC_INSTALL=etc/ncp-config.d/nc-nextcloud.sh
-NC_CONFIG=etc/ncp-config.d/nc-init.sh
-
-IMGBASE="NextCloudPlus_RPi_$( date "+%m-%d-%y" )_base.img"
-
-export NO_CONFIG=1 # skip interactive configuration
-
-## BUILD
-
-download_resize_raspbian_img 1G "$IMGBASE"
-
-NO_HALT_STEP=1 ./installer.sh prepare.sh "$IP" "$IMGBASE"
- ./installer.sh lamp.sh "$IP" "$( ls -1t *.img | head -1 )"
- ./installer.sh $NC_INSTALL "$IP" "$( ls -1t *.img | head -1 )"
- ./installer.sh nextcloudplus.sh "$IP" "$( ls -1t *.img | head -1 )"
- ./installer.sh $NC_CONFIG "$IP" "$( ls -1t *.img | head -1 )"
- ./installer.sh raspbian-cleanup.sh "$IP" "$( ls -1t *.img | head -1 )"
-
-## PACKING
-
-IMGFILE=$( ls -1t *.img | head -1 )
-IMGNAME=$( basename "$IMGFILE" _base_prepare_lamp_nc-nextcloud_nextcloudplus_nc-init_raspbian-cleanup.img )
-
-[[ "$IMGNAME" != "" ]] || exit 1
-
-pack_image "$IMGFILE" "$IMGNAME.img"
-
-## TESTING
-
-launch_qemu "$IMGNAME.img" &
-sleep 10
-wait_SSH "$IP"
-sleep 180 # Wait for the services to start. Improve this ( wait HTTP && trusted domains )
-tests/tests.py "$IP"
-
-ssh_pi "$IP" sudo halt
-
-## UPLOADING
-
-create_torrent "${IMGNAME}.tar.bz2"
-upload_ftp "$IMGNAME" || true
-
-## CLEANUP
-
-mkdir -p partial && mv NextCloudPlus*.bz2 partial
-rm -f *.img
-
-# 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/build-raspi.sh b/build-raspi.sh
new file mode 100755
index 00000000..9fb0155a
--- /dev/null
+++ b/build-raspi.sh
@@ -0,0 +1,108 @@
+#!/bin/bash
+
+# Batch creation of NextCloudPi image
+#
+# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
+# GPL licensed (see end of file) * Use at your own risk!
+#
+# Usage: ./batch.sh <DHCP QEMU image IP>
+#
+
+set -e
+source buildlib.sh
+
+IP=192.168.0.145 # For QEMU automated testing
+SIZE=3G # Raspbian image size
+#CLEAN=1 # Pass this envvar to clean download cache
+IMG="NextCloudPi_RPi_$( date "+%m-%d-%y" ).img"
+
+##############################################################################
+
+## preparations
+
+[[ "$FTPPASS" == "" ]] && {
+ echo -e "\e[1mNo FTPPASS variable found, FTP won't work.\nYou can to cancel now\e[0m"
+ sleep 5
+}
+
+[[ "$CLEAN" != "" ]] && rm -rf cache
+rm -rf tmp && mkdir tmp
+IMG=tmp/"$IMG"
+
+download_raspbian "$IMG"
+resize_image "$IMG" "$SIZE"
+update_boot_uuid "$IMG" # PARTUUID has changed after resize
+
+## BUILD NCP
+
+prepare_chroot_raspbian "$IMG"
+
+mkdir raspbian_root/tmp/ncp-build
+cp etc/library.sh lamp.sh etc/ncp-config.d/{nc-nextcloud.sh,nc-init.sh} ncp.sh post-inst.sh raspbian_root/tmp/ncp-build
+
+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
+ sudo chroot raspbian_root /bin/bash <<'EOFCHROOT'
+ # mark the image as an image build
+ touch /.ncp-image
+
+ # update packages
+ apt-get update
+ apt-get upgrade -y
+ apt-get dist-upgrade -y
+
+ # As of 03-2018, you dont get a big kernel update by doing
+ # this, so better be safe. Might uncomment again in the future
+ #$APTINSTALL rpi-update
+ #echo -e "y\n" | PRUNE_MODULES=1 rpi-update
+
+ # install everything
+ cd /tmp/ncp-build || exit 1
+ source library.sh
+ install_script lamp.sh
+ install_script nc-nextcloud.sh
+ activate_script nc-nextcloud.sh
+ install_script ncp.sh
+ activate_script nc-init.sh
+ activate_script post-inst.sh
+
+ # harden SSH further for Raspbian
+ sed -i 's|^#PermitRootLogin .*|PermitRootLogin no|' /etc/ssh/sshd_config
+
+ rm -rf /tmp/ncp-build
+EOFCHROOT
+
+clean_chroot_raspbian
+
+## pack
+
+mkdir -p output
+TAR=output/"$( basename "$IMG" .img ).tar.bz2"
+pack_image "$IMG" "$TAR"
+
+## test
+
+set_static_IP "$IMG" "$IP"
+test_image "$IMG" "$IP"
+rm -r tmp
+
+# upload
+create_torrent "$TAR"
+upload_ftp "$( basename "$TAR" .tar.bz2 )"
+
+
+# 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/buildlib.sh b/buildlib.sh
index a7c720f8..356455b1 100644
--- a/buildlib.sh
+++ b/buildlib.sh
@@ -8,36 +8,27 @@
# More at ownyourbits.com
#
-IMGNAME=$( basename "$IMGFILE" .img )_$( basename "$INSTALL_SCRIPT" .sh ).img
DBG=x
-# $IMGOUT will contain the name of the last step
+# $IMG is the source image
+# $IP is the IP of the QEMU images
+# $IMGOUT will contain the name of the generated image
function launch_install_qemu()
{
local IMG=$1
local IP=$2
- [[ "$IP" == "" ]] && { echo "usage: launch_install_qemu <script> <img> <IP>"; return 1; }
- test -f "$IMG" || { echo "input file $IMG not found"; return 1; }
-
- local BASE=$( sed 's=-stage[[:digit:]]==' <<< "$IMG" )
- local NUM=$( sed 's=.*-stage\([[:digit:]]\)=\1=' <<< "$IMG" )
- [[ "$BASE" == "$IMG" ]] && NUM=0
-
- local NUM_REBOOTS=$( grep -c "nohup reboot" "$INSTALL_SCRIPT" )
- while [[ $NUM_REBOOTS != -1 ]]; do
- NUM=$(( NUM+1 ))
- IMGOUT="$BASE-stage$NUM"
- cp --reflink=auto -v "$IMG" "$IMGOUT" || return 1 # take a copy of the input image for processing ( append "-stage1" )
-
- pgrep qemu-system-arm &>/dev/null && { echo -e "QEMU instance already running. Abort..."; return 1; }
- launch_qemu "$IMGOUT" &
- sleep 10
- wait_SSH "$IP"
- launch_installation_qemu "$IP" || return 1
- wait
- IMG="$IMGOUT"
- NUM_REBOOTS=$(( NUM_REBOOTS-1 ))
- done
+ [[ "$IP" == "" ]] && { echo "usage: launch_install_qemu <img> <IP>"; return 1; }
+ test -f "$IMG" || { echo "input file $IMG not found"; return 1; }
+
+ IMGOUT="$IMG-$( date +%s )"
+ cp --reflink=auto -v "$IMG" "$IMGOUT" || return 1
+
+ pgrep qemu-system-arm &>/dev/null && { echo -e "QEMU instance already running. Abort..."; return 1; }
+ launch_qemu "$IMGOUT" &
+ sleep 10
+ wait_SSH "$IP"
+ launch_installation_qemu "$IP" || return 1 # uses $INSTALLATION_CODE
+ wait
echo "$IMGOUT generated successfully"
}
@@ -111,7 +102,7 @@ $CFG_STEP
$CLEANUP_STEP
$HALT_STEP
"
- launch_installation "$IP"
+ launch_installation "$IP" # uses $INSTALLATION_CODE
}
function launch_installation_online()
@@ -122,7 +113,121 @@ function launch_installation_online()
install
$CFG_STEP
"
- launch_installation "$IP"
+ launch_installation "$IP" # uses $INSTALLATION_CODE
+}
+
+function mount_raspbian()
+{
+ local IMG="$1"
+ local MP=raspbian_root
+
+ [[ -f "$IMG" ]] || { echo "no image"; return 1; }
+ [[ -e "$MP" ]] && { echo "$MP already exists"; return 1; }
+
+ local SECTOR=$( fdisk -l "$IMG" | grep Linux | awk '{ print $2 }' )
+ local OFFSET=$(( SECTOR * 512 ))
+ mkdir -p "$MP"
+ sudo mount $IMG -o offset=$OFFSET "$MP" || return 1
+ echo "Raspbian image mounted"
+}
+
+function mount_raspbian_boot()
+{
+ local IMG="$1"
+ local MP=raspbian_boot
+
+ [[ -f "$IMG" ]] || { echo "no image"; return 1; }
+ [[ -e "$MP" ]] && { echo "$MP already exists"; return 1; }
+
+ local SECTOR=$( fdisk -l "$IMG" | grep FAT32 | awk '{ print $2 }' )
+ local OFFSET=$(( SECTOR * 512 ))
+ mkdir -p "$MP"
+ sudo mount $IMG -o offset=$OFFSET "$MP" || return 1
+ echo "Raspbian image mounted"
+}
+
+function umount_raspbian()
+{
+ [[ -d raspbian_root ]] || [[ -d raspbian_boot ]] || { echo "Nothing to umount"; return 0; }
+ [[ -d raspbian_root ]] && { sudo umount -l raspbian_root; rmdir raspbian_root || return 1; }
+ [[ -d raspbian_boot ]] && { sudo umount -l raspbian_boot; rmdir raspbian_boot || return 1; }
+ echo "Raspbian image umounted"
+}
+
+function prepare_chroot_raspbian()
+{
+ local IMG="$1"
+ mount_raspbian "$IMG" || return 1
+ sudo mount -t proc proc raspbian_root/proc/
+ sudo mount -t sysfs sys raspbian_root/sys/
+ sudo mount -o bind /dev raspbian_root/dev/
+ sudo mount -o bind /dev/pts raspbian_root/dev/pts
+ sudo cp /usr/bin/qemu-arm-static raspbian_root/usr/bin
+}
+
+function clean_chroot_raspbian()
+{
+ sudo rm -f raspbian_root/usr/bin/qemu-arm-static
+ sudo umount -l raspbian_root/{proc,sys,dev/pts,dev}
+ umount_raspbian
+}
+
+# sets DEV
+function resize_image()
+{
+ local IMG="$1"
+ local SIZE="$2"
+ local DEV
+ fallocate -l$SIZE "$IMG"
+ parted "$IMG" -- resizepart 2 -1s
+ DEV="$( losetup -f )"
+ mount_raspbian "$IMG"
+ sudo resize2fs -f "$DEV"
+ echo "image resized"
+ umount_raspbian
+}
+
+function update_boot_uuid()
+{
+ local IMG="$1"
+ local PTUUID="$( sudo blkid -o export "$IMG" | grep PTUUID | sed 's|.*=||' )"
+
+ mount_raspbian "$IMG" || return 1
+ sudo bash -c "cat > raspbian_root/etc/fstab" <<EOF
+PARTUUID=${PTUUID}-01 /boot vfat defaults 0 2
+PARTUUID=${PTUUID}-02 / ext4 defaults,noatime 0 1
+EOF
+ umount_raspbian
+
+ mount_raspbian_boot "$IMG"
+ sudo bash -c "sed -i 's|root=[^[:space:]]*|root=PARTUUID=${PTUUID}-02 |' raspbian_boot/cmdline.txt"
+ umount_raspbian
+}
+
+function prepare_sshd()
+{
+ local IMG="$1"
+ mount_raspbian_boot "$IMG" || return 1
+ sudo touch raspbian_boot/ssh # this enables ssh
+ umount_raspbian
+}
+
+function set_static_IP()
+{
+ local IMG="$1"
+ local IP="$2"
+ mount_raspbian "$IMG" || return 1
+ sudo bash -c "cat > raspbian_root/etc/dhcpcd.conf" <<EOF
+interface eth0
+static ip_address=$IP/24
+static routers=192.168.0.1
+static domain_name_servers=8.8.8.8
+
+# Local loopback
+auto lo
+iface lo inet loopback
+EOF
+ umount_raspbian
}
function copy_to_image()
@@ -130,74 +235,64 @@ function copy_to_image()
local IMG=$1
local DST=$2
local SRC=${@: 3 }
- local SECTOR
- local OFFSET
- SECTOR=$( fdisk -l "$IMG" | grep Linux | awk '{ print $2 }' )
- OFFSET=$(( SECTOR * 512 ))
-
- [ -f "$IMG" ] || { echo "no image"; return 1; }
- mkdir -p tmpmnt
- sudo mount "$IMG" -o offset="$OFFSET" tmpmnt || return 1
- sudo cp --reflink=auto -v "$SRC" tmpmnt/"$DST" || return 1
+
+ mount_raspbian "$IMG" || return 1
+ sudo cp --reflink=auto -v "$SRC" raspbian_root/"$DST" || return 1
sync
- sudo umount -l tmpmnt
- rmdir tmpmnt &>/dev/null
+ umount_raspbian
}
function deactivate_unattended_upgrades()
{
local IMG=$1
- local SECTOR
- local OFFSET
- SECTOR=$( fdisk -l "$IMG" | grep Linux | awk '{ print $2 }' )
- OFFSET=$(( SECTOR * 512 ))
-
- [ -f "$IMG" ] || { echo "no image"; return 1; }
- mkdir -p tmpmnt
- sudo mount "$IMG" -o offset="$OFFSET" tmpmnt || return 1
- sudo rm -f tmpmnt/etc/apt/apt.conf.d/20ncp-upgrades
- sudo umount -l tmpmnt
- rmdir tmpmnt &>/dev/null
+
+ mount_raspbian "$IMG" || return 1
+ sudo rm -f raspbian_root/etc/apt/apt.conf.d/20ncp-upgrades
+ umount_raspbian
}
-function download_resize_raspbian_img()
+function download_raspbian()
{
- local SIZE=$1
- local IMGFILE=$2
- local IMG=raspbian_lite_latest
+ local IMGFILE=$1
+ local IMG_CACHE=cache/raspbian_lite.img
+ local ZIP_CACHE=cache/raspbian_lite.zip
- test -f "$IMGFILE" && \
- echo -e "INFO: $IMGFILE already exists. Skipping download ..." && return 0
+ mkdir -p cache
+ test -f $IMG_CACHE && \
+ echo -e "INFO: $IMG_CACHE already exists. Skipping download ..." && \
+ cp -v --reflink=auto $IMG_CACHE "$IMGFILE" && \
+ return 0
- test -f $IMG.zip || \
- wget https://downloads.raspberrypi.org/$IMG -O $IMG.zip || return 1
+ test -f "$ZIP_CACHE" && {
+ echo -e "INFO: $ZIP_CACHE already exists. Skipping download ..."
+ } || {
+ wget https://downloads.raspberrypi.org/raspbian_lite_latest -O "$ZIP_CACHE" || return 1
+ }
- unzip -o $IMG.zip && \
- mv *-raspbian-*.img "$IMGFILE" && \
- qemu-img resize -f raw "$IMGFILE" +"$SIZE" && \
- return 0
+ unzip -o "$ZIP_CACHE" && \
+ mv *-raspbian-*.img $IMG_CACHE && \
+ cp -v --reflink=auto $IMG_CACHE "$IMGFILE"
}
function pack_image()
{
- local IMGOUT="$1"
- local IMGNAME="$2"
- local TARNAME=$( basename $IMGNAME .img ).tar.bz2
- echo "copying $IMGOUT → $IMGNAME"
- cp --reflink=auto "$IMGOUT" "$IMGNAME" || return 1
- echo "packing $IMGNAME → $TARNAME"
- tar -I pbzip2 -cvf "$TARNAME" "$IMGNAME" &>/dev/null && \
- echo -e "$TARNAME packed successfully"
+ local IMG="$1"
+ local TAR="$2"
+ local DIR="$( dirname "$IMG" )"
+ local IMG="$( basename "$IMG" )"
+ echo "packing $IMG → $TAR"
+ tar -I pbzip2 -C "$DIR" -cvf "$TAR" "$IMG" && \
+ echo -e "$TAR packed successfully"
}
function create_torrent()
{
- local IMG="$1"
- [[ -f "$IMG" ]] || { echo "image $IMG not found"; return 1; }
- local IMGNAME="$( basename "$IMG" .tar.bz2 )"
+ local TAR="$1"
+ [[ -f "$TAR" ]] || { echo "image $TAR not found"; return 1; }
+ local IMGNAME="$( basename "$TAR" .tar.bz2 )"
local DIR="torrent/$IMGNAME"
[[ -d "$DIR" ]] && { echo "dir $DIR already exists"; return 1; }
- mkdir -p torrent/"$IMGNAME" && cp --reflink=auto "$IMG" torrent/"$IMGNAME"
+ mkdir -p torrent/"$IMGNAME" && cp -v --reflink=auto "$TAR" torrent/"$IMGNAME"
md5sum "$DIR"/*.bz2 > "$DIR"/md5sum
createtorrent -a udp://tracker.opentrackr.org -p 1337 -c "NextCloudPlus. Nextcloud for Raspberry Pi image" "$DIR" "$DIR".torrent
}
@@ -211,22 +306,10 @@ function generate_changelog()
sed 's|* \[tag: |\n[|' > changelog.md
}
-function prepare_sshd()
-{
- local IMG="$1"
- local SECTOR1=$( fdisk -l $IMG | grep FAT32 | awk '{ print $2 }' )
- local OFFSET1=$(( SECTOR1 * 512 ))
- mkdir -p tmpmnt
- sudo mount $IMG -o offset=$OFFSET1 tmpmnt
- sudo touch tmpmnt/ssh # this enables ssh
- sudo umount tmpmnt
- rmdir tmpmnt
-}
-
function upload_ftp()
{
local IMGNAME="$1"
- [[ -f torrent/"$IMGNAME"/"$IMGNAME".tar.bz2 ]] || { echo "No image file found, abort"; return 1; }
+ [[ -f torrent/"$IMGNAME"/"$IMGNAME".tar.bz2 ]] || { echo "No image file found, abort"; return 1; }
[[ "$FTPPASS" == "" ]] && { echo "No FTPPASS variable found, abort"; return 1; }
cd torrent
@@ -253,6 +336,20 @@ EOF
cd -
}
+function test_image()
+{
+ local IMG="$1"
+ local IP="$2"
+ [[ -f "$IMG" ]] || { echo "No image file found, abort"; return 1; }
+ launch_qemu "$IMG" &
+ sleep 10
+ wait_SSH "$IP"
+ sleep 180 # Wait for the services to start. Improve this ( wait HTTP && trusted domains )
+ tests/tests.py "$IP"
+ ssh_pi "$IP" sudo halt
+ wait
+}
+
# License
#
# This script is free software; you can redistribute it and/or modify it
diff --git a/docker-armhf/nextcloud/Dockerfile b/docker-armhf/nextcloud/Dockerfile
index 1220909e..3002fbe7 100644
--- a/docker-armhf/nextcloud/Dockerfile
+++ b/docker-armhf/nextcloud/Dockerfile
@@ -32,10 +32,7 @@ rm -f /var/log/alternatives.log /var/log/apt/*; \
# specific cleanup
apt-get purge -y wget ca-certificates; \
-rm /nc-nextcloud.sh; \
-sed -i -E "s/^requirepass .*/requirepass default/" /etc/redis/redis.conf; \
-echo -e "[client]\npassword=default" > /root/.my.cnf; \
-chmod 600 /root/.my.cnf
+rm /nc-nextcloud.sh
COPY docker-common/nextcloud/020nextcloud /etc/services-enabled.d/
COPY bin/ncp-provisioning.sh /usr/local/bin/
diff --git a/docker-armhf/nextcloudplus/Dockerfile b/docker-armhf/nextcloudplus/Dockerfile
index 652e2ac7..01cc58d9 100644
--- a/docker-armhf/nextcloudplus/Dockerfile
+++ b/docker-armhf/nextcloudplus/Dockerfile
@@ -6,7 +6,7 @@ SHELL ["/bin/bash", "-c"]
ENV DOCKERBUILD 1
-COPY nextcloudplus.sh /usr/local/etc/
+COPY ncp.sh /usr/local/etc/
RUN \
@@ -19,17 +19,22 @@ touch /.docker-image; \
apt-get update; \
apt-get install --no-install-recommends -y wget ca-certificates; \
-# install nextcloudplus
+# install nextcloudpi
source /usr/local/etc/library.sh; \
set +x; \
cd /usr/local/etc/; \
-install_script nextcloudplus.sh; \
+install_script ncp.sh; \
+
+# stop mysqld and redis
+mysqladmin -u root shutdown; \
+kill $( cat /run/redis/redis-server.pid ); \
+kill $( cat /run/crond.pid ); \
# fix default paths
sed -i 's|/media/USBdrive|/data/backups|' ncp-config.d/nc-backup.sh; \
# specific cleanup
-rm /usr/local/etc/nextcloudplus.sh; \
+rm /usr/local/etc/ncp.sh; \
rm /.ncp-image; \
# remove wizard for now
@@ -76,7 +81,7 @@ rm -rf /usr/share/doc/*; \
rm -f /var/log/alternatives.log /var/log/apt/*; \
rm /var/cache/debconf/*-old;
-COPY docker-common/nextcloudplus/000ncp /etc/services-enabled.d/
+COPY docker-common/nextcloudpi/000ncp /etc/services-enabled.d/
# 4443 - ncp-web
EXPOSE 80 443 4443
diff --git a/docker/nextcloud/Dockerfile b/docker/nextcloud/Dockerfile
index 214bd74b..e91aa042 100644
--- a/docker/nextcloud/Dockerfile
+++ b/docker/nextcloud/Dockerfile
@@ -32,10 +32,7 @@ rm -f /var/log/alternatives.log /var/log/apt/*; \
# specific cleanup
apt-get purge -y wget ca-certificates; \
-rm /nc-nextcloud.sh; \
-sed -i -E "s/^requirepass .*/requirepass default/" /etc/redis/redis.conf; \
-echo -e "[client]\npassword=default" > /root/.my.cnf; \
-chmod 600 /root/.my.cnf
+rm /nc-nextcloud.sh
COPY docker-common/nextcloud/020nextcloud /etc/services-enabled.d/
COPY bin/ncp-provisioning.sh /usr/local/bin/
diff --git a/docker/nextcloudplus/Dockerfile b/docker/nextcloudplus/Dockerfile
index a75ef835..08dffc6f 100644
--- a/docker/nextcloudplus/Dockerfile
+++ b/docker/nextcloudplus/Dockerfile
@@ -6,7 +6,7 @@ SHELL ["/bin/bash", "-c"]
ENV DOCKERBUILD 1
-COPY nextcloudplus.sh /usr/local/etc/
+COPY ncp.sh /usr/local/etc/
RUN \
@@ -19,17 +19,22 @@ touch /.docker-image; \
apt-get update; \
apt-get install --no-install-recommends -y wget ca-certificates; \
-# install nextcloudplus
+# install nextcloudpi
source /usr/local/etc/library.sh; \
set +x; \
cd /usr/local/etc/; \
-install_script nextcloudplus.sh; \
+install_script ncp.sh; \
+
+# stop mysqld and redis
+mysqladmin -u root shutdown; \
+kill $( cat /run/redis/redis-server.pid ); \
+kill $( cat /run/crond.pid ); \
# fix default paths
sed -i 's|/media/USBdrive|/data/backups|' ncp-config.d/nc-backup.sh; \
# specific cleanup
-rm /usr/local/etc/nextcloudplus.sh; \
+rm /usr/local/etc/ncp.sh; \
rm /.ncp-image; \
# remove wizard for now
@@ -82,7 +87,7 @@ rm -rf /usr/share/doc/*; \
rm -f /var/log/alternatives.log /var/log/apt/*; \
rm /var/cache/debconf/*-old;
-COPY docker-common/nextcloudplus/000ncp /etc/services-enabled.d/
+COPY docker-common/nextcloudpi/000ncp /etc/services-enabled.d/
# 4443 - ncp-web
EXPOSE 80 443 4443
diff --git a/etc/ncp-config.d/NFS.sh b/etc/ncp-config.d/NFS.sh
index e3b64988..9fd6e715 100644
--- a/etc/ncp-config.d/NFS.sh
+++ b/etc/ncp-config.d/NFS.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh NFS.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/SSH.sh b/etc/ncp-config.d/SSH.sh
index 2dcdc7d2..5d4d1654 100644
--- a/etc/ncp-config.d/SSH.sh
+++ b/etc/ncp-config.d/SSH.sh
@@ -3,7 +3,7 @@
# Activate/deactivate SSH
#
#
-# Copyleft 2017 by Courtney Hicks
+# Copyleft 2017 by Courtney Hicks and Ignacio Nunez Hernanz
# GPL licensed (see end of file) * Use at your own risk!
#
diff --git a/etc/ncp-config.d/UFW.sh b/etc/ncp-config.d/UFW.sh
index 617e6ed7..b12380d3 100644
--- a/etc/ncp-config.d/UFW.sh
+++ b/etc/ncp-config.d/UFW.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh UFW.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/dnsmasq.sh b/etc/ncp-config.d/dnsmasq.sh
index ab6f65c2..37220bbd 100644
--- a/etc/ncp-config.d/dnsmasq.sh
+++ b/etc/ncp-config.d/dnsmasq.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh dnsmasq.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com/2017/03/09/dnsmasq-as-dns-cache-server-for-nextcloudpi-and-raspbian/
#
diff --git a/etc/ncp-config.d/fail2ban.sh b/etc/ncp-config.d/fail2ban.sh
index 4cbe3fe8..d7667a12 100644
--- a/etc/ncp-config.d/fail2ban.sh
+++ b/etc/ncp-config.d/fail2ban.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh fail2ban.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com/2017/02/24/nextcloudpi-fail2ban-installer/
#
diff --git a/etc/ncp-config.d/freeDNS.sh b/etc/ncp-config.d/freeDNS.sh
index bffc98e1..b13129e6 100644
--- a/etc/ncp-config.d/freeDNS.sh
+++ b/etc/ncp-config.d/freeDNS.sh
@@ -5,14 +5,6 @@
# Copyleft 2017 by Panteleimon Sarantos <pantelis.fedora _a_t_ gmail _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh freedns.sh
-#
-# See installer.sh instructions for details
-#
-#
-#
ACTIVE_=no
UPDATEHASH_=abcdefghijklmnopqrstuvwxyzABCDEFGHIJK1234567
diff --git a/etc/ncp-config.d/letsencrypt.sh b/etc/ncp-config.d/letsencrypt.sh
index a9d480ec..7c2bb155 100644
--- a/etc/ncp-config.d/letsencrypt.sh
+++ b/etc/ncp-config.d/letsencrypt.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh letsencrypt.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/03/17/lets-encrypt-installer-for-apache/
DOMAIN_=mycloud.ownyourbits.com
diff --git a/etc/ncp-config.d/modsecurity.sh b/etc/ncp-config.d/modsecurity.sh
index 5bc4a4c0..fa1184f9 100644
--- a/etc/ncp-config.d/modsecurity.sh
+++ b/etc/ncp-config.d/modsecurity.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh modsecurity.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-admin.sh b/etc/ncp-config.d/nc-admin.sh
index 16cf79ce..10ffff15 100644
--- a/etc/ncp-config.d/nc-admin.sh
+++ b/etc/ncp-config.d/nc-admin.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-admin.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-audit.sh b/etc/ncp-config.d/nc-audit.sh
index 04ef9c80..70df02a8 100644
--- a/etc/ncp-config.d/nc-audit.sh
+++ b/etc/ncp-config.d/nc-audit.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-audit.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-automount.sh b/etc/ncp-config.d/nc-automount.sh
index 19d91aea..d16a0bc2 100644
--- a/etc/ncp-config.d/nc-automount.sh
+++ b/etc/ncp-config.d/nc-automount.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-automount.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/
#
diff --git a/etc/ncp-config.d/nc-autoupdate-nc.sh b/etc/ncp-config.d/nc-autoupdate-nc.sh
index 0c639342..11ac884c 100644
--- a/etc/ncp-config.d/nc-autoupdate-nc.sh
+++ b/etc/ncp-config.d/nc-autoupdate-nc.sh
@@ -5,11 +5,6 @@
# Copyleft 2018 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-autoupdate-nc.sh <IP>
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-autoupdate-ncp.sh b/etc/ncp-config.d/nc-autoupdate-ncp.sh
index 1fa6e2d9..5f1430ab 100644
--- a/etc/ncp-config.d/nc-autoupdate-ncp.sh
+++ b/etc/ncp-config.d/nc-autoupdate-ncp.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-autoupdate-ncp.sh <IP>
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-backup-auto.sh b/etc/ncp-config.d/nc-backup-auto.sh
index d785eac9..629c7dd9 100644
--- a/etc/ncp-config.d/nc-backup-auto.sh
+++ b/etc/ncp-config.d/nc-backup-auto.sh
@@ -4,12 +4,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-backup-auto.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-backup.sh b/etc/ncp-config.d/nc-backup.sh
index 74155c93..5758a2b9 100644
--- a/etc/ncp-config.d/nc-backup.sh
+++ b/etc/ncp-config.d/nc-backup.sh
@@ -4,12 +4,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-backup.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-database.sh b/etc/ncp-config.d/nc-database.sh
index 21c4ecb8..bc1f651e 100644
--- a/etc/ncp-config.d/nc-database.sh
+++ b/etc/ncp-config.d/nc-database.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-database.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/
#
diff --git a/etc/ncp-config.d/nc-datadir.sh b/etc/ncp-config.d/nc-datadir.sh
index bd98ef8d..d39e7a83 100644
--- a/etc/ncp-config.d/nc-datadir.sh
+++ b/etc/ncp-config.d/nc-datadir.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-datadir.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/
#
diff --git a/etc/ncp-config.d/nc-fix-permissions.sh b/etc/ncp-config.d/nc-fix-permissions.sh
index 9aa9f1ea..d1cb578e 100644
--- a/etc/ncp-config.d/nc-fix-permissions.sh
+++ b/etc/ncp-config.d/nc-fix-permissions.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-fix-permissions.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-format-USB.sh b/etc/ncp-config.d/nc-format-USB.sh
index fef1f287..404155d5 100644
--- a/etc/ncp-config.d/nc-format-USB.sh
+++ b/etc/ncp-config.d/nc-format-USB.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-format-USB.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-forward-ports.sh b/etc/ncp-config.d/nc-forward-ports.sh
index ae25779c..b8e15ae8 100644
--- a/etc/ncp-config.d/nc-forward-ports.sh
+++ b/etc/ncp-config.d/nc-forward-ports.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-forward-ports.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-httpsonly.sh b/etc/ncp-config.d/nc-httpsonly.sh
index 6f441108..856642b2 100644
--- a/etc/ncp-config.d/nc-httpsonly.sh
+++ b/etc/ncp-config.d/nc-httpsonly.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-httpsonly.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/
#
diff --git a/etc/ncp-config.d/nc-info.sh b/etc/ncp-config.d/nc-info.sh
index e4b08f07..e9653138 100644
--- a/etc/ncp-config.d/nc-info.sh
+++ b/etc/ncp-config.d/nc-info.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-info.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-init.sh b/etc/ncp-config.d/nc-init.sh
index befc0b36..ad28c0b5 100644
--- a/etc/ncp-config.d/nc-init.sh
+++ b/etc/ncp-config.d/nc-init.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-init.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-limits.sh b/etc/ncp-config.d/nc-limits.sh
index 8902df5f..60da4d8e 100644
--- a/etc/ncp-config.d/nc-limits.sh
+++ b/etc/ncp-config.d/nc-limits.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-limits.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/03/13/nextcloudpi-gets-nextcloudpi-config/
#
diff --git a/etc/ncp-config.d/nc-nextcloud.sh b/etc/ncp-config.d/nc-nextcloud.sh
index ccc16dd6..61797e17 100644
--- a/etc/ncp-config.d/nc-nextcloud.sh
+++ b/etc/ncp-config.d/nc-nextcloud.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-nextcloud <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
@@ -31,7 +25,7 @@ INFOTITLE="NextCloud installation"
INFO="This new installation will cleanup current
NextCloud instance, including files and database.
-You can later use nc-init to configure to NextCloudPlus defaults
+You can later use nc-init to configure to NextCloudPi defaults
** perform backup before proceding **
@@ -40,7 +34,7 @@ You can use nc-backup "
install()
{
- # During build, this step is run before nextcloudplus.sh. Avoid executing twice
+ # During build, this step is run before ncp.sh. Avoid executing twice
[[ -f /usr/lib/systemd/system/nc-provisioning.service ]] && return 0
# Optional packets for Nextcloud and Apps
diff --git a/etc/ncp-config.d/nc-notify-updates.sh b/etc/ncp-config.d/nc-notify-updates.sh
index cc0432da..b69023dd 100644
--- a/etc/ncp-config.d/nc-notify-updates.sh
+++ b/etc/ncp-config.d/nc-notify-updates.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-notify-updates.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-passwd.sh b/etc/ncp-config.d/nc-passwd.sh
index ae3831fa..b65a557a 100644
--- a/etc/ncp-config.d/nc-passwd.sh
+++ b/etc/ncp-config.d/nc-passwd.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-passwd.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-ramlogs.sh b/etc/ncp-config.d/nc-ramlogs.sh
index 62417751..d9008a6c 100644
--- a/etc/ncp-config.d/nc-ramlogs.sh
+++ b/etc/ncp-config.d/nc-ramlogs.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-ramlogs.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/
#
diff --git a/etc/ncp-config.d/nc-restore.sh b/etc/ncp-config.d/nc-restore.sh
index 30fc745c..aff146f4 100644
--- a/etc/ncp-config.d/nc-restore.sh
+++ b/etc/ncp-config.d/nc-restore.sh
@@ -6,12 +6,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-restore.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-rsync-auto.sh b/etc/ncp-config.d/nc-rsync-auto.sh
index eccddd83..08a5a3d8 100644
--- a/etc/ncp-config.d/nc-rsync-auto.sh
+++ b/etc/ncp-config.d/nc-rsync-auto.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-rsync.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-rsync.sh b/etc/ncp-config.d/nc-rsync.sh
index c978a552..7ed1ad38 100644
--- a/etc/ncp-config.d/nc-rsync.sh
+++ b/etc/ncp-config.d/nc-rsync.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-rsync.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-scan-auto.sh b/etc/ncp-config.d/nc-scan-auto.sh
index 87d772a4..89bafdb2 100644
--- a/etc/ncp-config.d/nc-scan-auto.sh
+++ b/etc/ncp-config.d/nc-scan-auto.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./nc-scan-auto.sh
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-scan.sh b/etc/ncp-config.d/nc-scan.sh
index 0e30cc25..70b7570a 100644
--- a/etc/ncp-config.d/nc-scan.sh
+++ b/etc/ncp-config.d/nc-scan.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./nc-scan.sh
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-snapshot-auto.sh b/etc/ncp-config.d/nc-snapshot-auto.sh
index 84053656..03c5e58e 100644
--- a/etc/ncp-config.d/nc-snapshot-auto.sh
+++ b/etc/ncp-config.d/nc-snapshot-auto.sh
@@ -6,12 +6,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-snapshot-auto.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-snapshot-sync.sh b/etc/ncp-config.d/nc-snapshot-sync.sh
index 9f992f6a..ecca05f3 100644
--- a/etc/ncp-config.d/nc-snapshot-sync.sh
+++ b/etc/ncp-config.d/nc-snapshot-sync.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-snapshot-sync.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-snapshot.sh b/etc/ncp-config.d/nc-snapshot.sh
index 9059ac7c..607bc47e 100644
--- a/etc/ncp-config.d/nc-snapshot.sh
+++ b/etc/ncp-config.d/nc-snapshot.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-snapshot.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-static-IP.sh b/etc/ncp-config.d/nc-static-IP.sh
index 6da04f0d..a76c8963 100644
--- a/etc/ncp-config.d/nc-static-IP.sh
+++ b/etc/ncp-config.d/nc-static-IP.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-static-IP.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-swapfile.sh b/etc/ncp-config.d/nc-swapfile.sh
index 424588c2..b71b976c 100644
--- a/etc/ncp-config.d/nc-swapfile.sh
+++ b/etc/ncp-config.d/nc-swapfile.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-swapfile.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/
#
diff --git a/etc/ncp-config.d/nc-update-nextcloud.sh b/etc/ncp-config.d/nc-update-nextcloud.sh
index 14ac74b9..ca49afad 100644
--- a/etc/ncp-config.d/nc-update-nextcloud.sh
+++ b/etc/ncp-config.d/nc-update-nextcloud.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-update-nextcloud.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/nc-update.sh b/etc/ncp-config.d/nc-update.sh
index 056bf620..61387133 100644
--- a/etc/ncp-config.d/nc-update.sh
+++ b/etc/ncp-config.d/nc-update.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-update.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/
#
diff --git a/etc/ncp-config.d/nc-webui.sh b/etc/ncp-config.d/nc-webui.sh
index 4a1f7e5e..ef22ea3a 100644
--- a/etc/ncp-config.d/nc-webui.sh
+++ b/etc/ncp-config.d/nc-webui.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-webui.sh <IP>
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/nc-wifi.sh b/etc/ncp-config.d/nc-wifi.sh
index bac5d8f7..2914a845 100644
--- a/etc/ncp-config.d/nc-wifi.sh
+++ b/etc/ncp-config.d/nc-wifi.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-wifi.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/
#
diff --git a/etc/ncp-config.d/nc-zram.sh b/etc/ncp-config.d/nc-zram.sh
index 7bdbfe44..ccf595cf 100644
--- a/etc/ncp-config.d/nc-zram.sh
+++ b/etc/ncp-config.d/nc-zram.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh nc-zram.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
#
diff --git a/etc/ncp-config.d/no-ip.sh b/etc/ncp-config.d/no-ip.sh
index cf3d8232..1e610c9b 100644
--- a/etc/ncp-config.d/no-ip.sh
+++ b/etc/ncp-config.d/no-ip.sh
@@ -5,12 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh no-ip.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
# More at https://ownyourbits.com/2017/03/05/dynamic-dns-for-raspbian-with-no-ip-org-installer/
#
diff --git a/etc/ncp-config.d/samba.sh b/etc/ncp-config.d/samba.sh
index 9b6b3d46..3898b1a9 100644
--- a/etc/ncp-config.d/samba.sh
+++ b/etc/ncp-config.d/samba.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh samba.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: https://ownyourbits.com
#
diff --git a/etc/ncp-config.d/unattended-upgrades.sh b/etc/ncp-config.d/unattended-upgrades.sh
index 4ced697e..94b391d8 100644
--- a/etc/ncp-config.d/unattended-upgrades.sh
+++ b/etc/ncp-config.d/unattended-upgrades.sh
@@ -5,11 +5,6 @@
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
-# Usage:
-#
-# ./installer.sh unattended-upgrades.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
# More at: ownyourbits.com
#
diff --git a/install.sh b/install.sh
index 42d4bc49..84cacba8 100644
--- a/install.sh
+++ b/install.sh
@@ -1,6 +1,6 @@
#!/bin/bash
-# NextCloudPlus installation script
+# NextCloudPi installation script
#
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
@@ -14,7 +14,7 @@ BRANCH=master
set -e$DBG
-TMPDIR="$(mktemp -d /tmp/nextcloudplus.XXXXXX || (echo "Failed to create temp dir. Exiting" >&2 ; exit 1) )"
+TMPDIR="$(mktemp -d /tmp/nextcloudpi.XXXXXX || (echo "Failed to create temp dir. Exiting" >&2 ; exit 1) )"
trap "rm -rf \"${TMPDIR}\" ; exit 0" 0 1 2 3 15
[[ ${EUID} -ne 0 ]] && {
@@ -44,13 +44,13 @@ wget -O- --content-disposition https://github.com/nextcloud/nextcloudpi/archive/
cd - && cd "$TMPDIR"/nextcloudpi-"$BRANCH"
# install NCP
-echo -e "\nInstalling NextCloudPlus"
+echo -e "\nInstalling NextCloudPi"
source etc/library.sh
install_script lamp.sh
install_script etc/ncp-config.d/nc-nextcloud.sh
activate_script etc/ncp-config.d/nc-nextcloud.sh
-install_script nextcloudplus.sh
+install_script ncp.sh
activate_script etc/ncp-config.d/nc-init.sh
# re-enable mods disabled during install, in case there's other shared services in apache2
diff --git a/installer.sh b/installer.sh
index 422f9ed8..1c754d2f 100755
--- a/installer.sh
+++ b/installer.sh
@@ -35,16 +35,13 @@ INSTALL_SCRIPT=$1 # First argument is the script to be run inside Raspbian
IP=$2 # Second argument is the QEMU Raspbian IP address
IMGFILE=$3 # Third argument is the image file to start from ( empty for online installation )
-source buildlib.sh # initializes $IMGNAME
-source etc/library.sh
-
-test -f "$IMGNAME" && { echo "INFO: $IMGNAME already exists. Skip generation ... "; exit 0; }
+source buildlib.sh
config "$INSTALL_SCRIPT" || exit 1 # Initializes $INSTALLATION_CODE
if [[ "$IMGFILE" != "" ]]; then
- launch_install_qemu "$IMGFILE" "$IP" || { sudo killall qemu-system-arm; exit 1; } # initializes $IMGOUT
- pack_image "$IMGOUT" "$IMGNAME"
+ launch_install_qemu "$IMGFILE" "$IP" || { sudo killall qemu-system-arm; exit 1; } # initializes $IMGOUT
+ pack_image "$IMGOUT" "$IMGOUT".tar.bz2
else
launch_installation_online "$IP"
fi
diff --git a/nextcloudplus.sh b/ncp.sh
index afd26272..5439b4db 100644
--- a/nextcloudplus.sh
+++ b/ncp.sh
@@ -1,13 +1,13 @@
#!/bin/bash
-# NextcloudPlus additions to Raspbian
+# NextCloudPi additions to Raspbian
#
# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
# GPL licensed (see end of file) * Use at your own risk!
#
# Usage:
#
-# ./installer.sh nextcloudplus.sh <IP> (<img>)
+# ./installer.sh ncp.sh <IP> (<img>)
#
# See installer.sh instructions for details
#
@@ -32,7 +32,7 @@ install()
# include option in raspi-config (only Raspbian)
test -f /usr/bin/raspi-config && {
- sed -i '/Change User Password/i"0 NextCloudPlus Configuration" "Configuration of NextCloudPlus" \\\\' /usr/bin/raspi-config
+ sed -i '/Change User Password/i"0 NextCloudPi Configuration" "Configuration of NextCloudPi" \\\\' /usr/bin/raspi-config
sed -i '/1\\\\ \*) do_change_pass ;;/i0\\\\ *) ncp-config ;;' /usr/bin/raspi-config
}
@@ -170,7 +170,7 @@ EOF
# make sure this is called on last re-boot
[[ "$DOCKERBUILD" != 1 ]] && systemctl enable nextcloud-domain
- # NEXTCLOUDPLUS UPDATES
+ # NEXTCLOUDPI UPDATES
cat > /etc/cron.daily/ncp-check-version <<EOF
#!/bin/sh
/usr/local/bin/ncp-check-version
@@ -191,7 +191,7 @@ EOF
if [[ -f /.ncp-image ]]; then
rm -rf /var/log/ncp.log
- ## NEXTCLOUDPLUS MOTD
+ ## NEXTCLOUDPI MOTD
rm -rf /etc/update-motd.d
mkdir /etc/update-motd.d
rm /etc/motd
@@ -211,11 +211,11 @@ EOF
## HOSTNAME AND mDNS
$APTINSTALL avahi-daemon
- echo nextcloudplus > /etc/hostname
- sed -i '$c127.0.1.1 nextcloudplus' /etc/hosts
+ echo nextcloudpi > /etc/hostname
+ sed -i '$c127.0.1.1 nextcloudpi' /etc/hosts
## tag image
- echo "NextCloudPlus_$( date "+%m-%d-%y" )" > /usr/local/etc/ncp-baseimage
+ echo "NextCloudPi_$( date "+%m-%d-%y" )" > /usr/local/etc/ncp-baseimage
## SSH hardening
if [[ -f /etc/ssh/sshd_config ]]; then
diff --git a/post-inst.sh b/post-inst.sh
new file mode 100644
index 00000000..f7e1690d
--- /dev/null
+++ b/post-inst.sh
@@ -0,0 +1,53 @@
+#!/bin/bash
+
+# Cleanup step Raspbian image
+#
+# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
+# GPL licensed (see end of file) * Use at your own risk!
+#
+# More at nextcloudpi.com
+#
+
+configure()
+{
+ # stop mysqld and redis
+ mysqladmin -u root shutdown
+ kill $( cat /run/redis/redis-server.pid )
+ kill $( cat /run/crond.pid )
+
+ # enable randomize passwords
+ systemctl enable nc-provisioning
+
+ # cleanup all NCP extras
+ source /usr/local/etc/library.sh
+ cd /usr/local/etc/ncp-config.d/
+ for script in *.sh; do
+ cleanup_script $script
+ done
+
+ # clean packages and installation logs
+ apt-get autoremove -y
+ apt-get clean
+ rm /var/lib/apt/lists/* -r
+ find /var/log -type f -exec rm {} \;
+
+ # clean build flags
+ rm /.ncp-image
+}
+
+# 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/prepare.sh b/prepare.sh
deleted file mode 100644
index 29d94f81..00000000
--- a/prepare.sh
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/bin/bash
-
-# Prepare a Raspbian image (resize and update)
-#
-# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
-# GPL licensed (see end of file) * Use at your own risk!
-#
-# Usage: ./installer.sh prepare.sh <DHCP QEMU image IP> <image>
-#
-
-
-STATE_FILE=/home/pi/.installation_state
-APTINSTALL="apt-get install -y --no-install-recommends"
-
-install()
-{
- test -f $STATE_FILE && STATE=$( cat $STATE_FILE 2>/dev/null )
- if [ "$STATE" == "" ]; then
-
- # MARK THE IMAGE AS AN IMAGE BUILD
- touch /.ncp-image
-
- # RESIZE IMAGE
- ##########################################
-
- SECTOR=$( fdisk -l /dev/sda | grep Linux | awk '{ print $2 }' )
- echo -e "d\n2\nn\np\n2\n$SECTOR\n\nw\n" | fdisk /dev/sda || true
-
- echo 0 > $STATE_FILE
- nohup reboot &>/dev/null &
- elif [ "$STATE" == "0" ]; then
-
- # UPDATE EVERYTHING
- ##########################################
- resize2fs /dev/sda2
-
- apt-get update
- sleep 30
- apt-get upgrade -y
- apt-get dist-upgrade -y
-
- # As of 03-2018, you dont get a big kernel update by doing
- # this, so better be safe. Might uncomment again in the future
- # $APTINSTALL rpi-update
- echo -e "y\n" #| PRUNE_MODULES=1 rpi-update
- fi
-}
-
-configure(){ :; }
-
-cleanup()
-{
- [ "$STATE" != "0" ] && return
- rm $STATE_FILE
- nohup halt &>/dev/null &
-}
-
-# 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/raspbian-cleanup.sh b/raspbian-cleanup.sh
deleted file mode 100644
index b258111f..00000000
--- a/raspbian-cleanup.sh
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/bin/bash
-
-# Cleanup step Raspbian image
-#
-# Copyleft 2017 by Ignacio Nunez Hernanz <nacho _a_t_ ownyourbits _d_o_t_ com>
-# GPL licensed (see end of file) * Use at your own risk!
-#
-# Usage:
-#
-# ./installer.sh raspbian-cleanup.sh <IP> (<img>)
-#
-# See installer.sh instructions for details
-#
-# More at https://ownyourbits.com/2017/02/13/nextcloud-ready-raspberry-pi-image/
-#
-
-install() { :; }
-configure() { :; }
-
-cleanup()
-{
- # cleanup all NCP extras
- source /usr/local/etc/library.sh
- cd /usr/local/etc/ncp-config.d/
- for script in *.sh; do
- cleanup_script $script
- done
-
- # clean packages
- apt-get autoremove -y
- apt-get clean
- rm /var/lib/apt/lists/* -r
-
- # restore expand filesystem on first boot
- cat > /etc/init.d/resize2fs_once <<'EOF'
-#!/bin/sh
-### BEGIN INIT INFO
-# Provides: resize2fs_once
-# Required-Start:
-# Required-Stop:
-# Default-Start: 3
-# Default-Stop:
-# Short-Description: Resize the root filesystem to fill partition
-# Description:
-### END INIT INFO
-
-. /lib/lsb/init-functions
-
-case "$1" in
- start)
- log_daemon_msg "Starting resize2fs_once" && \
- resize2fs /dev/mmcblk0p2 && \
- update-rc.d resize2fs_once remove && \
- rm /etc/init.d/resize2fs_once && \
- log_end_msg $?
- ;;
- *)
- echo "Usage: $0 start" >&2
- exit 3
- ;;
-esac
-EOF
- chmod +x /etc/init.d/resize2fs_once
- systemctl enable resize2fs_once
-
- # remove QEMU specific rules
- rm -f /etc/udev/rules.d/90-qemu.rules
-
- # clean build flags
- rm /.ncp-image
-
- # harden and disable SSH
- sed -i 's|^#PermitRootLogin .*|PermitRootLogin no|' /etc/ssh/sshd_config
- systemctl disable ssh
-
- # enable randomize passwords
- systemctl enable nc-provisioning
-
- # other
- sudo -u www-data php /var/www/nextcloud/occ config:system:delete trusted_domains 1
-}
-
-# 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