Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

55 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation


sidebar_position: 1


๐Ÿณ SCS

ITPal Service Control Standard

1. ๐Ÿ“‹ Overview

The ITPal Service Control Standard (SCS) defines a single, scriptable, and observable way to manage services across Linux servers. It is the foundation of ITPalโ€™s infrastructure operations, built around:

  • ๐Ÿณ Docker-first architecture
  • ๐Ÿ“œ Script-based service control (adminctl)
  • ๐Ÿ“Š Matrix-based monitoring and operator feedback
  • ๐Ÿ”„ Consistency, automation, and traceability

With SCS, infrastructure isnโ€™t just about deploying containers โ€” itโ€™s about running them in a predictable, monitored, and upgradeable way through clear protocols and tools.

๐ŸŽฏ Goals

  • Define ๐Ÿ—๏ธ a standard layout, naming rules, and control scripts for all services.
  • Allow fully ๐ŸŒ remote and automated service operations through the CLI and Matrix bot.
  • Reduce manual steps while increasing ๐Ÿ” visibility and ๐Ÿ“ˆ monitoring.
  • Establish ๐Ÿ”„ clear lifecycle states for every service (start, stop, restart, build, backup, restore, etc).

๐Ÿ“ Scope

SCS applies to:

  • All backend services and applications managed by ITPal, especially those running in Docker.

  • Shell scripts that perform service operations (start, deploy, logs, etc.).

  • Communication between services and:

    • adminctl (the privileged host command dispatcher),
    • The ๐Ÿค– Matrix Operator Bot (for remote commands, status, and alerts).

2. โš™๏ธ Installation

2.1 ๐Ÿ“ฆ Installing SCS CLI

The SCS CLI is installed using the provided script. It installs globally:

/etc/control/scs/install.sh

After installation, the CLI is available as scs.

2.2 ๐ŸŽฎ Using SCS CLI

Basic commands:

# Help and available commands
scs help

# List all services
scs list

# Start a service
scs start <service-name>

# Stop a service
scs stop <service-name>

# Check service status
scs status <service-name>

# View logs
scs logs <service-name>

3. ๐ŸŽ›๏ธ Control CLI

The cli.sh script is the central interface for all services under SCS. It hides Docker commands, service dependencies, build arguments, lifecycle hooks, and Git operations behind a consistent Bash interface.

This CLI is used both by humans (via SSH or shell) and by higher-level agents like adminctl and the Matrix Operator Bot.

3.1 ๐Ÿท๏ธ Service Declarations

Services are declared in config.sh using associative arrays:

  • containers โ€” service โ†’ container name.
  • images โ€” service โ†’ Docker image tag.
  • services โ€” which services are enabled.
  • services_path โ€” where each service lives.
  • run_args โ€” Docker run arguments.
  • repos_path, github_repos โ€” Git repos for version control.

This serves as the manifest of services, loaded dynamically by cli.sh.

Unlike YAML tools (like Docker Compose), this Bash format supports variables, conditions, and custom repo tracking.

3.2 โšก Actions

cli.sh includes built-in actions:

  • ๐Ÿ”จ build: Build Docker image.
  • โ–ถ๏ธ start: Start service (with dependencies).
  • โน๏ธ stop: Stop container.
  • ๐Ÿ”„ restart: Restart service.
  • ๐Ÿ“Š status: Show Docker container status.
  • ๐Ÿ“‹ logs: Follow logs.
  • ๐Ÿš shell: Open a shell inside container/image.
  • โš™๏ธ exec: Run arbitrary commands in container.
  • ๐Ÿท๏ธ version: Print Git metadata.
  • ๐Ÿ” check-update: Compare repo with GitHub.
  • โฌ†๏ธ upgrade: Update repo, rebuild, restart.
  • ๐Ÿ’พ backup: Create a backup.
  • ๐Ÿ“ฅ restore: Restore from backup.
  • โฐ setup-backup: Setup scheduled backups.
  • ๐Ÿ“‹ list-backups: Show backups.

3.3 ๐Ÿช Hooks and Conventions

Services can define lifecycle scripts in their directories:

  • start.sh, stop.sh, restart.sh โ€” override defaults.
  • pre-start.sh, post-start.sh, pre-restart.sh, post-restart.sh โ€” hooks.
  • upgrade.sh, check-update.sh, version.sh, after-upgrade.sh โ€” custom logic.

This makes behavior customizable without touching the CLI core.

3.4 ๐Ÿ“ Service Folder Structure

Typical structure under /etc/<service>/:

/etc/<service>/
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ .env.defaults
โ”œโ”€โ”€ adminctlConfig.js
โ”œโ”€โ”€ repo/
โ”œโ”€โ”€ start.sh
โ”œโ”€โ”€ stop.sh
โ”œโ”€โ”€ restart.sh
โ”œโ”€โ”€ pre-start.sh
โ”œโ”€โ”€ post-start.sh
โ”œโ”€โ”€ post-stop.sh
โ”œโ”€โ”€ build.sh
โ”œโ”€โ”€ version.sh
โ”œโ”€โ”€ check-update.sh
โ”œโ”€โ”€ upgrade.sh
โ”œโ”€โ”€ backup.sh
โ”œโ”€โ”€ restore.sh
โ”œโ”€โ”€ Dockerfile

