#!/bin/sh -e

# Copyright (C) 2001, 2002, 2003, 2004 Joost van Baal
#
# This file is part of systraq.  Systraq 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.  You should have received a copy of
# the GNU General Public License along with this file (see COPYING).

# systraq - run some sysadmin commands to see what's going on

uptime
echo
free
echo
df -h
echo
echo 'last -a | head -15'
last -a | head -15
echo
echo lastlog
lastlog
echo
echo netstat -a --inet
netstat -a --inet
echo
echo ps auxwww
ps auxwww
echo
for h in `cut -d: -f6 /etc/passwd | sort -u`
do
    [ -d $h ] && HOMES="$HOMES $h"
done

SH_files="/etc/profile /etc/csh.cshrc /etc/csh.login /etc/bash.bashrc \
 /etc/zshenv /etc/zprofile /etc/zshrc /etc/zlogin /etc/zlogout \
 /etc/zsh-beta/zshenv /etc/zsh-beta/zprofile /etc/zsh-beta/zshrc \
 /etc/zsh-beta/zlogin /etc/zsh-beta/zlogout"
for f in $SH_files
do
    [ -f $f ] && SH_FILES="$SH_FILES $f"
done

SH_HOME=".profile .cshrc .tcshrc .login .logout .bash_profile .bashrc \
 .bash_login .bash_logout .klogin .zshenv .zprofile .zshrc .zlogin .zlogout"

HOMES="$HOMES /etc/skel"
for h in $HOMES
do
    for f in $SH_HOME
    do
        [ -f $h/$f ] && SH_FILES="$SH_FILES $h/$f"
    done
done

echo
echo 'check if umask (002 or 022 please) and PATH (no dot please) are sane'
for f in $SH_FILES
do
    if egrep umask\|PATH $f | grep -v '^#' | grep -v '^umask 0[02]2$' >/dev/null
    then
        echo 
        echo found in file $f:
        egrep umask\|PATH $f | grep -v '^#' | grep -v '^umask 0[02]2$'
    fi
done

if test -x "`which debsums`"
then
    echo
    echo 'debsums -s'
    debsums -s 2>&1 || true
else
    echo
    echo 'cannot check md5sums, please install debsums'
fi

#
localmd5sums=/usr/local/var/state/systraq/systraq.md5sums
if test -f $localmd5sums
then
    echo
    echo 'local md5sums'
    md5sum -c $localmd5sums 2>&1 || true
fi

echo "-- "
echo '$Id: systraq,v 1.9 2004/10/15 07:54:34 joostvb Exp $'

