#!/bin/bash
# Michael Magua
# Mount the fileserver and calculate \\TPSFS\Common
mount -t cifs -o credentials=/root/.credentials.txt //10.1.5.1/Common /opt/smb/mount
# Cd into /tpsfs-mount
cd /opt/smb/mount
# Calculate disk usage and send the output to /tmp
du --max-depth=1 -h > /tmp/Common.txt
# Exit /tpsfs-mount
cd /
# Unmount the Common share
umount //10.1.5.1/Common
# This time mount the fileserver and calculate \\TPSFS\Users
mount -t cifs -o credentials=/root/.credentials.txt //10.1.5.1/Users /opt/smb/mount
# Cd into /tpsfs-mount
cd /opt/smb/mount
# Calculate disk usage and send the output to /tmp
du --max-depth=1 -h > /tmp/Users.txt
# Exit /tpsfs-mount
cd /
# Unmount the Users share
umount //10.1.5.1/Users
# Make the *.txt files look easier on the eye ;)
sed -i "s/\.\///" /tmp/{Common,Users}.txt
# Mail the reports
echo `date` "Reports Generated..." | nail -s "The <site> fileserver usage report" -a /tmp/Common.txt -a /tmp/Users.txt me@me.com
# Delete the reports
rm -f /tmp/{Common,Users}.txt