summaryrefslogtreecommitdiff
path: root/vere/docker/start_urbit.sh
diff options
context:
space:
mode:
authorpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
committerpolwex <polwex@sortug.com>2025-10-05 21:56:51 +0700
commitfcedfddf00b3f994e4f4e40332ac7fc192c63244 (patch)
tree51d38e62c7bdfcc5f9a5e9435fe820c93cfc9a3d /vere/docker/start_urbit.sh
claude is gud
Diffstat (limited to 'vere/docker/start_urbit.sh')
-rwxr-xr-xvere/docker/start_urbit.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/vere/docker/start_urbit.sh b/vere/docker/start_urbit.sh
new file mode 100755
index 0000000..809f2f1
--- /dev/null
+++ b/vere/docker/start_urbit.sh
@@ -0,0 +1,71 @@
+#!/bin/bash
+
+set -eu
+
+# set defaults
+amesPort="34343"
+httpPort="80"
+loom="31"
+snap="2"
+
+# check args
+for i in "$@"
+do
+case $i in
+ -p=*|--port=*)
+ amesPort="${i#*=}"
+ shift
+ ;;
+ --http-port=*)
+ httpPort="${i#*=}"
+ shift
+ ;;
+ --loom=*)
+ loom="${i#*=}"
+ shift
+ ;;
+ --snap-time=*)
+ snap="${i#*=}"
+ shift
+ ;;
+esac
+done
+
+# If the container is not started with the `-i` flag
+# then STDIN will be closed and we need to start
+# Urbit/vere with the `-t` flag.
+ttyflag=""
+if [ ! -t 0 ]; then
+ echo "Running with no STDIN"
+ ttyflag="-t"
+fi
+
+# Check if there is a keyfile, if so boot a ship with its name, and then remove the key
+if [ -e *.key ]; then
+ # Get the name of the key
+ keynames="*.key"
+ keys=( $keynames )
+ keyname=''${keys[0]}
+ mv $keyname /tmp
+
+ # Boot urbit with the key, exit when done booting
+ urbit $ttyflag -w $(basename $keyname .key) -k /tmp/$keyname -c $(basename $keyname .key) -p $amesPort -x --http-port $httpPort --loom $loom --snap-time $snap
+
+ # Remove the keyfile for security
+ rm /tmp/$keyname
+ rm *.key || true
+elif [ -e *.comet ]; then
+ cometnames="*.comet"
+ comets=( $cometnames )
+ cometname=''${comets[0]}
+ rm *.comet
+
+ urbit $ttyflag -c $(basename $cometname .comet) -p $amesPort -x --http-port $httpPort --loom $loom --snap-time $snap
+fi
+
+# Find the first directory and start urbit with the ship therein
+dirnames="*/"
+dirs=( $dirnames )
+dirname=''${dirnames[0]}
+
+exec urbit $ttyflag -p $amesPort --http-port $httpPort --loom $loom $dirname --snap-time $snap