Skip to content

Instantly share code, notes, and snippets.

@gboudreau
Last active December 1, 2019 16:09
Show Gist options
  • Save gboudreau/1caa58d93b1f99ca8e57 to your computer and use it in GitHub Desktop.
Save gboudreau/1caa58d93b1f99ca8e57 to your computer and use it in GitHub Desktop.
Greyhole System Infos
#!/bin/sh
{
echo "## System information"
uname -a 2>&1
echo
echo "## Samba version"
/usr/sbin/smbd --version
if [ -d /usr/lib/arm-linux-gnueabihf/samba/vfs ]; then
TARGET_LIBDIR="/usr/lib/arm-linux-gnueabihf"
elif [ -d /usr/lib/x86_64-linux-gnu/samba/vfs ]; then
TARGET_LIBDIR="/usr/lib/x86_64-linux-gnu"
elif [ -d /usr/lib/i386-linux-gnu/samba/vfs ]; then
TARGET_LIBDIR="/usr/lib/i386-linux-gnu"
elif [ "`uname -m`" = "x86_64" ]; then
TARGET_LIBDIR="/usr/lib64"
# For Ubuntu, where even x86_64 install use /usr/lib
if [ -d /usr/lib/samba/vfs/ ]; then
TARGET_LIBDIR="/usr/lib"
fi
else
TARGET_LIBDIR="/usr/lib"
fi
if [ ! -d ${TARGET_LIBDIR}/samba/vfs/ ]; then
# Maybe samba-vfs-modules is missing?
if [ -d /usr/lib/arm-linux-gnueabihf ]; then
TARGET_LIBDIR="/usr/lib/arm-linux-gnueabihf"
elif [ -d /usr/lib/x86_64-linux-gnu ]; then
TARGET_LIBDIR="/usr/lib/x86_64-linux-gnu"
elif [ -d /usr/lib/i386-linux-gnu ]; then
TARGET_LIBDIR="/usr/lib/i386-linux-gnu"
else
TARGET_LIBDIR="/usr/lib"
fi
fi
TARGET_SYMLINK="${TARGET_LIBDIR}/samba/vfs/greyhole.so"
if [ ! -x /bin/rpm ]; then
echo "## Checking for required Samba libraries..."
MAJOR_SMB_VERSION="`smbd --version | awk '{print $2}' | awk -F'-' '{print $1}' | awk -F'.' '{print $1}'`"
if [ "${MAJOR_SMB_VERSION}" = "4" ]; then
if [ -f ${TARGET_LIBDIR}/samba/libsmbd_base.so.0 ]; then
echo " Found ${TARGET_LIBDIR}/samba/libsmbd_base.so.0"
else
if [ ! -f ${TARGET_LIBDIR}/samba/libsmbd-base-samba4.so ]; then
if [ -f ${TARGET_LIBDIR}/samba/libsmbd-base.so.0 ]; then
echo " Found ${TARGET_LIBDIR}/samba/libsmbd-base.so.0"
else
echo " Error: missing dependent library libsmbd-base.so.0 (libsmbd-base-samba4.so)"
fi
fi
if [ ! -f ${TARGET_LIBDIR}/samba/libsamba-debug-samba4.so ]; then
if [ -f ${TARGET_LIBDIR}/samba/libsamba-debug.so.0 ]; then
echo " Found ${TARGET_LIBDIR}/samba/libsamba-debug.so.0"
elif [ -f ${TARGET_LIBDIR}/libsamba-util.so.0 ]; then
echo " Found ${TARGET_LIBDIR}/libsamba-util.so.0"
else
echo " Error: missing dependent library libsamba-debug.so.0 (libsamba-debug-samba4.so)"
fi
fi
fi
fi
fi
echo
echo "## Samba VFS module"
echo " VFS TARGET_LIBDIR = ${TARGET_LIBDIR}"
echo " VFS TARGET_SYMLINK = ${TARGET_SYMLINK}"
if [ -f /usr/lib/x86_64-linux-gnu/samba/vfs/greyhole.so ]; then
ls -l /usr/lib/x86_64-linux-gnu/samba/vfs/greyhole.so
elif [ -f /usr/lib64/samba/vfs/greyhole.so ]; then
ls -l /usr/lib64/samba/vfs/greyhole.so
else
ls -l /usr/lib/samba/vfs/greyhole.so
fi
md5sum /usr/lib*/greyhole/greyhole-samba*.so
echo
if [ -x /bin/rpm ]; then
echo "## Greyhole version"
rpm -q greyhole
else
echo "## Greyhole version"
dpkg -s greyhole | grep Version | awk '{print $2}'
fi
greyhole | head -1
echo
echo "## Installed (required) packages"
if [ -x /bin/rpm ]; then
rpm -qa | grep samba
rpm -qa | grep mysql
rpm -qa | grep php
else
dpkg --get-selections | grep samba
dpkg --get-selections | grep smb
dpkg --get-selections | grep mysql
dpkg --get-selections | grep mariadb
dpkg --get-selections | grep php
fi
echo
echo "## Mounts"
mount 2>&1
echo
echo "## Locally mounted shares"
ls -la /mnt/samba/
echo
echo "## Disks information"
fdisk -l 2>&1
echo
echo "## Disk space"
df -h 2>&1
echo
echo "## Storage pool directories"
grep storage_pool /etc/greyhole.conf | grep -v '^[ \t]*#' | awk -F'=' '{print $2}' | awk -F'min_free:' '{print $1}' | awk -F',' '{print $1}' | awk '{print $1}' | xargs -I {} sh -c 'echo "{}" ; ls -la "{}" 2>&1'
echo "## Greyhole queue"
greyhole --view-queue 2>&1
echo
echo "## Greyhole storage pool stats"
greyhole --stats 2>&1
echo
greyhole --status 2>&1
echo
echo "## Restarting daemon"
if [ -f /etc/init.d/greyhole ]; then
/etc/init.d/greyhole restart
elif [ -f /etc/init/greyhole.conf ]; then
/sbin/restart greyhole
elif [ -f /usr/bin/systemctl ]; then
/usr/bin/systemctl restart greyhole
fi
echo
echo "## Greyhole log"
tail -200 /var/log/greyhole.log 2>&1
echo "## Greyhole error log"
tail -100 /var/log/greyhole.err 2>&1
echo "## smb.conf"
cat /etc/samba/smb.conf
echo "## Samba logs"
for f in /var/log/samba/*; do
echo "#### $f"
tail -n 50 "$f" 2>/dev/null
done
echo "## greyhole.conf"
cat /etc/greyhole.conf | grep -v db_pass | grep -v email_to.*@
} > /tmp/greyhole_sysinfo
echo "Here's the URL you will need to give the to person who's helping you:"
#cat /tmp/greyhole_sysinfo | curl -F 'sprunge=<-' http://sprunge.us
cat /tmp/greyhole_sysinfo | curl -n -F 'f:1=<-' http://ix.io
#cat /tmp/greyhole_sysinfo | curl -n -F 'f:1=<-' https://secure.danslereseau.com/paste/
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment