IT인/프로그래밍
cvs user 생성 자동 스크립트
Never4got10
2008. 3. 24. 02:09
# cvsuseradd
CVS 자체 계정생성
-----------------------------------------------------------------
#!/bin/ksh
CVSROOT=/sw/util/cvs/cvs_repository
echo "사용자 ID를 입력하세요 :\c"
read UID
if [ "$UID" = "" ]
then continue
fi
if grep "^$UID:" $CVSROOT/CVSROOT/passwd > /dev/null 2>&1
then
echo "사용자 ID $UID는 이미 있습니다. "
grep "^$UID:" $CVSROOT/CVSROOT/passwd
exit 2
fi
echo "사용자 이름을 영문으로 입력하세요 :\c"
read USRNM
if [ "$USRNM" = "" ]
then continue
fi
echo "패스워드를 입력하세요 (기본:1):\c"
read PSSWD
if [ "$PSSWD" = "" ]
then PSSWD="1"
fi
echo $UID:`./crypt $PSSWD`:cvsadm>> $CVSROOT/CVSROOT/passwd
echo $UID:$USRNM >> $CVSROOT/CVSROOT/tune/userinfo
#echo $UID >> $CVSROOT/CVSROOT/tune/readers
#echo $UID >> $CVSROOT/CVSROOT/tune/writers
# if ls $CVSROOT/CVSROOT/tune/readers
# then
# echo $UID >> $CVSROOT/CVSROOT/tune/readers
# fi
if ls $CVSROOT/CVSROOT/tune/writers
then
echo $UID >> $CVSROOT/CVSROOT/tune/writers
fi
echo "cvser add가 성공했습니다."
-------------------------------------------------------------
echo $UID:`./crypt $PSSWD`:cvsadm>> $CVSROOT/CVSROOT/passwd 에서 cvsadm은 실제
계정을 생성할 수 있는 UNIX 계정이어야 한다.
#cvsuserdel
-------------------------------------------------------------
#!/bin/ksh
CVSROOT=/sw/util/cvs/cvs_repository
WRK=$CVSROOT/CVSROOT
echo "삭제할 계정을 입력하세요:\c "
read UID
if [ "$UID" = "" ]
then continue
fi
set echo off
if grep "^$UID:" $WRK/passwd ; then
grep -v "^$UID:" $WRK/passwd > $WRK/tmp
mv -f $WRK/tmp $WRK/passwd
grep -v "^$UID:" $WRK/tune/userinfo > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/tune/userinfo
grep -v "^$UID" $WRK/tune/readers > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/tune/readers
grep -v "^$UID" $WRK/tune/writers > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/tune/writers
if ls $WRK/tune/readers
then
grep -v "^$UID" $WRK/tune/readers > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/readers
fi
if ls $WRK/tune/writers
then
if ls $WRK/tune/writers.bak
then
grep -v "^$UID" $WRK/tune/writers > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/writers
fi
fi
echo "cvser delelte가 성공했습니다."
else
echo "$WRK/passwd 에 없는 계정입니다. "
fi
-------------------------------------------------------------------------
#cvsusers
-------------------------------------------------------------------------
CVSROOT=/sw/util/cvs/cvs_repository
cat $CVSROOT/CVSROOT/tune/userinfo
-------------------------------------------------------------------------
#crypt
패스워드 암호화
-------------------------------------------------------------------------
#!/usr/bin/perl
# Initialize the random number generator engine.
#
srand( time() );
# Generate a single random letter/digit to be used for the encryption key.
#
my $randLetter = "(int(rand( 26 )) + (int(rand( 1 ) + 0.5) % 2 ? 65 : 97))";
# The encryption key needs two letters/digits, so simply duplicate the
# random character we have already generated.
#
my $salt = sprintf( "%c%c", eval $randLetter, eval $randLetter );
# Get the first command line argument (should be given wrapped up in
# quotation marks -- remember to escape any shell-specific characters,
# such as the exclamation point).
#
my $plainText = shift;
# Now that we have the text to encrypt and a key to use for the encryption,
# generate the encrypted password then write it to standard output.
#
my $cryptText = crypt( $plainText, $salt );
printf "${cryptText}\n";
----------------------------------------------------------------------------
모든 파일들은 실행권한을 주어야 함 chmod 755
CVS 자체 계정생성
-----------------------------------------------------------------
#!/bin/ksh
CVSROOT=/sw/util/cvs/cvs_repository
echo "사용자 ID를 입력하세요 :\c"
read UID
if [ "$UID" = "" ]
then continue
fi
if grep "^$UID:" $CVSROOT/CVSROOT/passwd > /dev/null 2>&1
then
echo "사용자 ID $UID는 이미 있습니다. "
grep "^$UID:" $CVSROOT/CVSROOT/passwd
exit 2
fi
echo "사용자 이름을 영문으로 입력하세요 :\c"
read USRNM
if [ "$USRNM" = "" ]
then continue
fi
echo "패스워드를 입력하세요 (기본:1):\c"
read PSSWD
if [ "$PSSWD" = "" ]
then PSSWD="1"
fi
echo $UID:`./crypt $PSSWD`:cvsadm>> $CVSROOT/CVSROOT/passwd
echo $UID:$USRNM >> $CVSROOT/CVSROOT/tune/userinfo
#echo $UID >> $CVSROOT/CVSROOT/tune/readers
#echo $UID >> $CVSROOT/CVSROOT/tune/writers
# if ls $CVSROOT/CVSROOT/tune/readers
# then
# echo $UID >> $CVSROOT/CVSROOT/tune/readers
# fi
if ls $CVSROOT/CVSROOT/tune/writers
then
echo $UID >> $CVSROOT/CVSROOT/tune/writers
fi
echo "cvser add가 성공했습니다."
-------------------------------------------------------------
echo $UID:`./crypt $PSSWD`:cvsadm>> $CVSROOT/CVSROOT/passwd 에서 cvsadm은 실제
계정을 생성할 수 있는 UNIX 계정이어야 한다.
#cvsuserdel
-------------------------------------------------------------
#!/bin/ksh
CVSROOT=/sw/util/cvs/cvs_repository
WRK=$CVSROOT/CVSROOT
echo "삭제할 계정을 입력하세요:\c "
read UID
if [ "$UID" = "" ]
then continue
fi
set echo off
if grep "^$UID:" $WRK/passwd ; then
grep -v "^$UID:" $WRK/passwd > $WRK/tmp
mv -f $WRK/tmp $WRK/passwd
grep -v "^$UID:" $WRK/tune/userinfo > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/tune/userinfo
grep -v "^$UID" $WRK/tune/readers > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/tune/readers
grep -v "^$UID" $WRK/tune/writers > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/tune/writers
if ls $WRK/tune/readers
then
grep -v "^$UID" $WRK/tune/readers > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/readers
fi
if ls $WRK/tune/writers
then
if ls $WRK/tune/writers.bak
then
grep -v "^$UID" $WRK/tune/writers > $WRK/tune/tmp
mv -f $WRK/tune/tmp $WRK/writers
fi
fi
echo "cvser delelte가 성공했습니다."
else
echo "$WRK/passwd 에 없는 계정입니다. "
fi
-------------------------------------------------------------------------
#cvsusers
-------------------------------------------------------------------------
CVSROOT=/sw/util/cvs/cvs_repository
cat $CVSROOT/CVSROOT/tune/userinfo
-------------------------------------------------------------------------
#crypt
패스워드 암호화
-------------------------------------------------------------------------
#!/usr/bin/perl
# Initialize the random number generator engine.
#
srand( time() );
# Generate a single random letter/digit to be used for the encryption key.
#
my $randLetter = "(int(rand( 26 )) + (int(rand( 1 ) + 0.5) % 2 ? 65 : 97))";
# The encryption key needs two letters/digits, so simply duplicate the
# random character we have already generated.
#
my $salt = sprintf( "%c%c", eval $randLetter, eval $randLetter );
# Get the first command line argument (should be given wrapped up in
# quotation marks -- remember to escape any shell-specific characters,
# such as the exclamation point).
#
my $plainText = shift;
# Now that we have the text to encrypt and a key to use for the encryption,
# generate the encrypted password then write it to standard output.
#
my $cryptText = crypt( $plainText, $salt );
printf "${cryptText}\n";
----------------------------------------------------------------------------
모든 파일들은 실행권한을 주어야 함 chmod 755