From fd43c15bcdbd0b2d4d2285373410634a96f6d978 Mon Sep 17 00:00:00 2001 From: Brandon Cornejo Date: Thu, 5 Mar 2026 13:19:14 -0600 Subject: [PATCH] Install script, fix Discworld directory --- Discworld | 26 +++++++++++++++----------- README.md | 9 +++++---- discworld.yaml | 14 +++++++------- install.sh | 24 ++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 22 deletions(-) create mode 100755 install.sh diff --git a/Discworld b/Discworld index 508acfa..5e23f85 100755 --- a/Discworld +++ b/Discworld @@ -1,6 +1,9 @@ # Change to the 'discworld-tintin' directory and remove the input history file -cd "$( dirname -- "$( readlink -f -- "$0"; )"; )" -rm logs/history.log +export DISCWORLD_DIRECTORY="PACKAGE_DIRECTORY" +cd $DISCWORLD_DIRECTORY +if [ -e logs/history.log ]; then + rm logs/history.log +fi # Set hotkeys to switch in/out of "mobile" mode tmux bind C-f resize-pane -x 80% @@ -15,13 +18,14 @@ if [[ ! $(tmux ls -F '#S') =~ discworld ]]; then rm logs/chat.log && touch logs/chat.log # Start a new tmux session named "discworld" with our tmuxp setup - tmuxp load -s discworld ./discworld2.yaml -fi - -# If there is already a session, just attach -if [ -z "$TMUX" ]; then - #tmux send-keys 'clear && tt++ -G config.tin' 'C-m' - echo "Not already in TMUX, so let's attach" - # If we aren't already inside of TMUX, then attach to our session - tmux -2 attach-session -t discworld -d + echo "No existing discworld session, create a new one" + tmuxp load -s discworld ./discworld.yaml +else + # If there is already a session, just attach + if [ -z "$TMUX" ]; then + #tmux send-keys 'clear && tt++ -G config.tin' 'C-m' + echo "Not already in TMUX, so let's attach" + # If we aren't already inside of TMUX, then attach to our session + tmux -2 attach-session -t discworld -d + fi fi diff --git a/README.md b/README.md index 0b537f8..114dadc 100644 --- a/README.md +++ b/README.md @@ -144,10 +144,11 @@ A short guide to getting the client installed, this package put in place and MUD - tmux and [tmuxp](https://github.com/tmux-python/tmuxp) (sudo apt install tmux tmuxp) - python 3 - sqlite 3 -* With package downloaded and requirements installed then `tt++ -G config.tin` will launch -* "Discworld" shell-file exists to setup tmux layout or connect to existing - - Recommend symlinking e.g. (`sudo ln -s /home/myuser/discworld-tintin/Discworld /usr/local/bin/disc) - - Now you can type "disc" from anywhere to launch or connect to the setup +* Run "install.sh" to configure your directories and create a global alias + - Will request sudo password to create link in /usr/local/bin +* Now you can type "disc" from your terminal to create a new session or connect to an existing one + - To run just the client without any tmux panes use `tt++ -G config.tin` + - The `disc` command runs the `Discworld` script which handles tmux session creation or re-attachment ### Configuring the MUD diff --git a/discworld.yaml b/discworld.yaml index 748003d..ebec68e 100644 --- a/discworld.yaml +++ b/discworld.yaml @@ -1,16 +1,16 @@ --- session_name: discworld +start_directory: "$DISCWORLD_DIRECTORY" windows: - focus: 'true' layout: 459d,144x79,0,0[144x8,0,0,289,144x10,0,9,290,144x59,0,20{116x59,0,20,291,27x59,117,20[27x38,117,20,292,27x10,117,59,293,27x9,117,70,294]}] options: {} panes: - - tail - - sh + - clear && tail -fs .5 logs/chat.log + - ./bin/mdt - focus: 'true' - shell_command: tt++ - - bash - - sh - - bash - start_directory: "$(dirname '$0')" + shell_command: tt++ -G config.tin + - ./bin/dt + - ./bin/grp + - ./bin/map window_name: DiscworldMUD diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..9d421ae --- /dev/null +++ b/install.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Directory where this script lives +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)" + +discworld_file="$script_dir/Discworld" + +# Ensure the Discworld file exists +if [ ! -f "$discworld_file" ]; then + echo "Error: '$discworld_file' not found." + exit 1 +fi + +# Escape characters that might confuse sed (& and |) +escaped_dir=$(printf '%s\n' "$script_dir" | sed 's/[&|]/\\&/g') + +# Replace "PACKAGE_DIRECTORY" on the second line with the full path +sed -i "2s|PACKAGE_DIRECTORY|$escaped_dir|" "$discworld_file" + +# Create (or overwrite) the symlink in /usr/local/bin +sudo ln -sf "$discworld_file" /usr/local/bin/disc + +echo "The discworld-tintin package is installed, you can now type 'disc' from anywhere to connect"