root/floppyfw/files/passwd.sh
| Revision 1, 440 bytes (checked in by root, 6 years ago) |
|---|
| Line | |
|---|---|
| 1 | #!/bin/sh |
| 2 | |
| 3 | PW_F=./passwd |
| 4 | PW_L=13 |
| 5 | |
| 6 | PW="$1" |
| 7 | |
| 8 | [ "$PW" ] || { |
| 9 | echo "E: need a passwd argument" |
| 10 | exit 1 |
| 11 | } |
| 12 | |
| 13 | [ ${#PW} -eq $PW_L ] || { |
| 14 | echo "E: passwd argument length must be $PW_L" |
| 15 | exit 1 |
| 16 | } |
| 17 | |
| 18 | # tweak the passwd file with fall back, in case of a problem ;-) |
| 19 | mv $PW_F $PW_F.old |
| 20 | if sed -e "s,^\(root\):[^:]*:\(.*\)$,\1:$PW:\2," $PW_F.old > $PW_F |
| 21 | then |
| 22 | rm -f $PW_F.old |
| 23 | else |
| 24 | mv $PW_F.old $PW_F |
| 25 | fi |
| 26 | |
| 27 | exit 0 |
| 28 |
Note: See TracBrowser
for help on using the browser.