mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2025-12-10 07:44:50 +01:00
* add Makefile * move udhcpc.user.d script used for remaining dhcp lease time to this package
14 lines
480 B
Bash
14 lines
480 B
Bash
#!/bin/sh
|
|
|
|
leasestarttime="$(awk -F'.' '{print $1}' /proc/uptime 2> /dev/null)"
|
|
target_file=/tmp/dhcp_client_info
|
|
target_str="$INTERFACE $lease $leasestarttime"
|
|
|
|
# if this interface is present in file, then replace it
|
|
if grep -q "$INTERFACE" "$target_file" 2> /dev/null; then
|
|
# replace the whole line if pattern matches
|
|
sed -i "/${INTERFACE}/c\\${target_str}" "$target_file"
|
|
else
|
|
# interface info was not present, append it to the file
|
|
echo "$target_str" >> "$target_file"
|
|
fi
|