Skip to content

Commit

Permalink
nc-datadir: support specifying the root of the mountpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Sep 12, 2018
1 parent 9113ab2 commit 378ca60
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 5 deletions.
16 changes: 14 additions & 2 deletions etc/ncp-config.d/nc-datadir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
28 changes: 25 additions & 3 deletions etc/ncp-config.d/unattended-upgrades.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 <<EOF
# Raspbian case
grep -q Raspbian /etc/issue && {

# 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 <<EOF
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "$AUTOUPGRADE";
APT::Periodic::MaxAge "14";
Expand All @@ -41,6 +44,25 @@ Dpkg::Options {
"--force-confold";
};
EOF

# Armbian case # TODO security only?
} || {
cat > /etc/apt/apt.conf.d/20ncp-upgrades <<EOF
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "$AUTOUPGRADE";
APT::Periodic::MaxAge "14";
APT::Periodic::AutocleanInterval "7";
Unattended-Upgrade::Automatic-Reboot "$AUTOREBOOT";
Unattended-Upgrade::Automatic-Reboot-Time "04:00";
Unattended-Upgrade::Origins-Pattern {
o=Debian,n=stretch,l=Debian;
}
Dpkg::Options {
"--force-confdef";
"--force-confold";
};
EOF
}
echo "Unattended upgrades active: $ACTIVE_ (autoreboot $AUTOREBOOT_)"
}

Expand Down

0 comments on commit 378ca60

Please sign in to comment.