WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Quickly release IP  (Read 5966 times)

Offline CFH

  • Newbie
  • *
  • Posts: 6
Quickly release IP
« on: May 07, 2014, 01:26:08 PM »
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: [Select]
killall -SIGUSR2 udhcpc
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...

Offline bmarkus

  • Administrator
  • Hero Member
  • *****
  • Posts: 7183
    • My Community Forum
Re: Quickly release IP
« Reply #1 on: May 07, 2014, 01:30:57 PM »
Proper solution is managing the DHCP server, not at client side.
Béla
Ham Radio callsign: HA5DI

"Amateur Radio: The First Technology-Based Social Network."

Offline CFH

  • Newbie
  • *
  • Posts: 6
Re: Quickly release IP
« Reply #2 on: May 07, 2014, 03:28:28 PM »
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...

Offline CFH

  • Newbie
  • *
  • Posts: 6
Re: Quickly release IP
« Reply #3 on: June 04, 2014, 04:05:27 PM »
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: [Select]
#!/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

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

Offline gerald_clark

  • TinyCore Moderator
  • Hero Member
  • *****
  • Posts: 4254
Re: Quickly release IP
« Reply #4 on: June 04, 2014, 05:14:17 PM »
Why not just add
   killall -SIGUSR2 udhcpc
to /opt/shutdown.sh.