您的位置:软件测试 > 开源软件测试 > 开源配置管理工具 > cvs
CVS管理脚本
作者:网络转载 发布时间:[ 2013/1/18 13:49:31 ] 推荐标签:

  
  4. 修改密码程序源码
  
  [root@linux cvs]# cat cvspasswd
  
  #!/bin/sh
  
  ##############################################################
  
  # Script to cvs passwd
  
  # File:/root/admintool
  
  ##############################################################
  
  # Setup environment for script execution
  
  ENVS="`pwd`"/envs
  
  if [ -f $ENVS ]; then
  
  . $ENVS
  
  else
  
  CVSROOT=/cvsroot/CVSROOT
  
  CVSUSER=$1
  
  CVSPASS=$2
  
  # echo "The file exist."
  
  # exit 0
  
  fi
  
  cvspasswd() {
  
  isExists=`gawk -F: '$1=="'$CVSUSER'"{print $1}' $CVSROOT/passwd`
  
  # echo $isExists
  
  if [ "$CVSUSER" = "$isExists" ]; then
  
  # echo "true"
  
  adduser $CVSUSER -g nobody -s /dev/null -d /tmp
  
  echo "$CVSUSER:$CVSPASS"|chpasswd
  
  SDPASS=`gawk -F: '$1=="'$CVSUSER'"{print $2}' /etc/shadow`
  
  DLINE=`grep -n "$CVSUSER>" $CVSROOT/passwd|gawk -F: '{print $1}'`
  
  SYSUSER=`grep "$CVSUSER>" $CVSROOT/passwd|gawk -F: '{print $3}'`
  
  mv -f $CVSROOT/passwd $CVSROOT/passwd.old
  
  sed $DLINE'd' $CVSROOT/passwd.old>>$CVSROOT/passwd
  
  echo $CVSUSER:$SDPASS:$SYSUSER>>$CVSROOT/passwd
  
  userdel $CVSUSER
  
  # echo $SDPASS,$DLINE,$SYSUSER
  
  else
  
  echo "$0 : user $1 does not exist"
  
  fi
  
  }
  
  if [ -z $1 ]; then
  
  echo "Usage: $0 [cvsuser] [newpassword] "
  
  echo " $0 chen 123456"
  
  exit 0
  
  else
  
  cvspasswd
  
  exit 1
  
  fi
  
  exit 1
  
  [root@linux cvs]#

上一页1234下一页
软件测试工具 | 联系我们 | 投诉建议 | 诚聘英才 | 申请使用列表 | 网站地图
沪ICP备07036474 2003-2017 版权所有 上海泽众软件科技有限公司 Shanghai ZeZhong Software Co.,Ltd