Tiny Core Base > TCB Q&A Forum

Quickly release IP

(1/1)

CFH:
We are doing a large scale deployment of computers to replace some older ones.  Part of the process involves releasing the IP address on the OLD PC before disconnecting it.  Currently, this means logging into Win7 as administrator, opening a command prompt and typing IPCONFIG /RELEASE - a slow process, and it requires the admin password.

Surely this is a perfect job for TinyCore Base!

I have very limited Linux experience, but am learning a lot through this project.  I just need a small script that will boot into a linux CLI, show the currently assigned IP address (IFCONFIG ETH0), and prompt the user to confirm that they want to release the IP.  From what I can tell, the udhcpc term to send a DHCP_RELEASE command is
--- Code: ---killall -SIGUSR2 udhcpc
--- End code ---

I've tried to add "IFCONFIG ETH0" to the end of the APPEND line in the ISOLINUX.CFG file but it doesn't display anything after booting to the TinyCore prompt.  I've also tried "postexec='ifconfig eth0'" to no avail. 

Would someone be able to assist me with some of the coding here?  Many thanks...

bmarkus:
Proper solution is managing the DHCP server, not at client side.

CFH:
I completely agree, but my company is on contract with a large bank and I just don't have the clout to steer that large a ship.  The ipconfig/release requirement is in the procedure documents that they authored/authorized.  Any help is appreciated...

CFH:
Just to follow up - I have completed the script to do what I wanted, and learned so much about TinyCore and Linux.  Here it is:
/opt/bootsync.sh

--- Code: ---#!/bin/sh -e
# put other system startup commands here
/usr/bin/sethostname box
/opt/bootlocal.sh &

clear
echo "Initializing Network Connection - Please Wait..."
echo ""

# Display IP address once available
CNT=0
until ifconfig | grep -q Bcast
do
[ $((CNT++)) -gt 60 ] && break || sleep 1
done
if [ $CNT -le 60 ]
then
CNT=0
ifconfig eth0
fi

echo "Network Initialized."
echo ""
sleep 1

# Release IP address
echo "Press any key to release IP address"
read -n 1 -p "Or 'x' to Exit..." XX
if [ "$XX" = 'x' -o "$XX" = 'X' ]; then
exit 0
else
echo ""
echo "Releasing IP address..."
killall -SIGUSR2 udhcpc
fi

sleep 2
echo ""
echo "IP address now released. Press 's' to shutdown."
read -n 1 -p "" RESP
if [ "$RESP" = "s" -o "$RESP" = "S" ]; then
sudo poweroff
fi

--- End code ---

Tested with a Linksys router running Tomato, DHCP gets released.

gerald_clark:
Why not just add
   killall -SIGUSR2 udhcpc
to /opt/shutdown.sh.

Navigation

[0] Message Index

Go to full version