|
Revision 1, 0.8 KB
(checked in by root, 6 years ago)
|
|
First post
|
| Line | |
|---|
| 1 | #!/bin/sh |
|---|
| 2 | # |
|---|
| 3 | # This shell script converts /etc/ethers to preassigned leases in |
|---|
| 4 | # /var/udhcpd.leases. It's used to reserve IPs for certain hosts |
|---|
| 5 | # by making udhcpd think it has already given a lease to the host. |
|---|
| 6 | # Run this before starting udhcpd. |
|---|
| 7 | # |
|---|
| 8 | # The input format is: |
|---|
| 9 | # mac-address ip-address |
|---|
| 10 | # |
|---|
| 11 | # Comment lines and blank lines are ignored |
|---|
| 12 | # |
|---|
| 13 | while m=i=j= && read m i j |
|---|
| 14 | do |
|---|
| 15 | case "$m" in |
|---|
| 16 | ""|\#*) continue |
|---|
| 17 | ;; |
|---|
| 18 | esac |
|---|
| 19 | case "$i" in |
|---|
| 20 | "") continue |
|---|
| 21 | ;; |
|---|
| 22 | esac |
|---|
| 23 | a=$(echo $m | sed -e 's/:/ 0x/g' -e 's/^/0x/') |
|---|
| 24 | b=$(echo $i | sed 's/\./ /g') |
|---|
| 25 | s=$(printf '\\%03o\\%03o\\%03o\\%03o\\%03o\\%03o\\0\\0\\0\\0\\0\\0\\0\\0\\0\\0\\%03o\\%03o\\%03o\\%03o\\177\\\ |
|---|
| 26 | 377\\377\\177' $a $b) |
|---|
| 27 | echo -ne $s 1>&4 |
|---|
| 28 | done < /etc/ethers 4> /var/state/udhcpd.leases |
|---|