User Tools

Site Tools


simple-bpq-telnet-application

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
simple-bpq-telnet-application [2024/11/29 14:56] kc2ihxsimple-bpq-telnet-application [2026/01/01 22:42] (current) – [BPQ configuration] kc2ihx
Line 31: Line 31:
  
 <code> <code>
-import asyncio, telnetlib3, json+import asyncio, telnetlib3, json, sys
 from optparse import OptionParser from optparse import OptionParser
  
Line 40: Line 40:
  
 messages = json.load(open(options.filename,'r')) messages = json.load(open(options.filename,'r'))
 +
 +def print_log(*a):
 +    print(*a, file=sys.stderr)
 +
  
 async def shell(reader, writer): async def shell(reader, writer):
     incall = await reader.readline()     incall = await reader.readline()
-    print("%s connected" % incall)+    print_log("%s connected" % incall)
     writer.write("\r\nWelcome %s" % incall)     writer.write("\r\nWelcome %s" % incall)
     writer.write("\r\n%s" % messages["welcome"])     writer.write("\r\n%s" % messages["welcome"])
Line 51: Line 55:
     inp = await reader.read(1)     inp = await reader.read(1)
     while inp and not leave and len(textblocks) > 0:     while inp and not leave and len(textblocks) > 0:
-        print("writing next block")+        print("writing next block")
         writer.write(textblocks.pop(0))         writer.write(textblocks.pop(0))
         await writer.drain()         await writer.drain()
         inp = await reader.readline()         inp = await reader.readline()
-        if not rolled: print("%s rickrolled" % incall) +        if not rolled:  
-        rolled = True+            # notify that rolling has happened 
 +            print_log("%s rickrolled" % incall) 
 +            rolled = True
         leave = inp[0].upper() in ["Q", "B"] and rolled         leave = inp[0].upper() in ["Q", "B"] and rolled
     writer.close()     writer.close()
Line 88: Line 94:
 In my ''bpq32.cfg'' file, I added the port number to the telnet port, where the fourth entry, ''10001'' is the port for my new application: In my ''bpq32.cfg'' file, I added the port number to the telnet port, where the fourth entry, ''10001'' is the port for my new application:
 <code> <code>
-CMDPORT=8005 63001 4565 10001+CMDPORT=8005 63001 10001
 </code> </code>
-and in the application list, I added a new entry, where ''3'' is the 0th-indexed 4th entry above.+and in the application list, I added a new entry, where ''HOST 2'' is due to being the 0th-indexed 3rd entry above.
 <code> <code>
-APPLICATION 4,ROLL,C 1 HOST S+APPLICATION 3,ROLL,C 1 HOST S
 </code> </code>
  
Line 98: Line 104:
 Next we'll configure a ''systemd'' service to make sure this script is always running and ready to accept connections. Next we'll configure a ''systemd'' service to make sure this script is always running and ready to accept connections.
  
-I created this file as a "user" service, as ''~/.config/systemd/user/rick.service'', but it should probably run as a system service:+Put this file in ''/etc/systemd/system/rick.service'':
  
 <code> <code>
 # service for RRoAX25 server # service for RRoAX25 server
 +# replace USER with the username under which you created the bpq-apps venv
  
 [Unit] [Unit]
 Description="RRoAX25 service" Description="RRoAX25 service"
 After=network.target After=network.target
 +# this might be backwards, but I do need linbpq for this to work.
 +Requires=linbpq.service
  
 [Service] [Service]
 Type=simple Type=simple
-WorkingDirectory=/home/indiahotelxray/.local/bpq-apps/ +User=evan 
-ExecStart=/home/indiahotelxray/.local/bpq-apps/bin/python /home/indiahotelxray/.local/bpq-apps/scripts/rick.py -p 10001 -f /home/indiahotelxray/.local/bpq-apps/data/messages.json+Group=evan 
 +WorkingDirectory=/home/USER/.local/bpq-apps/ 
 +ExecStart=/home/USER/.local/bpq-apps/bin/python /home/USER/.local/bpq-apps/scripts/rick.py -p 10001 -f /home/USER/.local/bpq-apps/data/messages.json
 Restart=always Restart=always
 +RestartSec=3
  
 [Install] [Install]
Line 119: Line 131:
 Activate it by running: Activate it by running:
 <code> <code>
-systemctl --user enable rick.service +sudo systemctl enable rick.service 
-systemctl --user start rick.service+sudo systemctl start rick.service
 </code> </code>
  
Line 126: Line 138:
  
 <code> <code>
-systemctl --user status rick.service+systemctl status rick.service
 </code> </code>
  
 If you need to edit the service file, reload it with: If you need to edit the service file, reload it with:
 <code> <code>
-systemctl --user daemon-reload+systemctl daemon-reload 
 +</code> 
 + 
 +Finally, to see who has used it: 
 +<code> 
 +journalctl -u rick.service -f
 </code> </code>
simple-bpq-telnet-application.1732892162.txt.gz · Last modified: by kc2ihx