use environment to set addr and port in wrappers

This commit is contained in:
Iris Lightshard 2022-03-07 12:31:49 -07:00
parent 614c886436
commit 6864b143f2
Signed by: Iris Lightshard
GPG key ID: 3B7FBC22144E6398
4 changed files with 15 additions and 9 deletions

View file

@ -27,7 +27,7 @@ This is the working structure of the 9p filesystem:
* `/slot`: After loading the cartridge, its ROM is read from here; Read-only.
* `/data/`: Any supporting data that comes with the cartridge will be found here; They are in three parts: `sprite`, `audio`, and `text`. Because `uxn` is limited to 64-128kb input files, the filesizes of these data blobs should be 64kb max, and the `chunk` command should be used to page different files into the service when needed. The files on the server should be like `TYPEN` where `TYPE` is one of `sprite`, `audio`, and `text`, and `N` is any sequence of characters (canonically a nonnegative integer). When first loading the cartridge, `N == 0`. Issuing the command `chunk TYPE XXX` will attempt to load data from file `carts/CART_NAME/data/TYPEXXX` into the correct data file. If `TYPE` is not one of `sprite`, `audio`, or `text`, or the ifle `TYPEXXX` doesn't exist in the data directory, the `chunk` command does nothing.
* `/data/`: Any supporting data that comes with the cartridge will be found here; They are in three parts: `sprite`, `audio`, and `text`. While `uxn` has the ability to seek through a file up to 4GB in size, it can be beneficial to separate game assets into discrete files. The `chunk` command should be used to page different files into the service when needed. The files on the server should be like `TYPEN` where `TYPE` is one of `sprite`, `audio`, and `text`, and `N` is any sequence of characters (canonically a nonnegative integer). When first loading the cartridge, `N == 0`. Issuing the command `chunk TYPE XXX` will attempt to load data from file `carts/CART_NAME/data/TYPEXXX` into the correct data file. If `TYPE` is not one of `sprite`, `audio`, or `text`, or the file `TYPEXXX` doesn't exist in the data directory, the `chunk` command does nothing.
* `/realms`: Open/saved realms, read-only. Realms and their associated universe are backed by real files on the server so that they can be preserved across service instantiations, in a directory structure like: `carts/CART_NAME/realms/REALM_NAME/{realm, universe}`. Realms can either be solo, open, or protected; Open or protected realms can have limited member numbers. Depending on the cartridge, these settings can be user-managed or managed by the cartridge itself. Realms are listed per line upon reading the file like: `REALM_NAME 1 4 1`. First would obviously be the name of the realm. The first number is number of members, second is member limit, third is 1 if protected, 0 if not. `0 1 1` represents a protected solo realm that is empty (saved game with password). `0 1 0` represents an unprotected solo realm that is empty (saved game with no password).
@ -78,7 +78,7 @@ or expose a service on the network (uses `9pserve` to support multiple users and
./xrxs-srv.sh start
```
Add the `-d` option to the above command to enable 9p debugging output.
Add the `-d` option to the above command to enable 9p debugging output. The default port is `5460` but can be changed by setting the `XRXS_PORT` environment variable.
Similarly, you can stop the service with:
@ -103,6 +103,6 @@ You can run `./build.sh` with no options to build the normal `xrxs` client, or w
* `-l`: build the standalone bootloader
* `-lr`: build the standalone bootloader and run it
When the client ROM has been built, run `./uxn-xrxs.sh` to mount the `9p` service and run the client.
When the client ROM has been built, run `./uxn-xrxs.sh` to mount the `9p` service and run the client. As with the server, the default port is `5460` but can be overridden with the `XRXS_PORT` environment variable. The default server address is `127.0.0.1` but can be similarly changed by setting the `XRXS_ADDR` environment variable.
The scripts assume you have `uxnasm` and `uxnemu` in your `PATH`. `9pfuse` is used to mount the service, but other implementations could possibly be used.

View file

@ -1,6 +1,8 @@
#!/bin/sh
PORT=5460
if [ -z "${XRXS_PORT}" ]; then
XRXS_PORT=5460
else
if [ -z "${DISPLAY}" ]; then
export DISPLAY=:0
@ -16,7 +18,7 @@ case $1 in
debug="-d"
fi
./xrxs -s xrxs ${debug} & sleep 1
9pserve -c unix!/tmp/ns.$(whoami).${seat}/xrxs tcp!0.0.0.0!${PORT} &
9pserve -c unix!/tmp/ns.$(whoami).${seat}/xrxs tcp!0.0.0.0!${XRXS_PORT} &
;;
stop)
killall xrxs

View file

@ -17,7 +17,7 @@
#include "realm.h"
#include "user.h"
char version[] = "0.2";
char version[] = "0.3";
int chatty9p = 0;

View file

@ -1,14 +1,18 @@
#!/bin/sh
ADDR=209.141.55.64
PORT=5460
if [ -z "${XRXS_ADDR}" ]; then
XRXS_ADDR=127.0.0.1
fi
if [ -z "${XRXS_PORT}" ]; then
XRXS_PORT=5460
fi
if [ ! -d ./n ]; then
mkdir ./n
fi
# start the 9p client and wait for it to initialize
9pfuse "tcp!${ADDR}!${PORT}" ./n & sleep 1
9pfuse "tcp!${XRXS_ADDR}!${XRXS_PORT}" ./n & sleep 1
#run the xrxs client
uxnemu ./xrxs.rom