Tuesday, September 27, 2005

 

/etc/motd

#!/bin/bash
#
# motd This shell script takes care of /etc/motd
#
# chkconfig: 2345 99 05
# description: echo system hardware into motd
# processname: motd
# config: /etc/motd
#
# karl@webmedianow.com #############################################
# karl@singlefin.net #############################################
# Tue May 10 12:06:40 PDT 2005

OrigMotd ()
{
if [ ! -f /etc/motd.orig ]; then
cp /etc/motd /etc/motd.orig
fi
}

LoginCopyright ()
{
if [ -f /etc/redhat-release ]; then
cat /etc/redhat-release > /etc/motd
echo
"-------------------------------------------------------" >> /etc/motd
elif [ -f /etc/debian_version ]; then
VERSION=`cat /etc/debian_version`
echo "Debian GNU/Linux $VERSION" > /etc/motd
echo
"-------------------------------------------------------" >> /etc/motd

else
echo
"-------------------------------------------------------" > /etc/motd
fi
echo "(TM) 2001 to the Present SingleFin.Net" >> /etc/motd
}

ServerInfo ()
{
set -- `/bin/uname -a`

SYSNAME=`/bin/uname -a | awk '{print $1}'`
NODENAME=`/bin/uname -a | awk '{print $2}'`
KERNEL=`/bin/uname -a | awk '{print $3}'`
KERNELREV=`/bin/uname -a | awk '{print $4}'`
KDAYOFWEEK=`/bin/uname -a | awk '{print $5}'`
KMONTH=`/bin/uname -a | awk '{print $6}'`
KDAY=`/bin/uname -a | awk '{print $7}'`
KTIME=`/bin/uname -a | awk '{print $8}'`
KTMZ=`/bin/uname -a | awk '{print $9}'`
KYEAR=`/bin/uname -a | awk '{print $10}'`
KMACHINE=`/bin/uname -a | awk '{print $11}'`
PROCESSOR=`/bin/uname -a | awk '{print $12}'`
HWPLATFORM=`/bin/uname -a | awk '{print $13}'`
SWOS=`/bin/uname -a | awk '{print $14}'`

HOSTNAME=`hostname`
DNSDOMAINNAME=`hostname -d`
DOMAINNAME=`hostname -y` ##same as "domainname" cmd
MEMTOTAL=`cat /proc/meminfo | grep '^MemTotal' | awk '{print $2}'`
MT=`cat /proc/meminfo | grep '^MemTotal' | awk '{print $3}'`
SWAPT=`cat /proc/meminfo | grep '^SwapTotal:' | awk '{print $2}'`
ST=`cat /proc/meminfo | grep '^SwapTotal:' | awk '{print $3}'`

PMODEL=`cat /proc/cpuinfo | grep '^model name' | awk '{print $4
$5 $6}' | head -1`
PMHZ=`cat /proc/cpuinfo | grep '^cpu MHz' | awk '{print $4}'|
sed -e 's/\.[0-9]*//g' | head -1`
PVENDOR=`cat /proc/cpuinfo | grep '^vendor_id' | awk '{print
$3}' | head -1`
PNUMS=`cat /proc/cpuinfo | grep '^processor' | wc -l | awk
'{print $1}' | head -1`

echo
"-------------------------------------------------------" >> /etc/motd
echo "Hostname: $HOSTNAME" >> /etc/motd
echo "DNS Domain: $DNSDOMAINNAME NIS/YP: $DOMAINNAME" >>
/etc/motd
echo "OS type: $SYSNAME $KMACHINE" >> /etc/motd
echo "Kernel: $KERNEL $KTIME" >> /etc/motd
echo "Processor: $PNUMS $PVENDOR ${PMHZ}MHz $PMODEL"
>> /etc/motd
echo "Memory: $MEMTOTAL $MT Swap: $SWAPT
$ST" >> /etc/motd
echo
"-------------------------------------------------------" >> /etc/motd

}