All files are optional. Defaults assume a single container run with docker run and run_args.

3.5 ๐ŸŽจ CLI Design Principles

  • Config is declarative (config.sh).
  • ๐Ÿช Hooks take priority if defined.
  • ๐Ÿ”— Dependencies respected with start_with_deps.
  • Docker network auto-created.
  • Consistent ๐Ÿ“‹ log output with emoji markers.
  • shell and exec reuse run_args.

3.6 ๐Ÿ’ป Usage Patterns

scs start synapse       # Start synapse + dependencies
scs restart kuma        # Restart kuma
scs check-update all    # Git status for all services
scs upgrade mas         # Update MAS
scs status all          # Show status for all services
scs status webhook      # Show status for webhook service
scs logs webhook        # Follow logs
scs exec hookshot "ps aux"
scs backup authentik    # Backup authentik
scs restore synapse     # Restore synapse
scs setup-backup kuma   # Setup backups for kuma

These can be run directly, over SSH, via adminctl, or through automation.

โš™๏ธ Why Not Kubernetes? SCS is designed for developers/operators who want:

  • Running the latest dev commits
  • Easy forking/patching upstream
  • Full control over Docker args and repo tracking

Kubernetes focuses on scaling and abstraction. SCS prioritizes speed, flexibility, and full control.


4. ๐Ÿ’พ Backup and Restore

SCS includes backup and restore for services, with scheduling, S3 integration, and retention.

4.1 ๐Ÿ“‹ Overview

  • โฐ Scheduled backups (systemd timers).
  • โ˜๏ธ S3 integration.
  • ๐Ÿ—‘๏ธ Retention policies.
  • ๐Ÿ”ง Service-specific scripts.
  • ๐ŸŽ›๏ธ Unified CLI interface.

4.2 โš™๏ธ Configuration

In config.sh:

declare -A backup_services=(
  ["authentik"]="daily:30"
  ["synapse"]="weekly:90"
  ["kuma"]="monthly:365"
)

BACKUP_S3_BUCKET="your-bucket"
BACKUP_S3_REGION="us-east-1"
BACKUP_AWS_PROFILE="backup-profile"
  • daily โ†’ every midnight
  • weekly โ†’ Sunday midnight
  • monthly โ†’ first Sunday
  • Retention โ†’ days before deletion

4.3 ๐ŸŽฎ CLI Commands

scs setup-backup <service>   # Setup automated backups
scs backup <service>         # Run manual backup
scs list-backups <service>   # List backups
scs restore <service> <file> # Restore backup

4.4 ๐Ÿ”ง Service Backup Scripts

Each service provides backup.sh:

  1. Create archive.
  2. Place in backups/.
  3. Exit code 0 = success.

4.5 ๐Ÿ”„ Restore Scripts

Each service provides restore.sh:

  1. Accept archive path.
  2. Extract/validate.
  3. Restore service.
  4. Exit code 0 = success.

4.6 โ˜๏ธ S3 Integration

If S3 configured:

  • Upload backups after creation.
  • Apply retention policies.
  • Restore pulls from S3.
  • Local files cleaned up.

Path structure:

s3://<bucket>/<service>/<backup>.tar.gz

4.7 ๐Ÿ”„ Lifecycle

  1. Systemd triggers backup.
  2. Service backup.sh runs.
  3. Archive uploaded to S3.
  4. Old backups removed.
  5. Service restarted if needed.

Debugging:

systemctl status scs-backup-<service>
journalctl -u scs-backup-<service>
scs backup <service>
aws s3 ls s3://<bucket>/<service>/ --profile <profile>

5. ๐Ÿค– adminctl

5.1 ๐Ÿ“ adminctlConfig.js

Defines how adminctl and the Matrix Operator Bot interact with a service.

Type Definition

type AdminctlServiceConfig = {
  [serviceKey: string]: {
    serviceName: string,
    actions: string[],
    repoPath: string,
    owner: string,
    repo: string,
    branch: string,
    showTagMessage?: boolean,
    showReleaseNotes?: boolean,
    patchBranches?: string[],
    upstream?: { owner: string, repo: string },
    filesToCheck?: string[],
    getLocalVersion?: Function,
    upgrade?: Function,
    afterUpgrade?: Function,
  },
};

๐Ÿ”‘ Key Descriptions

  • ๐Ÿท๏ธ serviceName: Name of service.
  • โšก actions: Supported commands.
  • ๐Ÿ“ repoPath: Local repo path.
  • ๐Ÿ‘ค owner: GitHub owner.
  • ๐Ÿ“ฆ repo: Repo name.
  • ๐ŸŒฟ branch: Branch tracked.
  • ๐Ÿท๏ธ showTagMessage: Include tag message.
  • ๐Ÿ“‹ showReleaseNotes: Include release notes.
  • ๐Ÿ”ง patchBranches: Extra patch branches.
  • โฌ†๏ธ upstream: Override fork upstream.
  • ๐Ÿ“„ filesToCheck: Files to diff.
  • ๐Ÿท๏ธ getLocalVersion: Custom version logic.
  • โฌ†๏ธ upgrade: Custom upgrade function.
  • ๐Ÿ”„ afterUpgrade: Logic after upgrade.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages