#!/bin/sh # # /etc/rc.d/rc.info # # maintain machine info record # adapted from a Vector Linux rc. routine # # call with "start" for startup, "stop" for shutdown # # ;o) # where to keep the system record.. record_file=/var/log/system.record # if you don't have a custom logo, comment this out # or better yet, make one! it's easy. logo="-L 8" # *** I M P O R T A N T *** This wipes any changes you make to /etc/issue, # /etc/issue.net, and /etc/motd, WITH EACH BOOT! but they are very cool. # To enable these, set to 1, to disable, set to zero do_motd=1 do_issue=1 do_issue_net=1 # init.. this_host=`cat /etc/HOSTNAME` boot_count=${boot_count:-0} total_uptime=0 longest_uptime=0 # the functions.. view_info() { echo echo "current system record.." echo cat $record_file echo exit 0 } read_info() { . ${record_file} } info_start() { boot_count=$(( ${boot_count} + 1 )) ## login message with oshi logo text.. [requires custom linux_logo] if [ "$install_date" = '' ]; then install_date="[unknown]"; fi if [ $do_motd = 1 ]; then linux_logo ${logo} -t "$this_host since $install_date" > /etc/motd fi if [ $do_issue = 1 ]; then linux_logo ${logo} -t "$this_host since $install_date" > /etc/issue fi if [ $do_issue_net = 1 ]; then linux_logo ${logo} -t "$this_host since $install_date" > /etc/issue.net fi } info_stop() { uptime=`cat /proc/uptime | cut -f 1 -d '.'` total_uptime=$(( ${total_uptime} + ${uptime} )) if [ ${uptime} -gt ${longest_uptime} ]; then longest_uptime=${uptime} fi } info_main() { echo "updating system record.." echo cat<< EOF > ${record_file} # system history.. install_date="$install_date" boot_count="$boot_count" total_uptime="$total_uptime" longest_uptime="$longest_uptime" last_update="`date`" EOF } if [ -r ${record_file} ]; then read_info else install_date="`date`" info_main echo echo "new record created" exit 0 fi case "$1" in start|begin|go) read_info info_start info_main ;; stop|end|halt) read_info info_stop info_main ;; view|v|-v) view_info ;; *) echo "usage $0 start|stop" ;; esac