simple-bpq-telnet-application
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| simple-bpq-telnet-application [2024/11/29 14:39] – kc2ihx | simple-bpq-telnet-application [2026/01/01 22:42] (current) – [BPQ configuration] kc2ihx | ||
|---|---|---|---|
| Line 5: | Line 5: | ||
| - Create a location for the script, data, and a python '' | - Create a location for the script, data, and a python '' | ||
| - Write the script | - Write the script | ||
| + | - Add the application to '' | ||
| - Setup a '' | - Setup a '' | ||
| Line 30: | Line 31: | ||
| < | < | ||
| - | import asyncio, telnetlib3, json | + | import asyncio, telnetlib3, json, sys |
| from optparse import OptionParser | from optparse import OptionParser | ||
| Line 39: | Line 40: | ||
| messages = json.load(open(options.filename,' | messages = json.load(open(options.filename,' | ||
| + | |||
| + | def print_log(*a): | ||
| + | print(*a, file=sys.stderr) | ||
| + | |||
| async def shell(reader, | async def shell(reader, | ||
| incall = await reader.readline() | incall = await reader.readline() | ||
| - | | + | |
| writer.write(" | writer.write(" | ||
| writer.write(" | writer.write(" | ||
| Line 50: | 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(" | + | |
| 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: | + | if not rolled: |
| - | rolled = True | + | # notify that rolling has happened |
| + | print_log("%s rickrolled" | ||
| + | rolled = True | ||
| leave = inp[0].upper() in [" | leave = inp[0].upper() in [" | ||
| writer.close() | writer.close() | ||
| Line 87: | Line 94: | ||
| In my '' | In my '' | ||
| < | < | ||
| - | CMDPORT=8005 63001 4565 10001 | + | CMDPORT=8005 63001 10001 |
| </ | </ | ||
| - | and in the application list, I added a new entry, where '' | + | and in the application list, I added a new entry, where '' |
| < | < | ||
| - | APPLICATION | + | APPLICATION |
| </ | </ | ||
| ===== Configuring this as a service ===== | ===== Configuring this as a service ===== | ||
| Next we'll configure a '' | Next we'll configure a '' | ||
| - | //todo write block describing adding a service to run this script// | ||
| + | Put this file in ''/ | ||
| + | < | ||
| + | # service for RRoAX25 server | ||
| + | # replace USER with the username under which you created the bpq-apps venv | ||
| + | [Unit] | ||
| + | Description=" | ||
| + | After=network.target | ||
| + | # this might be backwards, but I do need linbpq for this to work. | ||
| + | Requires=linbpq.service | ||
| + | [Service] | ||
| + | Type=simple | ||
| + | User=evan | ||
| + | Group=evan | ||
| + | WorkingDirectory=/ | ||
| + | ExecStart=/ | ||
| + | Restart=always | ||
| + | RestartSec=3 | ||
| + | |||
| + | [Install] | ||
| + | WantedBy=default.target | ||
| + | </ | ||
| + | |||
| + | Activate it by running: | ||
| + | < | ||
| + | sudo systemctl enable rick.service | ||
| + | sudo systemctl start rick.service | ||
| + | </ | ||
| + | |||
| + | Then check the status to confirm it is working: | ||
| + | |||
| + | < | ||
| + | systemctl status rick.service | ||
| + | </ | ||
| + | |||
| + | If you need to edit the service file, reload it with: | ||
| + | < | ||
| + | systemctl daemon-reload | ||
| + | </ | ||
| + | |||
| + | Finally, to see who has used it: | ||
| + | < | ||
| + | journalctl -u rick.service -f | ||
| + | </ | ||
simple-bpq-telnet-application.1732891195.txt.gz · Last modified: by kc2ihx