#!/bin/bash
#
# This script is used to rotate the push_button log files.
#

this_script=$(basename $0)

SYSLOG_ERR="logger -s -p USER.ERR  -t $this_script"

# --- main --------------------------------------------------------------------

if [ "$(whoami)" != "root" ] ; then
    $SYSLOG_ERR "must be run as root"
    exit 1
fi

dump_file=$1

# If there is already a dump_file, then mark it as the previous
# (this will overwrite any existing previous file)
if [ -f $dump_file ] ; then
    mv $dump_file $dump_file.prev
fi

# Create an empty dump_file and set the user group to leosdiag.
touch $dump_file
chown root:leosdiag $dump_file