IPInfo()
{
ifconfig|grep "inet addr" | sed -e /127.0.0.1/d | sed -e "s/ inet //" >> /etc/motd
}

OrigMotd
LoginCopyright
ServerInfo
IPInfo


 

rc.swapfile

#!/bin/sh
# rc.swapfile This shell script takes care swapfile
#
# chkconfig: 2345 99 05
# description: mount a swapfile
# processname: rc.swapfile
# config: /swapfile

# karl@singlefin.net
# Last Update: Wed Aug 31 20:21:14 PDT 2005

DIR=/var

if [ -f $DIR/swapfile ]; then
echo "swapon $DIR/swapfile"
swapon -p 1 $DIR/swapfile
fi

if [ ! -f $DIR/swapfile ]; then
echo "creating swapfile. Please wait."
dd if=/dev/zero of=$DIR/swapfile bs=1M count=4096
sleep 2
chmod 0600 $DIR/swapfile
sleep 2
mkswap $DIR/swapfile
sleep 3
swapon -p 1 $DIR/swapfile
echo "...done, $DIR/swapfile now exists"
fi

exit 0


Sunday, September 25, 2005

 

linux cu

#baud=38400
baud=9600

if [ x$2 != x ]; then
baud=$2
fi

echo -ne "\033]0;$1: cu -s $baud -l /dev/ttyS$1\007"
cu -s $baud -l /dev/ttyS$1

echo -ne "\033]0;Disconnected from $1.\007"


Tuesday, September 13, 2005

 

admin.sh

odin:~/bin# cat admin.sh
#!/bin/sh

securehost="root@10.0.0.33"

compare() {

THISPASS=`grep root: /etc/shadow`
#echo $THISPASS
NEWPASS=`ssh $securehost 'cat /security/newpass'`
#echo $NEWPASS

if [ ${THISPASS} = ${NEWPASS} ];then
echo "SAME"
exit 0
else
echo "DIFFER"
doshadow
fi

}

gennewkey() {
if [ -f ~/.ssh/id_rsa.pub ]; then
echo "RSA public key OK."
else
ssh-keygen -t rsa -f ~/.ssh/id_rsa -N ""
cat ~/.ssh/id_rsa.pub | ssh $securehost "cat >> .ssh/authorized_keys"
fi
}

doshadow () {
cp /etc/shadow /etc/shadow.full.bk
sed -e /^root:/d /etc/shadow.full.bk > /etc/shadow.noroot
echo $NEWPASS > /etc/shadow
cat /etc/shadow.noroot >> /etc/shadow
rm /etc/shadow.full.bk
rm /etc/shadow.noroot
}

gennewkey
compare

exit 0

odin:~/bin#


Tuesday, September 06, 2005

 

windows xp shared folder NoSharedDocuments

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies

Select the "Explorer" folder.

Go to *Edit*, *New*, then "DWORD Value".

Name the new value "NoSharedDocuments".

Double click the new value and in the Edit DWORD Value dialog box,
change the value data field to "1".

Reboot your computer for the change take effect.

Bye bye Shared Documents folder.


 

Windows XP Tip of the Day - Tip #593: Get Rid of Shared Documents

*Windows XP Tip of the Day*

*Tip #593: Get Rid of Shared Documents*

New to Windows XP is a "Shared Documents" folder that appears in My
Computer. This is really just a pointer to another area on disk. You
can keep this from appearing by deleting the following subkey from the
Registry:

*Hive*: HKEY_LOCAL_MACHINE
*Key*: SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\My
Computer\NameSpace\DelegateFolders
*Subkey:* {59031a47-3f72- 44a7-89c5-5595fe6b30ee}

Delete the whole Subkey and all that it contains. You may wish to
right-click this subkey and export it before deleting it, just to be
safe. This also will prevent the current users "My Documents" from
showing up in the same area of My Computer.


This page is powered by Blogger. Isn't yours?