An open API service indexing awesome lists of open source software.

https://github.com/codenlighten/ubuntu-ai-server


https://github.com/codenlighten/ubuntu-ai-server

Last synced: 12 months ago
JSON representation

Awesome Lists containing this project

README

          

# Automated Ubuntu Server Setup

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`.

## Features

* **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.

## Prerequisites

* **Ubuntu 20.04+** (or compatible Debian-based distro)
* **Node.js v18+**
* **npm**
* An **OpenAI API key** with access to your `StructuredResponseGenerator` model.

## Installation

1. Clone this repository:

```bash
git clone
cd
```

2. Install Node.js dependencies:

```bash
npm install
```

3. Set your OpenAI API key as an environment variable:

```bash
export OPENAI_API_KEY="sk-..."
```

## Usage

1. Make the setup script executable:

```bash
chmod +x setup.js
```

2. Run the script with a profile name:

```bash
./setup.js --profile web-node
```

* The script will prompt the `StructuredResponseGenerator` to produce a JSON spec for the given profile.
* It will then:

1. Update `apt-get` and install all listed packages.
2. Execute any additional shell commands.
3. Write configuration files to their target paths.
4. Enable and restart specified services.

## Defining New Profiles

Profiles are defined by passing a different `--profile` argument. Under the hood, the script:

1. Constructs a prompt asking for a JSON spec for that profile
2. 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.

## Extending the Script

* **Change prompt**: Adjust the `prompt` variable in `setup.js` for custom instructions.
* **Add validation**: Integrate JSON schema validation before executing `response` content.
* **Dry-run mode**: Add a flag to print actions without executing them.

## Contributing

1. Fork the repository.
2. Create a feature branch: `git checkout -b feature/awesome-profile`.
3. Commit your changes: `git commit -m "Add awesome profile schema"`.
4. Push to your branch: `git push origin feature/awesome-profile`.
5. Open a pull request.

## License

This project is MIT‑licensed. See the [LICENSE](LICENSE) file for details.