CP and printing QR codes
-
Hi,
playing around with captive portal I noticed, that there is no satisfying solution (for me) to print the voucher codes as QR code directly from pfSense GUI.
Call me mad, but I dont like to send a file to a QR generator in web for creating my QR code vouchers.
But most available QR code generators do not met my requirements.
Actually I was excited from the vouchers made by knobelbecher.net found in this thread.Looking around in web and here in forum, it seems, that there have been feature requests since years, one is marked „solved“, but I did not find any related page/file in pfSense for that!?
So after some days of checking different possibilities I created my own, quick and (not so) dirty QR code generation.
It is just phase 1.0 and „as is“, but may be someone else is looking for such a QR code printout.
Requirements for this solution: you need a Linux PC running in your network, here a raspberry Pi 4B is doing that job, this device is already running in my LAN.
You need to install qrencoder and a NFS server (if not already installed).
Afterwards mount a filesystem from this host to the pfSense. I did create a script for the mount and added it to cron.
Usually at a Linux system I would create a system unit for mounting, but my approach was to modify nothing in pfSense operating system. Modifying html/php pages is a complete different level than modifying OS files.
So an update should hopefully dont have an serious impact to this solution.Here is a quick overview how I solved the issue:
From CP you can create and download the .csv file as usual, but in addition the .csv file is written to a directory at pfSense host.
After that a script (also at pfSense host) is triggered from the php site which do the following tasks:
delete the old .csv at remote mount from raspberry Pi
delete old qr codes at remote mount from raspberry Pi
delete old qr codes at pfSense (the codes are not needed after printout)
run a ssh command against the raspberry Pi which contains the script for qrencode
qrcodes for current roll are created at Pi
copy the qrcodes to a directoy at pfSenseNow you can print the vouchers which QR code.
In pfSense I also enabled a cron job for monitoring the mount from the remote host. If mount is not available, you will be notified by mail (if SMTP is configured)
A complete description what has been changed/created/modified is in the attached .pdf file in archive.
Also the modified php and css files.Remember: the pages/scripts are provided „as is“, feel free to improve (and share).
As a feature request it would be nice, if Netgate can add the qrencode in the OS of pfSense (or at least provide a package for install).
Regards
Edit Dec 14, 2022: uploaded a modified version(1a). QR code image names are now referring to the selected roll (have been generic in first draft).
Edit Dec 15, 2022: uploaded a modified version (1b). In "check_mount" script Windows control codes removed.
Edit Dec 19, 2022: uploaded a modified version (1c). In "voucher page" the link to High Availability was missing.
Edit Dec 20, 2022: uploaded a modified version (1d). Minor bugfix, in /etc/inc/priv/portalprint.priv.inc two pages from "services" title refers to "status" ->changed to correct title.
Here are some examples of the printout:
-
After some minor bug fixes in the previous posted pages I added some more:
Now from Captive Portal Status pages it is also possible to print the voucher codes.
If you create a user/group with only access to the CP status pages they can download/print the codes.For managing the codes an access to the CP service pages is still mandatory.
A detailed description how to set the permissions is in the .pdf included in the archive.
The screenshots in .pdf are also contained as .png files in archive.Regards
Edit Dec., 23th, 2022: Uploaded v1.1a (only typos in setup pdf corrected)
Edit Dec., 27th, 2022: Uploaded v1.1b (corrected comment field in voucher status)
Edit Feb., 16th, 2023: Uploaded v1.2 (modified for FW 23.01)
Edit Feb., 17th, 2023: Uploaded v1.3 (Bugfix)For FW 23.01 actually only two files have been modified:
services_captiveportal_vouchers.php (major changes in code!)
status_captiveportal_voucher_rolls.php (lines added for printing).Rest of files remains untouched.
-
@FSC830 hello I'm researching about some like this, exist some github repo? it will be nice because the community can contribute
this is grate i will test soon
thanks