diff options
author | nachoparker <nacho@ownyourbits.com> | 2017-05-20 12:12:37 +0300 |
---|---|---|
committer | nachoparker <nacho@ownyourbits.com> | 2017-05-24 19:41:29 +0300 |
commit | e3a4878ef2e2e9f6b6ae6a701a449c024d1982ef (patch) | |
tree | e61e56223c800476e6082a8066a65724bfae3af7 | |
parent | 06423bf4ae86ec695d4dcde482f1f316a79e5cd6 (diff) |
add automount featurev0.12.0
-rw-r--r-- | README.md | 25 | ||||
-rwxr-xr-x | etc/nextcloudpi-config.d/nc-automount.sh | 128 |
2 files changed, 142 insertions, 11 deletions
@@ -7,7 +7,7 @@ Use QEMU to automatically generate Raspbian Images with Nextcloud ## Features * Raspbian 8 Jessie -* Nextcloud 11.0.2 +* Nextcloud 12 * Apache 2.4.25, with HTTP2 enabled * PHP 7.0 (double the speed of PHP5!) * MariaDB 10 @@ -23,16 +23,19 @@ Use QEMU to automatically generate Raspbian Images with Nextcloud ## Extras -* Wi-Fi ready ( NEW 03-31-2017 ) -* Automatic security updates, activated by default. ( NEW 03-21-2017 ) -* Let’s Ecrypt for trusted HTTPS certificates.( NEW 03-16-2017 ) -* Fail2Ban protection against brute force attacks. ( NEW 02-24-2017 ) -* Dynamic DNS support for no-ip.org ( NEW 03-05-2017 ) -* dnsmasq DNS server with DNS cache ( NEW 03-09-2017 ) -* ModSecurity Web Application Firewall ( NEW 03-23-2017 ) -* NFS ready to mount your files over LAN ( NEW 04-13-2017 ) -* SAMBA ready to share your files with Windows/Mac/Linux ( NEW 04-16-2017 ) -* Remote updates ( NEW 03-31-2017 ) + * Wi-Fi ready ( NEW 03-31-2017 ) + * Automatic security updates, activated by default. ( NEW 03-21-2017 ) + * Let’s Encrypt for trusted HTTPS certificates.( NEW 03-16-2017 ) + * Fail2Ban protection against brute force attacks. ( NEW 02-24-2017 ) + * Dynamic DNS support for no-ip.org ( NEW 03-05-2017 ) + * dnsmasq DNS server with DNS cache ( NEW 03-09-2017 ) + * ModSecurity Web Application Firewall ( NEW 03-23-2017 ) + * NFS ready to mount your files over LAN ( NEW 04-13-2017 ) + * SAMBA ready to share your files with Windows/Mac/Linux ( NEW 04-16-2017 ) + * USB automount ( NEW 05-24-2017 ) + * Remote updates ( NEW 03-31-2017 ) + * NextCloud backup and restore ( NEW 05-24-2017 ) + * NextCloud online installation ( NEW 05-24-2017 ) ## Usage diff --git a/etc/nextcloudpi-config.d/nc-automount.sh b/etc/nextcloudpi-config.d/nc-automount.sh new file mode 100755 index 00000000..9f2d49ce --- /dev/null +++ b/etc/nextcloudpi-config.d/nc-automount.sh @@ -0,0 +1,128 @@ +#!/bin/bash + +# Automount configuration for NextCloudPi +# Tested with 2017-03-02-raspbian-jessie-lite.img +# +# 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/ +# + +ACTIVE_=no +DESCRIPTION="Automount USB drives by plugging them in" + +show_info() +{ + whiptail --yesno \ + --backtitle "NextCloudPi configuration" \ + --title "Automount notes" \ +"Plugged in USB drives will be automounted under /media +on boot or at the moment of insertion. + +Format your drive as ext4 in order to move NC datafolder or database +VFAT or NTFS is not recommended and will not work without hackery + +IMPORTANT: halt or umount the drive before extracting" \ + 20 90 +} + +install() +{ + cat >> /etc/fstab <<EOF + +# Rules for automounting both at boot and upon USB plugin. Rely on udev rules +/dev/USBdrive /media/USBdrive auto defaults,noatime,auto,nofail 0 2 +/dev/USBdrive1 /media/USBdrive1 auto defaults,noatime,auto,nofail 0 2 +/dev/USBdrive2 /media/USBdrive2 auto defaults,noatime,auto,nofail 0 2 +/dev/USBdrive3 /media/USBdrive3 auto defaults,noatime,auto,nofail 0 2 +/dev/USBdrive4 /media/USBdrive4 auto defaults,noatime,auto,nofail 0 2 +/dev/USBdrive5 /media/USBdrive5 auto defaults,noatime,auto,nofail 0 2 +/dev/USBdrive6 /media/USBdrive6 auto defaults,noatime,auto,nofail 0 2 +/dev/USBdrive7 /media/USBdrive7 auto defaults,noatime,auto,nofail 0 2 +/dev/USBdrive8 /media/USBdrive8 auto defaults,noatime,auto,nofail 0 2 +EOF + + cat > /usr/local/etc/blknum <<'EOF' +#!/bin/bash + +OUT=$( lsblk -l ) + +# partitions, from USB hard drives +PARTS=$( grep part <<< "$OUT" | wc -l ) + +# removable flash sticks +RM=$( awk '{ print $3 }' <<< "$OUT" | grep -c 1 ) + +# discount /boot and /root, start at 0 +RES=$(( RM + PARTS - 3 )) + +[[ $RES > 0 ]] && echo $RES || exit 0 + +EOF + chmod +x /usr/local/etc/blknum + + systemctl daemon-reload +} + +cleanup() { :; } + +configure() +{ + cat > /etc/udev/rules.d/50-automount.rules <<'EOF' +# Need to be a block device +KERNEL!="sd[a-z]*", GOTO="exit" + +# Import some useful filesystem info as variables +IMPORT{program}="/sbin/blkid -o udev -p %N" + +# Need to be a filesystem +ENV{ID_FS_TYPE}!="vfat|ntfs|ext4", GOTO="exit" + +# Create symlink that will be understood by fstab, and a directory in /media +ACTION!="remove", PROGRAM="/usr/local/etc/blknum", RUN+="/bin/mkdir -p /media/USBdrive%c", SYMLINK+="USBdrive%c" + +# Get a label if present, otherwise specify one +ENV{ID_FS_LABEL}!="", ENV{dir_name}="%E{ID_FS_LABEL}" + +# Link with label name if exists +ACTION!="remove", ENV{ID_FS_LABEL}!="", RUN+="/bin/ln -s /media/USBdrive%c /media/%E{ID_FS_LABEL}" + +# Clean up created directory +ACTION=="remove", RUN+="/bin/rmdir /media/USBdrive%c" + +# Cleanup created link +ACTION=="remove", ENV{ID_FS_LABEL}!="", RUN+="/bin/rm /media/%E{ID_FS_LABEL}" + +# Exit +LABEL="exit" +EOF + + [[ "$ACTIVE_" != "yes" ]] && rm -f /etc/udev/rules.d/50-automount.rules + + udevadm control --reload-rules && udevadm trigger +} + +# 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 + |