add make.profile script
git-svn-id: https://svn.disconnected-by-peer.at/svn/linamh/trunk/genlink@2633 6952d904-891a-0410-993b-d76249ca496b
This commit is contained in:
@@ -1,49 +1,12 @@
|
||||
#!/usr/bin/expect -f
|
||||
# Password change shell script, tested on Linux and FreeBSD
|
||||
# ----------------------------------
|
||||
# It need expect tool. If you are using Linux use following command
|
||||
# to install expect
|
||||
# apt-get install expect
|
||||
# FreeBSD user can use ports or following command:
|
||||
# pkg_add -r -v expect
|
||||
# ----------------------------------
|
||||
# If you are using linux change first line
|
||||
# From:
|
||||
#!/usr/local/bin/expect -f
|
||||
# To:
|
||||
#!/usr/bin/expect -f
|
||||
# -----------------------------------------------
|
||||
# Copyright (c) 2006 nixCraft project
|
||||
# This script is licensed under GNU GPL version 2.0 or above
|
||||
# -------------------------------------------------------------------------
|
||||
# This script is part of nixCraft shell script collection (NSSC)
|
||||
# Visit http://bash.cyberciti.biz/ for more information.
|
||||
# -------------------------------------------------------------------------
|
||||
# display usage
|
||||
if {$argc!=2} {
|
||||
send_user "usage: $argv0 username password \n"
|
||||
exit
|
||||
}
|
||||
# script must be run by root user
|
||||
set whoami [exec id -u]
|
||||
if {$whoami!=0} {
|
||||
send_user "You must be a root user to run this script\n"
|
||||
exit
|
||||
}
|
||||
#
|
||||
set timeout -1
|
||||
match_max 100000
|
||||
# stopre password
|
||||
# wrapper to make passwd(1) be non-interactive
|
||||
# username is passed as 1st arg, passwd as 2nd
|
||||
# Executable only by root
|
||||
|
||||
set password [lindex $argv 1]
|
||||
# username
|
||||
set user [lindex $argv 0]
|
||||
# opem shell
|
||||
spawn $env(SHELL)
|
||||
# send passwd command
|
||||
send -- "passwd $user\r"
|
||||
expect "assword:"
|
||||
spawn passwd [lindex $argv 0]
|
||||
expect "password:"
|
||||
send "$password\r"
|
||||
expect "assword:"
|
||||
expect "password:"
|
||||
send "$password\r"
|
||||
send "\r"
|
||||
expect eof
|
||||
Reference in New Issue
Block a user