corz.org uses cookies to remember that you've seen this notice explaining that corz.org uses cookies, okay!
corz.org text viewer..
[currently viewing: / public/ linux/ usr/ local/ bin/ corz-grablogs.sh - raw]
if [ -z $1 ]; then
echo
echo "Please supply a domain name on the command-line. e.g.."
echo
echo "$0 foobar.net"
echo
echo "grabcomments will then use settings file: ~/.sftp/foobar.net"
echo
exit 1
fi
. ~/.sftp/$1
echo "Archiving logs for $host.."
newname=$now.$host.logs.tar.gz
if [ ! -e $logstore ]; then
mkdir -pv $logstore > /dev/null
fi
echo "Zipping logs.."
cd $home/$logdir
cd ..
tar cfz $newname log >> $logfile
rm -rf $home/$logdir/$logarc/.* &> /dev/null
rm -rf $home/$logdir/$logarc/phperr.* &> /dev/null
mv $newname $logstore/
remount > /dev/null
if [ ! -d $ol_logs ]; then
mkdir -pv $ol_logs > /dev/null
fi
if [ -e "$ol_logs" ];then
echo -n "Copying log backup to offline storage facility.. "
cp $logstore/$newname $ol_logs/
if [ -e "$ol_logs/$newname" ];then
echo "Success!"
rm $logstore/$newname >> $logfile &> /dev/null
rmdir $logstore &> /dev/null
else
echo "Fail!"
echo "Could not copy $logstore/$newname to $ol_logs"
fi
echo
fi
rmdir $arcroot/$host &> /dev/null
rmdir $arcroot &> /dev/null
echo "Performing sftp operations for $user@$host.."
sftp -b "/usr/local/bin/$host/grablogs" $user@$host
rc=$?
if [ $rc != 0 ] ; then
echo "**WARNING** grablogs sftp for $host returned an error: $rc"
echo "**WARNING** grablogs sftp for $host returned an error: $rc"|mailx -s "Error in up grablogs sftp!" postmaster
exit $rc
fi
echo "Setting local file permissions.."
chmod 777 $home/inc/logr />
now=`date "+%Y.%m.%d-%H.%M"`
command -v fortune >/dev/null 2>&1 || { echo "Smile! It's real-time!"; exit 0; }
fortune
echo "grablogs for $host complete at $now"
exit 0
Welcome to corz.org!
Since switching hosts (I hope you are alright, Ed! Wherever you are …) quite a few things seems to be wonky.
Juggling two energetic boys (of very different ages) on Coronavirus lockdown, I'm unlikely to have them all fixed any time soon. Mail me! to prioritise!