#!/bin/bash # NFS server for Raspbian # # Copyleft 2017 by Ignacio Nunez Hernanz # GPL licensed (see end of file) * Use at your own risk! # # More at: https://ownyourbits.com # ACTIVE_=no DIR_=/media/USBdrive/ncdata/admin/files SUBNET_=192.168.1.0/24 USER_=www-data GROUP_=www-data DESCRIPTION="NFS network file system server (for Linux LAN)" INFOTITLE="Instructions for external synchronization" INFO="If we intend to modify the data folder through NFS, then we have to synchronize NextCloud to make it aware of the changes. This can be done manually or automatically using 'nc-scan' and 'nc-scan-auto'" install() { apt-get update apt-get install --no-install-recommends -y nfs-kernel-server systemctl disable nfs-kernel-server systemctl mask nfs-blkmap # delay init because of automount sed -i 's|^ExecStartPre=.*|ExecStartPre=/bin/bash -c "/bin/sleep 30; /usr/sbin/exportfs -r"|' /lib/systemd/system/nfs-server.service } configure() { [[ $ACTIVE_ != "yes" ]] && { service nfs-kernel-server stop systemctl disable nfs-kernel-server echo -e "NFS disabled" return } # CHECKS ################################ id "$USER_" &>/dev/null || { echo "user USER_ does not exist" ; return 1; } id -g "$GROUP_" &>/dev/null || { echo "group GROUP_ does not exist"; return 1; } [ -d "$DIR_" ] || { echo -e "INFO: directory $DIR_ does not exist. Creating"; mkdir -p "$DIR_"; } [[ $( stat -fc%d / ) == $( stat -fc%d $DIR_ ) ]] && \ echo -e "INFO: mounting a in the SD card\nIf you want to use an external mount, make sure it is properly set up" # CONFIG ################################ cat > /etc/exports <