This repository provides a Node.js script (setup.js) that automates the provisioning of an Ubuntu server based on a structured JSON specification generated by your AI-driven StructuredResponseGenerator.
- Profile-based configuration: Define multiple setup profiles (e.g.,
web-node,docker-host,ci-runner) and generate tailored JSON specs. - Package installation: Installs required packages via
apt-get. - Custom commands: Executes arbitrary shell commands.
- Configuration files: Creates and writes configuration files at specified paths.
- Service management: Enables and restarts systemd services.
- Ubuntu 20.04+ (or compatible Debian-based distro)
- Node.js v18+
- npm
- An OpenAI API key with access to your
StructuredResponseGeneratormodel.
-
Clone this repository:
git clone <your-repo-url> cd <your-repo-directory>
-
Install Node.js dependencies:
npm install
-
Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY="sk-..."
-
Make the setup script executable:
chmod +x setup.js
-
Run the script with a profile name:
./setup.js --profile web-node
-
The script will prompt the
StructuredResponseGeneratorto produce a JSON spec for the given profile. -
It will then:
- Update
apt-getand install all listed packages. - Execute any additional shell commands.
- Write configuration files to their target paths.
- Enable and restart specified services.
- Update
-
Profiles are defined by passing a different --profile argument. Under the hood, the script:
-
Constructs a prompt asking for a JSON spec for that profile
-
Uses your AI model to generate an object with these keys:
packages: string[]commands: string[]files: { path: string; content: string }[]services: string[]
You can modify the prompt schema in setup.js to add or remove properties as needed.
- Change prompt: Adjust the
promptvariable insetup.jsfor custom instructions. - Add validation: Integrate JSON schema validation before executing
responsecontent. - Dry-run mode: Add a flag to print actions without executing them.
- Fork the repository.
- Create a feature branch:
git checkout -b feature/awesome-profile. - Commit your changes:
git commit -m "Add awesome profile schema". - Push to your branch:
git push origin feature/awesome-profile. - Open a pull request.
This project is MIT‑licensed. See the LICENSE file for details.