Here's how I do it in a script named /usr/bin/prevlogin:

#!/usr/bin/ksh
# Karl
# prevlogin, prevent logins
# place in /usr/bin

if [ $# -ge 1 ]
then
  a=`/bin/echo $1 | /usr/bin/cut -c1 | /usr/bin/tr YN yn`
  if [ "$a" = y ]
  then
    shift
    /bin/cp /etc/nologin.klp /etc/nologin
    chmod 444 /etc/nologin
  elif [ "$a" = n ]
  then
    if [ -f /etc/nologin ]
    then
       /bin/rm /etc/nologin
    fi
  else
    /bin/echo "Usage: prevlogin [yn] [message]"
    exit 2
  fi
else
  if [ -f /etc/nologin ]
  then
    /usr/bin/id | grep 'uid=0' > /dev/null
    if [ $? -ne 0 ]
    then
      /bin/cat /etc/nologin
        /bin/sleep 7
      exit 2
    fi
  fi
fi


## add to the end of /etc/profile
## after removing one # from each line

#PATH="$PATH:`cat /.uvhome`/bin"
#export PATH

## Track login usage
#`date >> ./loguse.$LOGNAME`
#`tail -20 ./loguse.$LOGNAME > ./temp.$LOGNAME`
#`cp ./temp.$LOGNAME ./loguse.$LOGNAME`
#`rm ./temp.$LOGNAME`

## The following line prevents logins if /etc/nologin is present
## AIX already checks for /etc/nologin, so this is redundant
#       .  /usr/bin/prevlogin
## End of prevlogin call

Contents of nologin.klp:


  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
  *              A T T E N T I O N    P L E A S E           *
  *   There is either System Maintenance or Month End in    *
  *   progress. Therefore, you will not be allowed to log   *
  *   in at this time. This notice will not be shown when   *
  *   it is okay to login and go back to work. Thank you.   *
  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *


On AIX the nologin file in /etc is removed on boot up. Be sure to
include this capability in rc.local (use the correct file) else you will
find as I have that users start referring to you as "evil IT guy".

Karl

On Fri, 2004-05-21 at 11:35, Anthony Dzikiewicz wrote:
> One flavor of unix we ran looked for an /etc/nologin file.  If it existed,
> it would print the contents of the message and not allow you to login.  When
> we moved off that particular unix, we lost that functionality.  This is a
> nice thing to have for reasons like you speak of.  So, we put a statement in
> the users .profile as such;
> if
>    test -r /etc/nologin
> then
>    cat /etc/nologin
>    exit
> fi
> 
> We created a Universe command called 'FENCE.UP' that creates the 'nologin'
> and a 'FENCE.DOWN' that deletes the 'nologin'.  Very simple and effective.
> Since you are on unix and not windows, you could probably do the same.
> 
>  -----Original Message-----
> From:         [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]  On Behalf Of Brutzman, Bill
> Sent: Friday, May 21, 2004 12:39 PM
> To:   '[EMAIL PROTECTED]'
> Subject:      [U2] Preventing Unix Login
> 
> We are getting file overflow error messages on our Sales Order files and I
> want to make sure that nobody can login as it is resizing.
> 
> Maybe I am overly concerned.
> 
> We are on UV 8.3.3 on HP-Unix v10.  Suggestions are welcome.
> 
> Bill Brutzman
> Manager, IT
> HK MetalCraft Mfg Corp
> PO Box 775
> 35 Industrial Road
> Lodi  NJ  07644-0775
> 
> 973.471.7770 x145 .voice
> 973.471.9666 .fax
> 
> www.hkMetalCraft.com
> 
> [demime 1.01d removed an attachment of type application/octet-stream which
> had a name of Brutzman, Bill.vcf]
> -------
> u2-users mailing list
> [EMAIL PROTECTED]
> http://www.u2ug.org/listinfo/u2-users
> -------
> u2-users mailing list
> [EMAIL PROTECTED]
> http://www.u2ug.org/listinfo/u2-users
-- 
Karl L. Pearson
Director of IT,
ATS Industrial Supply
Direct: 801-978-4429
Toll-free: 888-972-3182 x29
Fax: 801-972-3888
http://www.atsindustrial.com
[EMAIL PROTECTED]
-------
u2-users mailing list
[EMAIL PROTECTED]
http://www.u2ug.org/listinfo/u2-users

Reply via email to