Is your old account not working? Don't panic, please register again!

*New 11.4 series Release:
2020-05-29: XigmaNAS 11.4.0.4.8453 - released!

*New 12.2 series Release:
2021-05-31: XigmaNAS 12.2.0.4.8458- released!

We really need "Your" help on XigmaNAS Language https://translations.launchpad.net/xigmanas packages. Please help us today!

XigmaNAS talks on IRC https://web.libera.chat/#xigmanas, ircs://irc.libera.chat:6697 (TLS) or irc://irc.libera.chat:6667 (plain text)

[HOWTO] AMD64 Print Server Setup Guide (by micr0n)

Only Admin's or Moderators can move thread's to this sub-forum.
Nobody should start a new thread on this sub-forum.
Anybody can reply to a thread on this sub-forum.
Forum rules
Set-Up GuideFAQsForum Rules
Post Reply
Hiji56
Advanced User
Advanced User
Posts: 170
Joined: Feb 13th, '21, 11:33
Status: Offline

[HOWTO] AMD64 Print Server Setup Guide (by micr0n)

#1

Post by Hiji56 »

"
by ChriZathens»29 Jun 2012 11:11
I am quoting this guide here, since I think it is useful for many people
micr0n wrote:First and foremost, I want to give credit to SGRIZZI, TAU_ZERO, & WEEZER on there take and write-up of setting up a print server through NAS4Free. Without them, I wouldn’t have any leads on parts of the things I needed to accomplish my goals. With that said and done, lets get in to this mess a bit.
I just wanted to first say that the LPR way of setting up a print server was what led me to further my discovery. No disrespect to those that came up with this usage, but it just didn’t fit me perfectly. I have a mixer of different O/Ses in my environment and it seem that all my Windows system just didn’t like this LPR. Plus, it seems those guides where kind of out dated and I figure I freshen it up a bit. With that said, this setup was done on a:
9.0.0.1.573
After reading up countless threads there was a few things I discovered. For those that didn’t know, one doesn’t need the ulpt0 drivers if one is running the amd64 version. This driver is built in to the kernel and it was quiet a surprise as someone mentions it on one of the forums. Second, the amount of configuration files needed to get the LPR spooler going was just too much for me. Too much to keep track of and although they were small files, it still felt a bit cluttered.
In my current situation (which isn't so current now since I've changed it up), I have a router with usb capabilities along with running dd-wrt. Which in this case is also currently acting as my print server. After some digging around, I found that it was using a small print server daemon (p910nd). This led me to the original authors site (""http://www.etherboot.org/p910nd/""
After doing some additional research to ensure that this binary can be cross-compiled, I decided to load up FreeBSD on my virtual server and take on the challenge. Luckily this wasn’t too bad of an undertaken job and with a few tweaks to the source to ensure it not only worked for FreeNAS, but that there was as little configuration needed as possible. So here we are today.
NOTE: The following file and guide is what worked for me. Please take this with a grain of salt as I’m unable to test this on a variety of systems and do not know and cannot guarantee that it will work for you. If it does work, please chime in and if enough people request for the i386 version, I can also compile one.
Also, This setup was done on a full install. I haven’t had an embedded system for a while, but I’m sure the helpful folks here might be able to tweak my guide and make one for you. This is also a basic setup and can be worked to expand further.
Please take precaution of commands that have the # in the beginning. Do not type this. This is just a reference point. Except with copying the config file.
I’ve attached the main binary (p910nd.txt) to this post. Download it, remove the .txt, and upload it to your nas. Place the binary in the following folder.
/usr/local/sbin
Once it’s there, I would recommend following the rest of the other files permission and owner just to be consistent by doing so. (Ensure you are root when doing this.)
#cd /usr/local/sbin
#chown root:wheel p910nd
#chmod 555 p910nd
Once that is competed, were half ways there. Next, create a devd folder like so.
#mkdir /usr/local/etc/devd
I would also recommend that this be root owned with the same permissions as the other files / folders to stay consistent.
#cd /usr/local/etc
#chown root:wheel devd
#chmod 755 devd
Now the hard part. Copy the following code, save it as ‘devd.conf’ without the quotes and drop it in the devd folder.

Code: Select all

# start action when USB printer ulpt0 is plugged in
# wait 3 second and then start the printer daemon
#
attach 100 {
device-name ""ulpt0"";
action ""sleep 3; 
/usr/local/sbin/p910nd -f /dev/ulpt0 -b 0;
echo 'o5L25fgfab' > /dev/speaker;"";
};
# this will cause a beep when you unplug the usb printer
detach 100 {
device-name ""ulpt0"";
action ""sleep 1;
kill `cat /var/run/p91*`
echo 'o5L10bafgffgfab' > /dev/speaker;
sleep 1;
echo 'o5L10fgfabbafgf' > /dev/speaker"";
}; 
*/
This must also be root owned with the following permissions.

Code: Select all

#chown root:wheel devd.conf
#chmod 755 devd.conf
Pretty much like the other authors that did the code for the LPR, this is just an extension to stop the print server daemon if there is no printer attached.
Now we need to restart the device daemon to take in the configuration.

Code: Select all

#/etc/rc.d/devd restart
And drum roll please….That’s it. Done. To test this, plug in your printer and type in the following command.

Code: Select all

#ps aux|grep –I p910nd
You should get two lines. One of them should show the actual binary running from the saved location. When the printer is disconnected, the daemon will stop automatically. You can run the same command above and this time, it should only show one line pertaining to grep.
Now the million dollar question, how the heck to print to this. Simple, if following one of the guides on setting up a LPR printer for Windows, don’t choose LPR for the port. Instead choose ‘Standard TCP/IP Port’ and follow the rest of the wizard till it asks you the device type. In which case, one can select the ‘Hewlett Packard Jet Direct’. Once the completion of adding the printer, that’s it. No other configuration is need. Just do a print test and give it moment.
The wonderful part of this setup is that, we don't need to restart the server, we don't need scripts to copy files, and best of all, file reduction. Pretty much only two files are needed to get this thing going. Well, hopefully this write-up was helpful and simple to follow since I am writing this @ 2am and things are getting a bit foggy. If there’s any question, just post them up I’ll see what kind of help I can provide if any.
Here is the link for p910nd.txt ---> ""https://sourceforge.net/apps/phpbb/free ... hp?id=1787""
Moderators please allow .txt extension in attachments, so that I could upload here..
EDIT 27/11/2012 ---> Added files as zip
attachment here!
Attachments
[/u] printserver.zip
Printserver(6.9 KiB) Downloaded 794 times
Attachment dead (Hiji56)
Last edited by ChriZathens[/u] on 27 Nov 2012 11:28, edited 2 times in total.
"
"
by ChriZathens»29 Jun 2012 11:12
chang-li wrote:Hi micr0n,
Thanks for a very nice HowTo and great work. I have used the p910nd module a on a stand alone old pc
"" ""http://members.shaw.ca/nicholas.fong/printsrv/""
But it was not for usb.
I'm assuming your ver should work for usb, via port 9100, and the other ports 9101,9102 working only for lpt type.
or, could you run multiple instances of p910nd so that multiple usb printers could be configured?
I would be interested in a i386 compatible ver, as I don't have x64 freenas server.
Thanks
chang-li
"
"
by ChriZathens»29 Jun 2012 11:14
micr0n wrote:
Hey chang-li, attached is the i386 version. I was bored and ended up generating it since it didn't take to long for me to do. Good luck and let me know if this works properly since I don't have a way to test this.
On a side note, remember to remove the '.i386.txt' (without quotes).
Again the attachment is posted as a link ===> ""https://sourceforge.net/apps/phpbb/free ... hp?id=1794""
"
"
by ChriZathens»29 Jun 2012 11:15
ldkraemer wrote:Nice Tutorial! It seems to work good on my i386 Embedded Compact Flash System Version 0.7.2.6412
I have one 500 Gig Hitachi drive mounted as mysata, and my setup files are stored there under:
/mnt/mysata/apps/p910nd
ldk:/mnt/mysata/apps/p910nd# ls -alt
total 32
dr-xr-xr-x 2 root wheel 512 May 26 11:21 .
-rwxr-xr-x 1 root wheel 161 May 26 11:21 lpsetup
-r-xr-xr-x 1 root wheel 13805 May 26 10:53 p910nd
-rwxr-xr-x 1 root wheel 1022 May 26 10:53 devd.conf

drwxr-xr-x 3 root wheel 512 May 26 10:53 ..
ldk:/mnt/mysata/apps/p910nd#
I've modified the configuration a bit, making it support two USB printers, although I haven't
taken the time to test printer #2.
To start with here is a bit of information on p910nd:
NAME
p910nd - port 9100+n printer daemon

SYNOPSIS
p910nd [-bv] [-f device] [0|1|2]

DESCRIPTION
p910nd is a small daemon that copies any data received on the port it is listening on to the corresponding printer port.
It is primarily intended for diskless Linux hosts running as printer drivers but there is no reason why it could not be
used on diskful hosts. Port 9100 is copied to /dev/lp0, 9101 to /dev/lp1 and 9102 to /dev/lp2. The default is
port 9100 to /dev/lp0.
The -f option can be used to specify a different printer device, e.g. /dev/usblp0.
The -b option turns on bidirectional copying.
The -v option shows the version number.
So, my command for device-name ""ulpt0"" is:
/usr/local/sbin/p910nd -f /dev/ulpt0 -b 0;
and for device-name ""ulpt1"" is:
/usr/local/sbin/p910nd -f /dev/ulpt1 -b 1;
Copy the following code, save it as ‘devd.conf’ without the quotes and save it in your apps folder on the hard drive.
Mine is saved at:
/mnt/mysata/apps/p910nd/
Edit the file devd.conf so it contains the following, then save it at /mnt/mysata/apps/p910nd/ with the permissions and owner/group as shown above.

Code: Select all

# start action when USB printer ulpt0 and ulpt1 are plugged in
# wait 3 second and then start the printer daemon
#
attach 100 {
device-name ""ulpt0"";
action ""sleep 3;
/usr/local/sbin/p910nd -f /dev/ulpt0 -b 0;
echo 'o5L25fgfab' > /dev/speaker;"";
#
#echo 'o5L10fgfabbafgf' > /dev/speaker;
#
};
# this will cause a beep when you unplug the usb printer 0
detach 100 {
device-name ""ulpt0"";
action ""sleep 1;
kill `cat /var/run/p91*`
echo 'o5L10bafgffgfab' > /dev/speaker;
sleep 1;
echo 'o5L10fgfabbafgf' > /dev/speaker;"";
};
attach 100 {
device-name ""ulpt1"";
action ""sleep 3;
/usr/local/sbin/p910nd -f /dev/ulpt1 -b 1;
echo 'o5L25fgfab' > /dev/speaker;"";
#
#echo 'o5L10fgfabbafgf' > /dev/speaker;
#
};
# this will cause a beep when you unplug the usb printer 1
attach 100 {
device-name ""ulpt1"";
action ""sleep 1;
kill `cat /var/run/p91*`
echo 'o5L10bafgffgfab' > /dev/speaker;
sleep 1;
echo 'o5L10fgfabbafgf' > /dev/speaker;"";
};
*/
I also copied the p910nd.i386.txt file to /mnt/mysata/apps/p910nd/ and renamed it as p910nd with the permissions and owner/group as shown above.
Now, we just need a Postinit script to move the files where they need to be for the system to function.
I created a file named lpsetup at /mnt/mysata/apps/p910nd/ with the permissions and user/group as shown above.
The file contains:

Code: Select all

cd /
cp -R -p -i /mnt/mysata/apps/p910nd/p910nd /usr/local/sbin/
mkdir -p -m 755 /usr/local/etc/devd
cp -R -p -i /mnt/mysata/apps/p910nd/devd.conf /usr/local/etc/devd/
/etc/rc.d/devd restart
Now login the webmin and go to SYSTEM -> ADVANCED -> COMMAND SCRIPTS and ADD lpsetup as type Postinit as shown.
Command ............................. Type
/mnt/mysata/apps/p910nd/lpsetup PostInit
Then reboot FreeNAS with your USB Printers unplugged. When the system is up, plug in the first USB printer and you should
hear some tones as it locates the printer.
Add your Printer to the system as a network printer as AppSocket/HP JetDirect. Be sure the printer has ENABLE checked.
This should get you printing from your Embedded System.
I have noticed that some Credit Card PDF Statements won't print unless they are scaled to 90%. But, that isn't a big problem.
Larry
"
"
by ldkraemer»12 Jul 2012 21:11
Note:
When you Boot NAS4Free your USB Printers should be unplugged. After NAS4Free is running Plug them in.
My printer didn't work when I plugged in my USB cable on my Embedded NAS. Instead of the normal beeps, I got nothing......
Reviewing devd.conf, I wanted to see if my files were copied to the correct place in /usr/local/sbin
I logged in as root via ssh:

Code: Select all

larry@debian:~$ ssh root@192.168.1.250
root@192.168.1.250's password: 
root@192.168.1.250's password: 
Last login: Thu Jul 12 03:50:49 2012
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California.  All rights reserved.
Welcome to NAS4Free!nas4free:~#
The file had been copied where it should be.....

Code: Select all

cd /usr/local/sbin
ls -alt
Displayed:
drwxr-xr-x 2 root wheel 1024 Jul 12 03:50 .
-rwxr-xr-x 1 root wheel 13805 Jul 12 03:30 p910nd
Now, let's see if it will execute.....

Code: Select all

/usr/local/sbin/p910nd -v
gave the following error message:
Shared object ""libwrap.so.5"" not found, required by ""p910nd""nas4free:/usr/local/sbin#
Ah, looks like a missing link.....ie. ln -s /path/to/real/file /path/to/non-existant/file
Search for the missing libwrap* file.....

Code: Select all

cd /
find . -iname ""libwrap*""
cd to it's subdirectory.....

Code: Select all

cd /usr/lib
ls -alt libwrap*
Displays:
-rwxr-xr-x 1 root wheel 28368 Jun 15 19:56 libwrap.so.6
Create the symbolic link.....

Code: Select all

ln -s libwrap.so.6 libwrap.so.5
But this symbolic link won't exist through a re-boot.....
So, we need to create it on every re-boot with lpsetup

Code: Select all

#lpsetup - modified for symbolic link
cp -p /mnt/store/.apps/p910nd/p910nd /usr/local/sbin/
mkdir -p /usr/local/etc/devd
cp -p /mnt/store/.apps/p910nd/devd.conf /usr/local/etc/devd/
cd /usr/lib
ln -s libwrap.so.6 libwrap.so.5
cd /mnt/store/.apps/p910nd
/etc/rc.d/devd restart
Re-Boot NAS4Free with USB Printer Unplugged, then continue from here.
Command I used for quick testing to find the current version.....

Code: Select all

/usr/local/sbin/p910nd -v
Displays:
p910nd Version 0.8
Now we need to restart the device daemon to take in the configuration.

Code: Select all

/etc/rc.d/devd restart
And drum roll please….That’s it. Done. To test this, plug in your printer and type in the following command.

Code: Select all

ps aux | grep –i p910nd
You should get two lines. One of them should show the actual binary running from the saved location. When the
printer is disconnected, the daemon will stop automatically. You can run the same command above and this time,
it should only show one line pertaining to grep.
nas4free:/mnt/store/.apps/p910nd# ps aux | grep -i p910nd
root 2620 0.0 0.1 9568 1104 ?? Is 6:15AM 0:00.03 /usr/local/sbin/p910nd -f /dev/ulpt0 -b 0
root 2673 0.0 0.0 496 300 1 R+ 7:04AM 0:00.00 grep -i p910nd
nas4free:/mnt/store/.apps/p910nd#
Now the million dollar question, how the heck to print to this. Simple, if following one of the guides on setting
up a LPR printer for Windows, don’t choose LPR for the port. Instead choose ‘Standard TCP/IP Port’ and follow the
rest of the wizard till it asks you the device type. In which case, one can select the ‘Hewlett Packard Jet Direct’.
Once the completion of adding the printer, that’s it. No other configuration is need. Just do a print test and
give it a moment.
The wonderful part of this setup is that, we don't need to restart the server, we don't need scripts to copy files,
and best of all, file reduction. Pretty much only two files are needed to get this thing going.
All Credit goes to micr0n from the FreeNAS Forum.
Subdirectories & Permissions for Reference:
NOTE:
Included is my keysetup file to setup NAS4Free for DSA Key Authentication also known as Public Key Authentication.
Also note that the user given SSH Permission has a ""Home Directory"" that is a Default of /mnt. This makes the
authorized_keys2 file located at /mnt/.ssh/authorized_keys2
nas4free:/mnt# ls -alt
drwxr-xr-x 4 root wheel 512 Jul 11 10:58 .
drwxr-xr-x 19 root wheel 512 Jul 11 10:58 ..
drwx--x--x 2 root wheel 512 Jul 11 10:58 .ssh
drwxrwxrwx 14 root wheel 1536 Jul 7 13:38 store
nas4free:/mnt#
nas4free:/mnt/store# ls -alt
drwxr-xr-x 5 1000 admin 512 Jul 11 10:58 .apps
nas4free:/mnt/store#
nas4free:/mnt/.ssh# ls -alt
drwx--x--x 2 root wheel 512 Jul 11 10:58 .
drwxr-xr-x 4 root wheel 512 Jul 11 10:58 ..
-rw------- 1 loginbozo wheel 602 May 29 2011 authorized_keys2
nas4free:/mnt/.ssh#
nas4free:/mnt/store/.apps# ls -alt
drwxrwxrwx 14 root wheel 1536 Jul 7 13:38 ..
drwxr-xr-x 5 root wheel 512 Jun 19 2011 mcommander
drwxr-xr-x 2 root wheel 512 May 30 2011 p910nd
drwxr-xr-x 5 root wheel 512 May 27 2011 .
drwxr-xr-x 2 root wheel 512 May 2 2011 temp
nas4free:/mnt/store/.apps#
nas4free:/mnt/store/.apps/p910nd# ls -alt
drwxr-xr-x 2 root wheel 512 May 30 2011 .
-rwxr-xr-x 1 root wheel 945 May 30 2011 keysetup
-rwxr-xr-x 1 root wheel 167 May 30 2011 lpsetup
-rw------- 1 root wheel 602 May 29 2011 authorized_keys2
drwxr-xr-x 5 root wheel 512 May 27 2011 ..
-rwxr-xr-x 1 root wheel 13805 May 26 2011 p910nd
-rwxr-xr-x 1 root wheel 1022 May 26 2011 devd.conf
nas4free:/mnt/store/.apps/p910nd#
#This is root
nas4free:~# ls -alt
drwxr-xr-x 3 root wheel 512 Jul 12 09:08 .
drwx--x--x 2 root wheel 512 Jul 12 09:08 .ssh
#This is root/.ssh
nas4free:~/.ssh# ls -alt
drwx--x--x 2 root wheel 512 Jul 12 09:08 .
drwxr-xr-x 3 root wheel 512 Jul 12 09:08 ..
-rw------- 1 root wheel 602 Jul 12 03:30 authorized_keys2
WHEW! What a challenge! If anyone knows how to get two users SSH access via DSA Keys, please post those solutions.........
THANKS!
Larry
Updated 07-12-2012 - Added Symbolic links for mc so it executes properly through a re-boot.
""http://sourceforge.net/projects/p910nd/""
Uploaded the Binary files again so they are saved.
"
"
by Wingman5»24 Nov 2012 15:13
Already stuck on:
I’ve attached the main binary (p910nd.txt) to this post. Download it, remove the .txt, and upload it to your nas. Place the binary in the following folder.
The binary .txt file is NOWHERE to download anymore.
I downloaded the tar.bz2 file but that is not the correct binary.
Also the .zip file in previous post isn't available anymore
Please help me. If needed I can provide an alternative upload source for this file.
thnx
"
"
by ChriZathens»27 Nov 2012 11:25
I only have the 64bit version of the scripts...
I attached them on the first post
"
"
by ldkraemer»06 Dec 2012 03:56
Wingman5,
I haven't been online for a couple of months, and I didn't know the Binary files had been deleted. I've uploaded them again, so you should be able to
continue your project. Sorry, for the inconvenience.
I'd have never expected the Binaries to disappear.
Keep us informed as to how your progress is going.....
Thanks.
Larry
"
"
by stealth915»25 Dec 2012 07:19
Thanks for the guide! I'm somewhat noob but I was able to get the p910nd version to print after making the symbolic link, but

Code: Select all

ps aux | grep –i p910nd
isn't displaying anything for me. Is there something I'm missing?
I'm using the 64 bit p910nd from the post above and NAS4FREE 9.1.0.1 r509.
Any help would be appreciated. Thanks!
"
"
by ldkraemer»20 Feb 2013 01:47
stealth915,
When you boot your NAS4Free, I'm assuming your Printer is unplugged. After your NAS4Free has finished booting, plug in your USB printer.
You should hear some musical notes. At that point you should be able to ssh into your NAS4Free and try the following command:

Code: Select all

/usr/local/sbin/p910nd -v
You should get the current version. If that worked, you should be able to get the following command to execute, if you have created the symbolic link,
and also have it in the lpsetup file, so it gets linked on each reboot:

Code: Select all

ps aux | grep –i p910nd
If it doesn't execute then you have something misplaced, or wrong permissions, or some other problem.
Larry
"
"
by freetoe»16 Mar 2013 06:14
This will be very basic question. I downloaded two zip files in this thread. After unzipping and set-up as written in the post. Any of two zip files did not work. Thus, I checked very primitive one. When I execute p910nd through SSH as root account, it returns ""command not found"". Is that mean p910nd in my HP N40L is not binary file? The way I used to move file p910nd in My iMac to HP server is FTP in binary mode.
This is what happened when I execute p910nd
nas4free:/usr/local/sbin# ls -la p910nd
-rwxr-xr-x 1 root wheel 16582 Mar 16 11:42 p910nd
nas4free:/usr/local/sbin# p910nd
p910nd: Command not found.
nas4free:/usr/local/sbin#
Is it problem of the attached file or my poor knowledge about UNIX?
"
"
by ldkraemer»01 Apr 2013 07:44
freetoe,
Will you try the following full path for the commands and see what happens, then post the results?

Code: Select all

which p910nd
/usr/local/sbin/p910nd -v
Thanks.
Larry
"
"
by freetoe»04 May 2013 07:24
Thanks Larry
This is what I did.
% which p910nd
p910nd: Command not found.
% /usr/local/sbin/p910nd -v
/usr/local/sbin/p910nd: Command not found.
"
"
by jamaroney»14 Jul 2015 17:05
Does this setup work anymore with newer versions of N4F? I ask because all setup directives went smoothly, but when I finally run ""ps aux | grep –i p910nd"" , I get nothing.
Also, if I read everything correctly, will I need to disconnect/reconnect my printer every time I reboot N4F?
"
"
by viliamr»27 Sep 2015 12:41
jamaroney wrote:Does this setup work anymore with newer versions of N4F? I ask because all setup directives went smoothly, but when I finally run ""ps aux | grep –i p910nd"" , I get nothing.
Also, if I read everything correctly, will I need to disconnect/reconnect my printer every time I reboot N4F?
i'm interested in this too...because i can't get those two lines and printer server doesn't work properly
rgds,
viliam
"
Post Reply