From 09aed30893b8d5738bc96018b4439189218fb3e8 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Sun, 31 Mar 2024 17:36:36 -0700 Subject: [PATCH] pbot-vm: add PBOTVM_ADDR env var to set address of vm-server --- Docker/README.md | 3 +++ applets/pbot-vm/host/bin/vm-client | 5 +++-- applets/pbot-vm/host/bin/vm-server | 2 +- doc/VirtualMachine.md | 19 ++++++++++--------- lib/PBot/Core/Commands/Users.pm | 2 +- lib/PBot/VERSION.pm | 2 +- 6 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Docker/README.md b/Docker/README.md index 34f165ae..e7585096 100644 --- a/Docker/README.md +++ b/Docker/README.md @@ -61,6 +61,9 @@ For example, to connect securely via TLS to irc.libera.chat with botnick `coolbo docker run --name pbot -ti -v $DATA_DIR:/opt/pbot/persist-data pbot irc.botnick=coolbot irc.server=irc.libera.chat irc.port=6697 irc.tls=1 +If you are using the pbot-vm virtual machine, be sure to add (after `-ti`) `-e PBOTVM_ADDR=$ADDR` where `$ADDR` is the IP address or hostname of the machine +where `vm-server` is running. See [Virtual Machine](../doc/VirtualMachine.md) for more information. + Follow the steps in [Additional configuration](../doc/QuickStart.md#additional-configuration) in the [QuickStart guide](../doc/QuickStart.md) to create your bot-admin account, add channels, etc. diff --git a/applets/pbot-vm/host/bin/vm-client b/applets/pbot-vm/host/bin/vm-client index e14c6826..c11b3b68 100755 --- a/applets/pbot-vm/host/bin/vm-client +++ b/applets/pbot-vm/host/bin/vm-client @@ -17,12 +17,13 @@ use strict; use IO::Socket; use constant { - SERVER_PORT => $ENV{PBOTVM_SERVER} // 9000, + SERVER_ADDR => $ENV{PBOTVM_ADDR} // '127.0.0.1', + SERVER_PORT => $ENV{PBOTVM_PORT} // 9000, }; # TODO: extend to take a list of server/ports to cycle for load-balancing my $sock = IO::Socket::INET->new( - PeerAddr => '127.0.0.1', + PeerAddr => SERVER_ADDR, PeerPort => SERVER_PORT, Proto => 'tcp' ); diff --git a/applets/pbot-vm/host/bin/vm-server b/applets/pbot-vm/host/bin/vm-server index 2b353b77..0bba07b2 100755 --- a/applets/pbot-vm/host/bin/vm-server +++ b/applets/pbot-vm/host/bin/vm-server @@ -24,7 +24,7 @@ use Time::HiRes qw/gettimeofday/; use Encode; use constant { - SERVER_PORT => $ENV{PBOTVM_SERVER} // 9000, + SERVER_PORT => $ENV{PBOTVM_PORT} // 9000, HEARTBEAT_PORT => $ENV{PBOTVM_HEART} // 5556, DOMAIN_NAME => $ENV{PBOTVM_DOMAIN} // 'pbot-vm', COMPILE_TIMEOUT => $ENV{PBOTVM_TIMEOUT} // 10, diff --git a/doc/VirtualMachine.md b/doc/VirtualMachine.md index 14660ec7..ccd04a4d 100644 --- a/doc/VirtualMachine.md +++ b/doc/VirtualMachine.md @@ -21,15 +21,16 @@ Many commands can be configured with environment variables. If a variable is not defined, a sensible default value will be used. Environment variable | Default value | Description ---- | --- | --- -PBOTVM_DOMAIN | `pbot-vm` | The libvirt domain identifier -PBOTVM_SERVER | `9000` | `vm-server` port for incoming `vm-client` commands -PBOTVM_SERIAL | `5555` | TCP port for serial communication -PBOTVM_HEART | `5556` | TCP port for serial heartbeats -PBOTVM_CID | `7` | Context ID for VM socket (if using VSOCK) -PBOTVM_VPORT | `5555` | VM socket service port (if using VSOCK) -PBOTVM_TIMEOUT | `10` | Duration before command times out (in seconds) -PBOTVM_NOREVERT | not set | If set then the VM will not revert to previous snapshot +-------------------- | ------------- | ----------- +PBOTVM_DOMAIN | `pbot-vm` | The libvirt domain identifier +PBOTVM_ADDR | `127.0.0.1` | `vm-server` address for incoming `vm-client` commands +PBOTVM_PORT | `9000` | `vm-server` port for incoming `vm-client` commands +PBOTVM_SERIAL | `5555` | TCP port for serial communication +PBOTVM_HEART | `5556` | TCP port for serial heartbeats +PBOTVM_CID | `7` | Context ID for VM socket (if using VSOCK) +PBOTVM_VPORT | `5555` | VM socket service port (if using VSOCK) +PBOTVM_TIMEOUT | `10` | Duration before command times out (in seconds) +PBOTVM_NOREVERT | not set | If set then the VM will not revert to previous snapshot ## Initial virtual machine set-up These steps need to be done only once during the first-time set-up. diff --git a/lib/PBot/Core/Commands/Users.pm b/lib/PBot/Core/Commands/Users.pm index 50525c9f..c5d64d6b 100644 --- a/lib/PBot/Core/Commands/Users.pm +++ b/lib/PBot/Core/Commands/Users.pm @@ -193,7 +193,7 @@ sub cmd_usershow($self, $context) { return "There is no user account $name."; } - if (lc $key eq 'password') { + if (defined $key && lc $key eq 'password') { return "I don't think so."; } diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 77c5ae4b..7914ab54 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4732, + BUILD_REVISION => 4733, BUILD_DATE => "2024-03-31", };