Hotplug is a set of scripts running upon certain predefined conditions. On today's Linux system, hotplug can do many things from auto mounting USB drive, pairing bluetooth devices to network configuration.
Seldom mentioned, but DD-WRT does offer (very preliminary) hotplug support. With almost no info on the web, the job is done by digging though DD-WRT's source code and various Linux documents.
- Replace DD-WRT's event handler with our own
By default, DD-WRT registers /sbin/hotplug to handle all hotplug requests but the program, /sbin/hotplug doesn't follow standard hotplug rules, and, per my understanding, is a dummy and does nothing at all. So let's replace it with our own
Create a startup script /opt/etc/init.d/hotplugd with only one line:
echo /opt/sbin/hotplug > /proc/sys/kernel/hotplug
Then set it to run upon start up
chmod a+x /opt/etc/init.d/hotplugd
ln -s /opt/etc/init.d/hotplugd /opt/etc/init.d/S95hotplugd
run
/opt/etc/init.d/hotplugd
and check the result:
cat /proc/sys/kernel/hotplug
The output should be /opt/sbin/hotplug, which is our new event handler.
- Test drive hotplug
So how does the hotplug work? below script will give you some idea to start with:
Create /opt/sbin/hotplug with following:
#!/bin/sh#For Debugging
echo "Customized hotplug" >> /tmp/hotplug.log
echo -------------$(date)----------- >> /tmp/hotplug.log
set >> /tmp/hotplug.log
set it as executable
chmod a+x /opt/sbin/hotplug
Unplug the printer, wait few seconds and plug the printer back. Check the log by typing:
cat /tmp/hotplug.log
You can see there are bunch of environmental variables logged, two of them are worth noting:
ACTION The value for "ACTION" variable can be "add" or "remove", corresponding to device plugin and removal.
PRODUCT This is the unique device ID for the USB device, my printer is HP 1020 and value is 3f0/2b17/100.
In a full Linux system, hotplug is much more complex. My script is a quick dirty hack but should be sufficient to handle USB printers. - Configure hotplug to upload firmware to the printer
Some GDI printer(aka Windows printer) will require extra work on Linux. Below is an example of my HP Laserjet 1020 but also applies to other HP laser printers like 1000, 1005, 1018, P1005, P1008, P1505 etc..
You'll need two things to start with:
The printer's firmware -- this must be in the printer before printing. Some of popular HP printers' can be downloaded from http://oleg.wl500g.info/hplj/
usb_printerid -- this is used to detect if the firmware is already in place to prevent duplicated firmware uploading. Above link has one but that's for Broadcom devices. So I compile one for Atheros routers. Download here. Extract and put it to the router(samba, ftp or WinSCP).
Assume we have the firmware in /opt/usr/local/lib/ and usb_printerid in /opt/usr/local/bin/, run
chmod a+x /opt/usr/local/bin/usb_printerid
And finally, here is the full script /opt/sbin/hotplug#!/bin/sh
#For Debugging
#echo "Customized hotplug" >> /tmp/hotplug.log
#echo -------------$(date)----------- >> /tmp/hotplug.log
#set >> /tmp/hotplug.logP910ND='/opt/usr/sbin/p910nd'
PRINTERID='/opt/usr/local/bin/usb_printerid'
FIRMWARE='/opt/usr/local/lib/sihp1020.dl'
#replace it with your printer's firmware.if [ $DEVTYPE == 'usb_device' ] && [ $PRODUCT == '3f0/2b17/100' ]; then
#replace with your printer's device id.
if [ $ACTION == 'add' ]; then
#check and upload firmware
${PRINTERID} /dev/usb/lp0 | grep -q FWVER || cat ${FIRMWARE} > /dev/usb/lp0
#kill and restart p910nd
kill -9 $(pidof p9100d)
${P910ND} -b -f /dev/usb/lp0 0
fiif [ $ACTION == 'remove' ]; then
#printer removed, lets stop p910nd
kill -9 $(pidof p9100d)
fi
fi
The above script will upload firmware to printer then start p910nd daemon upon printer plug-in and stop p910nd when it's removed. - Modified p910nd startup script
With above script, DD-WRT will automatically configure the printer after the router is fully booted. However, similar approach has to be done during startup as the hotplug does not take effect at that moment.
For unknown reasons, DD-WRT will NOT create /dev/usb/lp0 for printer even we have printer support enabled. As a result, we can't use this device node to detect the printer's presence.
Here is a modified version of /opt/etc/init.d/p910nd startup script.
source /mnt/root/.profilemkdir -m 755 -p /dev/usb
mknod -m 660 /dev/usb/lp0 c 180 0
sleep 1P910ND='/opt/usr/sbin/p910nd'
PRINTER_ID='/opt/usr/local/bin/usb_printerid'
FIRMWARE='/opt/usr/local/lib/sihp1020.dl'
#replace with yours
PNAME='LaserJet'
#printer name id string, see belowi=$(find /sys/devices/platform/ -name product -exec cat {} \; | grep -c ${PNAME})
if [ $i != '0' ]; then
${PRINTER_ID} /dev/usb/lp0 | grep -q FWVER || cat ${FIRMWARE} > /dev/usb/lp0
kill -9 `pidof p9100d`
${P910ND} -b -f /dev/usb/lp0 0
fi
Notice the PNAME='LaserJet' line. The 'LaserJet" is part of the printer's name and can be used to check if the printer is plugged. To determine yours, run
find /sys/devices/platform/ -name product -exec cat {} \;
The result looks like that:
HP LaserJet 1020 #printer
DataTravelerMini #USB flash drive
Atheros AR91xx built-in EHCI controller #USB controller
After that, follow the previous tutorial to install printer in Windows if you haven't done so. Now enjoy the convenience of hotplug.
54 comments:
I searched thru the web just for this bit of info - could not find anywhere....
Thanks a lot.
I use dd-wrt on Asus router. I needed to send my FW to my GDI printer (HP LaserJet 1018) the hotplug way....
Keep up the good work.
BTW, your blog is so methodical as opposed to dd-wrt site which is full of confusing/contradictory/obsolete information.
Regards.
I am using your script to automatically start and kill samba once my hard disk is attached to the router. Mounting the partitions via hotplug and killing samba on remove works fine.
Unfortunately, the script fails to run samba for some reason. I am using the command "smbd -s /opt/etc/samba/smb.conf" from your previous tutorial. The command works fine from command line but not from within the script. I also tried using the absolute path to the smbd binary with no success. Any ideas?
I found out that when using id in the hotplug-script the entry "groups" is missing:
#normal output:
root $ id
uid=0(root) gid=0(root) groups=0(root)
#from script:
uid=0(root) gid=0(root)
I guess that is an issue for Samba. Can this be fixed?
have found an expert..wonderful and you have resolved my issue
hp laserjet 1020
GDI printer(aka Windows printer) will require extra work on Linux. Below is an example of my HP Laserjet 1020 but also applies to other HP laser printers like 1000, 1005, 1018, P1005, P1008, P1505 etc..
Nice Thanks Alot For sharing
Brick Rigs Game Download
I am very comfortable and pleased to come here. Thank you very much.
Paint Tool Sai Crack Torrent
Good information.
Dr Fone Registration Code Generator
Thanks your post it really so helpful......
Rosetta Stone Italian Torrents
Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog.
Rpg Maker Mv Mac Torrent
I should say thank you very much for this thought. It gives me more knowledge on this issue.
very Help Full Post. Look Some Different here at
Router Login not working
routerlogin admin page
Routerlogin
Routerlogin Net
newyear2019love.com get the new quotes
Watch live streaming of PSL https://livepsldigital.com/
Latest quotes , images and sayings about the https://happyvalentinesday2019.net/ available here.
https://teacherappreciationweekideas.com/ teacher apprication weeks for more progress
thanks for the information.
Nice thoughts with great helping content. I have also been seeking such thoughfull content to learn and appy in the life. We have also created such type of content on our site. You can refer out site for more ideas.
Happy New Year 2019 Wishes Messages Sms in Bengali
Merry Christmas 2018 SMS, Wishes, Messages, Greetings in Bengali
Merry Christmas 2018 Wishes Messages in Marathi,funny christmas text sms
thanks for the information.
pip camera new version 2019
Best New Year 2019 Love Quotes and wishes for Her or Him with images. Most Romantic Sayings for Girlfriend and Boyfriend to wish and propose on New
newyear2019s.com/
thanks for the information.
Sketch Maker new version 2019
Latest and romantic happy valentine day images
Very neat blog article.Much thanks again. Really Great. anniversary quotes for husband
This is certainly additionally an exceedingly wonderful offer everyone truly qualified on the lookout with. It's always not likely everyday there is chances read a little something. extremely well written article as studyplans.in . I will be sure to and return to read more of your useful information. Thanks for the post. I’ll certainly comeback.
https://apsscresult2019.in
latestgovtjobs2019.in
upboard10thresult2019.com
This is certainly additionally an exceedingly wonderful offer everyone truly qualified on the lookout with. It's always not likely everyday there is chances read a little something. extremely well written article as click here . I will be sure to and return to read more of your useful information. Thanks for the post. I’ll certainly comeback.
This is certainly additionally an exceedingly wonderful offer everyone truly qualified on the lookout with. It's always not likely everyday there is chances read a little something. extremely well written article as. I will be sure to and return to read more of your useful information. Thanks for the post. I’ll certainly comeback
Thats rightly set it the way the author talks to you makes you studychat.inread more and complete the book quickly!!!
sarkari result
Norton Customer Service phone number
McAfee contact number
Malwarebytes support
Hp printer support for mac
Canon printer technical support phone number
The list could go on and on because you are one fantastic mother!
https://www.motherdayquotesi.com
motherdayquotesi
Magicjack Live Chat,How to do Magicjack Live Chat,Magicjack Customer Service,Magicjack Customer care,Magicjack Phone Number,Magicjack Customer care Chat,Magicjack Number,Magicjack Care,Magicjack Help Support,Magicjack Support,Magicjack Technical Support,Magicjack Customer Support Support,Magicjack Toll Free Number,Magicjack Help,Magicjack Not Working,How To Connect Magicjack To Wi Fi,Magicjack Live Chat Online
RAGE 2
Redshift Render Crack
cubase pro crack
recover my files crack
vray crack for sketchup
shanpc
Thank you, I’ve recently been searching for information about this subject for a long time and yours is the best I have found out so far.Wintousb Enterprise Crack
IDM Crack
Connectify Hotspot Pro Crack
Spyhunter Pro Crack
Cracks
Cockos Reaper Crack
Piriform Recuva Pro Crack
Cadsoft Eagle Pro Crack
Clear the tapes and protective paper from the scanner lid, ink cartridge and paper tray.
123 hp com setup
123hp
Check the accessories that accompanied the HP Printer with the help of the list.
123.hp.com/setup
Hello there, could you tell me which blog platform you're working with?
I'm thinking about starting my blog soon, but I can't decide between BlogEngine/Wordpress/B2evolution and Drupal.
I'm curious because your design appears to be unique.
I'm looking for something different than other blogs.
P.S. Please accept my apologies for straying from the topic, but I had to inquire!
filebot crack
reimage pc repair crack
cleanmymac crack
razer surround pro crack
Hey! This is my first visit to your blog.
We are a collection of volunteers starting with one
a new project in the community in the same niche.
Your blog has provided us with useful information to work with. YOU
did a fantastic job!
screamer radio crack
final draft crack
prism video file converter crack
easeus partition master crack
On the Internet, I was overjoyed to discover this establishment.
This was a fantastic read, and I owe it to you at least once.
It piqued my interest a little, and you were kind enough to keep it.
Become a fan of a new item on your site.
screamer radio crack
switch sound file converter crack
freemake video downloader crack
tenorshare reiboot crack
Woah! This site's template/theme appeals to me much.
It's straightforward, yet it's effective. Getting the "perfect balance" might be difficult at times.
between excellent usability and aesthetics, I think you did a fantastic job on this.
Furthermore, the blog is quite rapid to load.
I'm using Firefox. Fantastic website!
ld player crack
little snitch crack
movavi video editor plus
aurora 3d presentation crack
Thanks for the wonderful message! I really enjoyed reading
You can be a good writer. Bad Alvzis Blog and Testament
He'll be back later. I want to argue
Keep up the good work, have a great weekend!
And I appreciate your work, I'm a great blogger.
This article bothered me a lot.
I will bookmark your site and continue searching for new information.
aegisub crack
aiseesoft screen rec crack
synchredible professional crack
videosolo video converter ultimate crack
I like your all post. You Have Done really good Work On This Site. Thank you For The Information You provided. It helps Me a lot. It Is Very Informative Thanks For Sharing. I have also Paid This sharing. I am ImPressed For With your Post Because This post is very beneficial for me and provides new knowledge to me. This is a cleverly
written article. Good work with the hard work you have done I appreciate your work thanks for sharing it.
It Is very Wounder Full Post.
apowersoft video editor crack
apowersoft video editor crack
apowersoft video editor crack
apowersoft video editor crack
I am very happy to find this blog. Thanks for sharing it. It's an amazing blog for information.
du-meter-crack
isumsoft-zip-password-refixer-crack
imyfone-lockwiper-crack
anytrans-for-ios-crack
navicat-premium-crack-download
driver-talent-pro-crack
I enjoyed reading
you will be a secretary. I will definitely tag your blog
and eventually he returns from then on. This excellent site definitely has all the information I have
was required in connection with this case and I did not know who to ask.
kmsauto net crack
solidworks crack
oo defrag professional edition crack
Wow, amazing block structure! How long
Have you written a blog before? Working on a blog seems easy.
The overview of your website is pretty good, not to mention what it does.
In the content!
vstpatch.net
Raxco PerfectRegistry Crack
Articulate Storyline Crack
TriDef 3D Crack
Rapid SEO Tool Crack
iSumsoft ZIP Password Refixer Crack
I am very thankful for the effort put on by you, to help us, Thank you so much for the post it is very helpful, keep posting such type of Article.
ThunderSoft Audio Editor Deluxe Crack
Rocket LeagueRocket League Full Version
Atom Crack
Here at Karanpccrack, you will get all your favourite software. Our site has a collection of useful software. That will help for your, Visite here and get all your favourite and useful software free.
Infix PDF Editor Pro Crack
freemake video downloader crack
movavi screen recorder crack
easy duplicate finder crack
minitab crack
unhackme crack
nero burning rom crack
It's Really good blog i Like the way how you explain it.
I am grateful to read it. Thanks for sharing.
procracktool
spotify premium crack
ultraiso crack
microsoft office 2019 crack
inpage free download
Wzr-Hp-G300Nh Router: Advanced Printer Sharing With Hotplug >>>>> Download Now
>>>>> Download Full
Wzr-Hp-G300Nh Router: Advanced Printer Sharing With Hotplug >>>>> Download LINK
>>>>> Download Now
Wzr-Hp-G300Nh Router: Advanced Printer Sharing With Hotplug >>>>> Download Full
>>>>> Download LINK 59
I am very impressed with your post because this post is very beneficial for me and provide a new knowledge to me.
WRC 10 Crack
eFootball PES 2021
homeguard pro crack
Crying Suns Crack
Thank you for sharing the HP Laserjet P1505 It's a small, fast, and reliable printer, perfect for home or small office use. The setup is simple, and it gives great quality prints. If you're looking for an affordable and easy-to-use printer, this one is a great choice.
Post a Comment