iopsys-feed/dhcpmngr/files/etc/udhcpc.user.d/udhcpc_lease_start_time.user
Mohd Husaam Mehdi 9b7b0184c8 dhcpmngr: add dhcpmngr package to iopsys feed
* add Makefile
* move udhcpc.user.d script used for remaining dhcp lease time to
  this package
2024-05-08 12:33:41 +00:00

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