From 378ca60d88a48dec7adbb34ea534166692e5bffe Mon Sep 17 00:00:00 2001 From: nachoparker Date: Mon, 10 Sep 2018 20:16:01 -0600 Subject: nc-datadir: support specifying the root of the mountpoint --- etc/ncp-config.d/nc-datadir.sh | 16 ++++++++++++++-- etc/ncp-config.d/unattended-upgrades.sh | 28 +++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/etc/ncp-config.d/nc-datadir.sh b/etc/ncp-config.d/nc-datadir.sh index 38f0e05f..4c4a45c4 100644 --- a/etc/ncp-config.d/nc-datadir.sh +++ b/etc/ncp-config.d/nc-datadir.sh @@ -44,9 +44,21 @@ configure() [ -d "$BASEDIR" ] || { echo "$BASEDIR does not exist"; return 1; } - grep -q -e ext -e btrfs <( stat -fc%T "$BASEDIR" ) || { echo -e "Only ext/btrfs filesystems can hold the data directory"; return 1; } + # If the user chooses the root of the mountpoint, force a folder + mountpoint -q "$DATADIR_" && { + BASEDIR="$DATADIR_" + DATADIR_="$DATADIR_/ncdata" + } + + grep -q -e ext -e btrfs <( stat -fc%T "$BASEDIR" ) || { + echo -e "Only ext/btrfs filesystems can hold the data directory" + return 1 + } - sudo -u www-data test -x "$BASEDIR" || { echo -e "ERROR: the user www-data does not have access permissions over $BASEDIR"; return 1; } + sudo -u www-data test -x "$BASEDIR" || { + echo -e "ERROR: the user www-data does not have access permissions over $BASEDIR" + return 1 + } [[ $( stat -fc%d / ) == $( stat -fc%d "$BASEDIR" ) ]] && { echo "Refusing to move to the SD card. Abort" diff --git a/etc/ncp-config.d/unattended-upgrades.sh b/etc/ncp-config.d/unattended-upgrades.sh index 94b391d8..eba93a5d 100644 --- a/etc/ncp-config.d/unattended-upgrades.sh +++ b/etc/ncp-config.d/unattended-upgrades.sh @@ -24,9 +24,12 @@ configure() [[ $ACTIVE_ == "yes" ]] && local AUTOUPGRADE=1 || local AUTOUPGRADE=0 [[ $AUTOREBOOT_ == "yes" ]] && local AUTOREBOOT=true || local AUTOREBOOT=false - # It seems like the label Raspbian-Security does not work for Raspbian - # See https://www.raspberrypi.org/forums/viewtopic.php?t=82863&p=585739 - cat > /etc/apt/apt.conf.d/20ncp-upgrades < /etc/apt/apt.conf.d/20ncp-upgrades < /etc/apt/apt.conf.d/20ncp-upgrades <