Skip to content

shanselman/zork-cloudshell

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

Zork for Azure Cloud Shell

Build and play the classic text adventure game Zork directly in Azure Cloud Shell without needing root privileges or additional package installations.

Overview

Azure Cloud Shell provides a convenient browser-based shell environment, but it has limitations: you can't run as root and can't use apt-get to install packages like ncurses or termcap libraries. This script solves that problem by cloning the Zork source code and patching it to work with the libraries available in the Cloud Shell environment.

What This Script Does

The build_zork_cloudshell.sh script automates the following:

  1. Clones the Zork repository from devshane/zork
  2. Patches the Makefile to:
    • Remove dependencies on unavailable libraries (-ltermcap, -ltinfo, -lncurses)
    • Add the -DNO_TERMCAP compiler flag
    • Fix the TEXTFILE path to use the local dtextc.dat file
  3. Patches supp.c to provide fallback implementations of termcap functions using environment variables (LINES and COLUMNS)
  4. Patches local.c to include <unistd.h> for the getuid() function
  5. Builds the game using the standard make command

All patches are idempotent, so you can safely re-run the script without causing issues.

Quick Start

At shell.azure.com

  1. Open Azure Cloud Shell in your browser
  2. Download and run the script:
curl -fsSL https://raw.githubusercontent.com/YOUR_USERNAME/zork-cloudshell/main/build_zork_cloudshell.sh -o build_zork_cloudshell.sh
chmod +x build_zork_cloudshell.sh
./build_zork_cloudshell.sh
  1. Once built, play the game:
cd zork
./zork

Usage

./build_zork_cloudshell.sh [OPTIONS]

Options

  • --rebuild - Clean and rebuild the existing Zork directory after re-applying patches
  • --force-reclone - Delete the existing ./zork directory and clone a fresh copy
  • --uninstall - Remove the ./zork directory and exit
  • -h, --help - Display usage information

Examples

First-time installation:

./build_zork_cloudshell.sh

Rebuild after modifications:

./build_zork_cloudshell.sh --rebuild

Start fresh:

./build_zork_cloudshell.sh --force-reclone

Remove installation:

./build_zork_cloudshell.sh --uninstall

Playing Zork

After building, navigate to the zork directory and run the game:

cd zork
./zork

The game is the classic 1980s text adventure where you explore the dungeon. Type commands like go north, take lamp, open mailbox, etc.

Technical Details

Why the Patches Are Needed

  • No termcap/ncurses libraries: Azure Cloud Shell doesn't include these terminal control libraries, and you can't install them without root access
  • NO_TERMCAP flag: This tells the code to use fallback implementations instead of real termcap functions
  • Terminal dimensions: The script provides simple stubs that read LINES and COLUMNS environment variables (which Cloud Shell sets automatically)
  • Missing headers: The getuid() function requires <unistd.h>, which wasn't originally included in local.c

Repository Customization

You can customize the installation location by setting the REPO_DIR environment variable:

REPO_DIR=/tmp/zork ./build_zork_cloudshell.sh

Requirements

  • Azure Cloud Shell (Bash environment)
  • Internet connection (for cloning the repository)
  • Standard build tools (git, make, gcc - all pre-installed in Cloud Shell)

Troubleshooting

Problem: Script fails to clone the repository
Solution: Check your internet connection and verify you can reach github.com

Problem: Build errors about missing functions
Solution: Run with --force-reclone to get a clean copy and re-apply patches

Problem: Game won't start or crashes
Solution: Make sure you're running it from the zork directory where dtextc.dat is located

License

This script is provided as-is for educational purposes. Zork itself is maintained in the devshane/zork repository - please refer to that repository for game licensing information.

Contributing

Found a bug or have a suggestion? Feel free to open an issue or submit a pull request!

Acknowledgments

  • Original Zork implementation: devshane/zork
  • Inspired by the need to make classic games accessible in modern cloud environments

About

Build and play Zork in Azure Cloud Shell without root access or package installations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages