-   Programming (
-   -   Wrapper needed for BASH Script (

outspoken 01-12-2005 09:04 AM

Wrapper needed for BASH Script
The comments have been made on what is needed, trying to figure out how to get this thing to be functional.

Min=7      # stops the users from changing their password for 7 days after a new password is set
Max=180    # 180 days after the password is set it expires
Warn=7      # 7 days warning about a password expiration
Inactive=60 # User account will expire 30 days after the password has expired

# On new systems:
if [ $NEWSYS ];then
        useradd -D -f $Inactive

# New users
if [ $NEWUSER ];then
        useradd -f $Inactive -c $GCOS $USER -k $SKEL_DIR
        passwd -n $Min -x $Max -w $Warn -i $Inactive $USER

# Force a password change by setting the last password changed date to 2000-01-01
# and the days between changes as 180
if [ $FORCE ];then
        DATE="2004-05-01" #need a routine that subtracts $Max + 1 days from today's date
        DATE=`./ $Max`;
        passwd -i $Inactive -x $Max $USER #prevents locking the account
        chage -d $DATE $USER #last password change

#!/usr/bin/perl -w
#Calculate the number of days in the past
#Does not account for Daylight savings time (I think)
use strict;

use POSIX qw/strftime/;

my $DaysFactor = 60 * 60 * 24;  #Number of seconds in  a day
my $Days = 0;
$Days = $ARGV[0] if $ARGV[0];
print strftime('%Y-%m-%d',localtime( time - ($DaysFactor * $Days)) );

All times are GMT -5. The time now is 04:10 PM.