Skip to content

Commit

Permalink
add nc-test-hdd
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Nov 5, 2018
1 parent 308a1a2 commit 6138183
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 6 deletions.
7 changes: 3 additions & 4 deletions batch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@
# 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>
# Usage: ./batch.sh
#

set -e

IP=${1:-192.168.0.145} # For QEMU automated testing

## BUILDING
source buildlib.sh # initializes $IMGNAME

Expand All @@ -21,14 +19,15 @@ source buildlib.sh # initializes $IMGNAME
}

# Raspbian
./build-SD-rpi.sh "$IP"
./build-SD-rpi.sh
IMG="$( ls -1t tmp/*.img | head -1 )"
./build-SD-berryboot.sh "$IMG"

# Armbian
./build-SD-armbian.sh odroidxu4 OdroidHC2
./build-SD-armbian.sh rock64 Rock64
./build-SD-armbian.sh bananapi Bananapi
./build-SD-armbian.sh orangepizeroplus2-h5 OrangePiZeroPlus2

# VM
./build-VM.sh
Expand Down
1 change: 0 additions & 1 deletion build-SD-rpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
set -e
source buildlib.sh

IP=${1:-192.168.0.145} # For QEMU automated testing (optional)
SIZE=3G # Raspbian image size
#CLEAN=0 # Pass this envvar to skip cleaning download cache
IMG="NextCloudPi_RPi_$( date "+%m-%d-%y" ).img"
Expand Down
4 changes: 3 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

[v0.64.12](https://github.com/nextcloud/nextcloudpi/commit/293c2c7) (2018-11-03) docker: fix provisioning on a stopped the container
[v0.65.0](https://github.com/nextcloud/nextcloudpi/commit/2f56f2c) (2018-11-03) add nc-test-hdd

[v0.64.12](https://github.com/nextcloud/nextcloudpi/commit/5e7f3da) (2018-11-03) docker: fix provisioning on a stopped the container

[v0.64.11](https://github.com/nextcloud/nextcloudpi/commit/1758331) (2018-10-27) check for path transversal

Expand Down
72 changes: 72 additions & 0 deletions etc/ncp-config.d/nc-hdd-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#!/bin/bash

# Check HDD health
#
# 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!
#
# More at https://ownyourbits.com
#

SHORTTEST_=yes
LONGTEST_=no
DESCRIPTION="Check HDD health"

INFO="Running no test will display test results"

install()
{
apt-get update
apt-get install --no-install-recommends -y smartmontools
systemctl disable smartd
systemctl stop smartd
}

configure()
{
local DRIVES=($(lsblk -ln | grep "^sd[[:alpha:]].*disk" | awk '{ print $1 }'))

[[ ${#DRIVES[@]} == 0 ]] && {
echo "no drives detected. Abort"
return 0
}

for dr in "${DRIVES[@]}"; do
smartctl --smart=on /dev/${dr} | sed 1,2d
if [[ "$SHORTTEST_" == yes ]]; then
echo "* Starting test on $dr. Check results later"
smartctl -X "/dev/$dr" &>/dev/null
smartctl -t short "/dev/$dr" | sed 1,2d
elif [[ "$LONGTEST_" == yes ]]; then
echo "* Starting test on $dr. Check results later"
smartctl -X "/dev/$dr" &>/dev/null
smartctl -t long "/dev/$dr" | sed 1,2d
else
echo "* Test results for $dr"
smartctl -l selftest "/dev/$dr" | sed 1,2d

echo "* Health Check for $dr"
smartctl -H "/dev/$dr" | sed 1,2d

echo "* Stats for $dr"
smartctl -A "/dev/$dr" | sed 1,2d
fi
done
}

# 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

0 comments on commit 6138183

Please sign in to comment.