[mdlug] Install event - Dearborn library computers?

Aaron Kulkis akulkis00 at gmail.com
Wed Apr 30 20:30:22 EDT 2014


gib at juno.com wrote:
> I was thinking that we could do an install event.  Usually that's where everyone brings in devices to install new software.  We typically do Linux.  Maybe we could install Linux on some of the Dearborn library computers.
>
> I see the library has some type of software to limit the time on the system and to restart fresh (clean system).  I'm not sure how we would do that.
>

It's fairly simple:

Let's say that the library user's login name is "libuser" or something  like that.


Setup -- a libuser account skeleton directory archived in ~libuser/../libuser.tar.


Script to create the scripts

Run this as root, not the user, so that root owns the .bash_login and watchdog files,
and has write permission in /home (or where-ever) to create ~libuser/../libuser.tar)


CAVEAT: NOT TESTED.

Make a trial account, and then when good, go live with that account.
The following assumes that the account name will be "libuser"

__________SCRIPT STARTS BELOW _____________
#!/bin/bash
BASH_LOGIN=~libuser/.bash_login

# 3600 is time in seconds = 1 hour before user is auto-logged-out
cat >> $BASH_LOGIN  << __END_OF_HEREDOC__

# start watchdog process in background
LIMIT=3600
GRACE=300
~/bin/watchdog $LIMIT $GRACE &
# make sure that all processses started in .profile are at least 5 seconds younger than watchdog
sleep 5

__END_OF_HEREDOC__
chmod 555 $BASH_LOGIN

BASH_LOGOUT=~libuser/.bash_logout
cat >> $BASH_LOGOUT << __END_OF_HEREDOC_BASH_LOGOUT
# get PID of watchdog process
WPID=`ps -ef | grep watchdog | grep -v grep | awk ' { print $2 } ' `
# AND KILL IT WITH FIRE!
kill -9 $WPID

# REMAKE HOME DIRECTORY
#
# 1. Remove everything except for ~/. and ~/..
cd ~
rm -rf * .?*
# 2. Install fresh copy
cd ..
tar xvf ~libuser.tar
  __END_OF_HEREDOC_BASH_LOGOUT


mkdir ~libuser/bin
WATCHDOG=~libuser/bin/watchdog

cat > $WATCHDOG << __END_OF_HDOC_WATCHDOG__
#!/bin/bash
#### WATCHDOG process to kill user processes
# usage: watchdog max-time
TIME_LIMIT=$1
COURTESY_TIME=$2
GRACE_TIME=5
${USER:=`whoami`}

WARN_TIME=(( $TIME_LIMIT - $COURTESY_TIME ))
COURTESY_MIN=(( $COURTESY_TIME / 60 ))
COURTESY_SEC=(( $COURTESY_TIME % 60 ))
	# Basic login limit

$LIMIT_GRACE=(( $TIME_LIMIT + $GRACE_TIME ))
$LIMIT_2GRACE=(( $TIME_LIMIT + (( 2 * $GRACE_TIME)) ))

echo "You will be automatically logged off in " $TIME_LIMIT \
" seconds (" (( $IME_LIMIT / 60 )) " minutes and " \
(( $IME_LIMIT % 60 )) " seconds)." > /dev/tty

#START COUNTDOWN CLOCK
sleep $WARN_TIME
echo "Courtesy warning: You will be automatically logged off in " \
	$COURTESY_TIME " seconds (" $COURTESY_MIN " minutes and " $COURTESY_SEC \
	" seconds)." > /dev/tty
sleep $COURTESY_TIME
echo "Your time is up." > /dev/tty


#start killing user processes started AFTER watchdog was started
# start gracefully by sending signals that can be caught
killall -u $USER -younger-than $TIME_LIMIT -s TERM
sleep $GRACE_TIME
killall -u $USER -younger-than $LIMIT_GRACE -s HUP
sleep $GRACE_TIME
# any remaining
killall -u $USER -younger-than $LIMITability_2GRACE -s KILL
# all of user's processes should now be dead

# REMAKE HOME DIRECTORY
#
# 1. Remove everything except for ~/. and ~/..
cd ~
rm -rf * .?*
# 2. Install fresh copy
cd ..
tar xvf ~libuser.tar

# Now complete user logout
killall -u $USER -s HUP

__END_OF_HDOC_WATCHDOG__


# make watchdog script executable and non-writeable.
chmod 555 $WATCHDOG
cd ~libuser/..
tar cvf libuser.tar ~libuser


# __________END OF SCRIPT_____________



Note: NOT tested.  Run, debug, repeat until done.

> I'd also like to suggest we could build some new computers for the library.
> Here is a list of the MicroCenter parts for a total of about $330 for each computer:
>
> Memory Ballistic Sport 4G 1600 $44.99.
> Case Diamond mid-tower with 400 watt power suppliy $29.99.
> CPU AMD FX Black Edition 3.9 GHZ six core AM3+ $129.99.
> Motherboard  MSI 970A-G43 $59.99.
> Harddrive SATA 8GB $14.99.
> Keyboard USB 3.99.
> Mouse $6.99.

Microcenter is selling a USB Keyboard + USB mouse (2-button_ for $7.99)

> Web Cam $8.99.
> Video card XFX AMD Radon HD 5450 1GB 2.1 $17.99.
>
> Monitor would be an additional $100. We could reuse some old parts to save money.
>
> Perhaps we could get volunteers to assemble them and install software.
>
> ____________________________________________________________
> Old School Yearbook Pics
> View Class Yearbooks Online Free. Search by School & Year. Look Now!
> http://thirdpartyoffers.juno.com/TGL3131/535ee72b4cc2b672b491cst01vuc
> _______________________________________________
> mdlug mailing list
> mdlug at mdlug.org
> http://mdlug.org/mailman/listinfo/mdlug
>



More information about the mdlug mailing list