# zinit Scripts
This directory contains scripts for installing and managing zinit.
## Main Script: `install.sh`
**Purpose:** Download and install pre-built zinit binaries for your platform
This is the **primary installation script** for end users who want to quickly get zinit running without building from source.
**Usage:**
```bash
# Download and run directly
# Or download and run locally
wget https://raw.githubusercontent.com/threefoldtech/zinit/main/scripts/install.sh
chmod +x install.sh
./install.sh
```
**Features:**
- Automatically detects your OS and architecture (Linux amd64, macOS arm64)
- Downloads pre-built binaries from Forgejo package registry
- Installs to `$HOME/hero/bin`
- Configures PATH in shell configuration files (bash, zsh, fish)
- Verifies binaries work after installation
- Handles both Linux and macOS with platform-specific behavior:
- **macOS/Windows:** Automatically starts zinit-server in the background
- **Linux:** Server runs in foreground (ready for container or systemd integration)
**What it does:**
1. Detects your platform (OS + architecture)
2. Downloads binaries from: `https://forge.ourworld.tf/api/packages/geomind_code/generic/zinit/dev/`
3. Installs to: `$HOME/hero/bin`
4. Configures PATH automatically
5. Verifies installations work
6. On macOS/Windows: Starts the server in background with proper socket/config paths
---
## Building from Source
For development or if pre-built binaries aren't available for your platform:
```bash
# Clone the repository
git clone https://github.com/threefoldtech/zinit
cd zinit
# Build and install
make build
make install
# Or run development server
make run
```
For more build options, see the [Makefile](../Makefile) or run:
```bash
make help
```
---
## Other Files in This Directory
### `initramfs-init`
Init system support file. Specialized for container and systemd integration when running zinit as PID 1.
---
## Quick Reference
| Install from internet | `curl ... \| bash` |
| Install locally | `./scripts/install.sh` |
| Build from source | `make build` |
| Build and run dev | `make run` |
| Run tests | `make test` |
| See all Makefile targets | `make help` |
---
## Path Configuration
The scripts are platform-aware and automatically use the correct paths:
### Linux
- Config directory: `/etc/zinit/services` (or `$ZINIT_CONFIG_DIR`)
- Socket: `/run/zinit.sock` (or `$ZINIT_SOCKET`)
- Install: `$HOME/hero/bin`
### macOS / Windows
- Config directory: `$HOME/hero/cfg/zinit` (or `$ZINIT_CONFIG_DIR`)
- Socket: `$HOME/hero/var/zinit.sock` (or `$ZINIT_SOCKET`)
- Install: `$HOME/hero/bin`
All scripts respect the `ZINIT_SOCKET`, `ZINIT_CONFIG_DIR`, and `ZINIT_LOG_LEVEL` environment variables if set.
---
## Troubleshooting
### Socket permission denied
The socket directory may have restrictive permissions. Check:
```bash
ls -la $(dirname $ZINIT_SOCKET)
# Should be writable by current user
```
### Server fails to start
Check the log:
```bash
cat /tmp/zinit-server.log
```
### Client can't connect
Ensure the server is running and socket exists:
```bash
ls -la $ZINIT_SOCKET
### Binary download fails
The install script requires either `curl` or `wget`. Install one of them:
```bash
# macOS
brew install curl
# Linux
apt-get install curl # Debian/Ubuntu
yum install curl # RedHat/CentOS
```
---
## For More Information
- **Building from source:** See [Makefile](../Makefile) or run `make help`
- **Main documentation:** See [README.md](../README.md)
- **Scripts migration:** See [SCRIPTS_MIGRATION.md](../SCRIPTS_MIGRATION.md)