211
Chapter 15: Advanced Configuration
portmanager daemon
Thereisnormallynoneedtostopandrestartthedaemon.Torestartthedaemonnormally,justrunthecommand:
# portmanager
Supported command line options are:
Force portmanager to run in the foreground: --nodaemon
Set the level of debug logging: --loglevel={debug,info,warn,error,alert}
Change which configuration file it uses: -c /etc/config/portmanager.conf
Signals
SendingaSIGHUPsignaltotheportmanagerwillcauseittore-readitscongurationle
15.2.2 External Scripts and Alerts
The portmanager has the ability to execute external scripts on certain events.
When a port is opened by the portmanager:
• Whentheportmanageropensaport,itattemptstoexecute /etc/config/scripts/portXX.init (whereXXisthenumberofthe
port,e.g.08).ThescriptisrunwithSTDINandSTDOUTbothconnectedtotheserialport.
• Ifthescriptcannotbeexecuted,thenportmanagerwillexecute /etc/config/scripts/portXX.chat via the chat command on
the serial port.
When an alert occurs on a port:
• Whenanalertoccursonaport,theportmanagerwillattempttoexecute /etc/config/scripts/portXX.alert (whereXXisthe
portnumber,e.g.08)
• ThescriptisrunwithSTDINcontainingthedatawhichtriggeredthealert,andSTDOUTredirectedto/dev/null,NOTtothe
serialport.Ifyouwishtocommunicatewiththeport,usepmshellorpmchatfromwithinthescript.
• Ifthescriptcannotbeexecuted,thenthealertwillbemailedtotheaddressconguredinthesystemadministration
section.
When a user connects to any port:
• Ifalecalled/etc/cong/pmshell-start.shexistsitisrunwhenauserconnectstoaport.Itisprovided2arguments,the
"Portnumber"andthe"Username".Hereisasimpleexample:
</etc/config/pmshell-start.sh >
#!/bin/sh
PORT="$1"
USER="$2"
echo "Welcome to port $PORT $USER"
< /etc/config/pmshell-start.sh>
• Thereturnvaluefromthescriptcontrolswhethertheuserisacceptedornot,if0isreturned(ornothingisdoneonexitas
intheabovescript)theuserispermitted,otherwisetheuserisdeniedaccess.