2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-30 21:45:37 +00:00

[#2914] extended documentation with for loops in scripts

This commit is contained in:
Razvan Becheriu
2024-06-17 16:30:46 +03:00
parent 1b8b3592da
commit 6f7d97c654
2 changed files with 78 additions and 2 deletions

View File

@@ -85,7 +85,7 @@ An example of a script implementing all hook points is presented below:
::
#!/bin/bash
#!/bin/sh
unknown_handle() {
echo "Unhandled function call ${*}"
@@ -625,3 +625,39 @@ at 0.
LEASE6_PREFERRED_LIFETIME
LEASE6_PREFIX_LEN
LEASE6_TYPE
The leases4_committed hook point needs for loops to handle the list of addresses.
This can be achived in the following way:
::
leases4_committed() {
for i in $(seq 0 $((LEASES4_SIZE-1))); do
LEASE4_ADDRESS=$(eval "echo \$LEASES4_AT${i}_ADDRESS")
...
done
for i in $(seq 0 $((DELETED_LEASES4_SIZE-1))); do
DELETED_LEASE4_ADDRESS=$(eval "echo \$DELETED_LEASES4_AT${i}_ADDRESS")
...
done
exit 0
}
The leases6_committed hook point needs for loops to handle the list of addresses.
This can be achived in the following way:
::
leases6_committed() {
for i in $(seq 0 $((LEASES6_SIZE-1))); do
LEASE6_ADDRESS=$(eval "echo \$LEASES6_AT${i}_ADDRESS")
...
done
for i in $(seq 0 $((DELETED_LEASES6_SIZE-1))); do
DELETED_LEASE6_ADDRESS=$(eval "echo \$DELETED_LEASES6_AT${i}_ADDRESS")
...
done
exit 0
}

View File

@@ -101,7 +101,7 @@ the hook point.
An example of a script implementing all hook points is presented below.
@code
#!/bin/bash
#!/bin/sh
unknown_handle() {
echo "Unhandled function call ${*}"
@@ -666,6 +666,46 @@ LEASE6_TYPE
@endcode
The leases4_committed hook point needs for loops to handle the list of addresses.
This can be achived in the following way:
@code
leases4_committed() {
for i in $(seq 0 $((LEASES4_SIZE-1))); do
LEASE4_ADDRESS=$(eval "echo \$LEASES4_AT${i}_ADDRESS")
...
done
for i in $(seq 0 $((DELETED_LEASES4_SIZE-1))); do
DELETED_LEASE4_ADDRESS=$(eval "echo \$DELETED_LEASES4_AT${i}_ADDRESS")
...
done
exit 0
}
@endcode
The leases6_committed hook point needs for loops to handle the list of addresses.
This can be achived in the following way:
@code
leases6_committed() {
for i in $(seq 0 $((LEASES6_SIZE-1))); do
LEASE6_ADDRESS=$(eval "echo \$LEASES6_AT${i}_ADDRESS")
...
done
for i in $(seq 0 $((DELETED_LEASES6_SIZE-1))); do
DELETED_LEASE6_ADDRESS=$(eval "echo \$DELETED_LEASES6_AT${i}_ADDRESS")
...
done
exit 0
}
@endcode
@section libdhcp_run_scriptMTCompatibility Multi-Threading Compatibility
The Run Script hooks library is compatible with multi-threading.