Volver al ranking

pch/welder

Shell

👨‍🏭Set up your Linux server with plain shell scripts

serverlinux-serverserver-setupbashshell
Crecimiento de estrellas
Estrellas
1.2k
Forks
30
Crecimiento semanal
Issues
0
1k1.1k
jun 2017jun 2020jul 2023jul 2026
README

👨‍🏭 Welder

Welder allows you to set up a Linux server with plain shell scripts.

I wrote it out of frustration with Ansible. Ansible is an amazing and powerful tool, but for my needs it's just too much. 90% of the time all I need is to be able to run a shell script on the server, without extra dependencies.

In most basic terms, that's what welder does.

But there's some more.

⚠️ NOTE: if you're looking for the previous version of welder, you'll find it here.

Features

  • set up your server with a single command (welder run <playbook> <server>)
  • run a set of organized reusable shell scripts
  • use simple template syntax ({{ VAR_NAME }}) to substitute config variables

Directory structure

An example directory structure:

├── playbook.conf
├── config.conf
├── firewall
│   ├── files
│   │   └── rules.v4
│   └── firewall.sh
├── nginx
│   └── nginx.sh
├── system
│   ├── files
│   │   ├── 10periodic
│   │   ├── 50unattended-upgrades
│   │   └── ssh_key
│   └── system.sh
└── website
    ├── files
    │   └── site.conf.template
    └── website.sh

Playbook

Playbook is just a list of modules to execute. Example:

# playbook.conf

system
firewall
nginx
website

Config

Config file:

SITE_DOMAIN = "example.com"
SITE_DIR = "/var/www"

You can reference config variables in your scripts like this:

#!/bin/sh
set -xeu

. ./config.conf

echo $SITE_DOMAIN

Templates

Welder offers simple sed-based templates that interpolate variables in double brackets with values defined in config.

# website/files/nginx-site.conf.template

server {
    listen 80;

    server_name {{ SITE_DOMAIN }};
    root {{ SITE_DIR }}/current/public;
}

Usage

Run the playbook with the following command:

welder run playbook.conf user@example.com

How it works

Welder goes through the modules defined in playbook.conf, copies them to a cache directory, compiles config files and templates, rsyncs the directory to the server. Then it runs the setup script that invokes all *.sh files within the playbook (all scripts will be called with sudo).

Example setup script

# nginx/nginx.sh

# NOTE: sudo isn't necessary because the whole script will be
#       invoked as `sudo nginx/nginx.sh`

set -xeu # 'u' will give you warnings on unbound config variables

add-apt-repository -y ppa:nginx/stable
sapt-get update && apt-get install -y nginx

service nginx start

cp files/nginx.conf /etc/nginx/nginx.conf

# Disable default site
if [ -f /etc/nginx/sites-enabled/default ]; then
  rm /etc/nginx/sites-enabled/default
fi

service nginx restart

Installation

The only dependency required by welder is rsync (which should be pre-installed on your system in most cases).

  1. Check out welder into ~/.welder (or whatever location you prefer):

    $ git clone https://github.com/pch/welder.git ~/.welder
    
  2. Add ~/.welder/bin to your $PATH for access to the welder command-line utility.

    $ echo 'export PATH="$PATH:$HOME/.welder/bin"' >> ~/.bash_profile
    

    Ubuntu Desktop note: Modify your ~/.bashrc instead of ~/.bash_profile.

    Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile.

  3. Restart your shell so that PATH changes take effect. (Opening a new terminal tab will usually do it.) Now check if welder was set up:

    $  which welder
    /Users/my-user/Code/welder/bin/welder
    

Caveats

Since welder allows you to run anything on the server, you should use it with caution. It won't protect you from screw-ups, like rm -rf "/$undefined_variable".

Use at your own risk.

Alternatives

There's an alternative version of welder (the classic version), re-implemented in Python by @thomas-mc-work.

Repositorios relacionados
gin-gonic/gin

Gin is a high-performance HTTP web framework written in Go. It provides a Martini-like API but with significantly better performance—up to 40 times faster—thanks to httprouter. Gin is designed for building REST APIs, web applications, and microservices.

GoGo ModulesMIT Licenseservermiddleware
gin-gonic.com
88.9k8.7k
expressjs/express

Fast, unopinionated, minimalist web framework for node.

JavaScriptnpmMIT Licensejavascriptnodejs
expressjs.com
69.2k24.3k
withastro/astro

The web framework for content-driven websites. ⭐️ Star to support our work!

TypeScriptnpmOtherstatic-site-generatorblog
astro.build
61.2k3.6k
coollabsio/coolify

An open-source, self-hostable PaaS alternative to Vercel, Heroku & Netlify that lets you easily deploy static sites, databases, full-stack applications and 280+ one-click services on your own servers.

PHPPackagistApache License 2.0nodejsmysql
coolify.io
59.2k5.1k
imthenachoman/How-To-Secure-A-Linux-Server

An evolving how-to guide for securing a Linux server.

Creative Commons Attribution Share Alike 4.0 Internationallinuxhardening
29.5k2k
PostgREST/postgrest

REST API for any Postgres database

HaskellMIT Licensehaskelldatabase
postgrest.org
27.5k1.2k
vapor/vapor

💧 A server-side Swift HTTP web framework.

SwiftMIT Licensevaporswift
vapor.codes
26.2k1.5k
valeriansaliou/sonic

🦔 Fast, lightweight & schema-less search backend. An alternative to Elasticsearch that runs on a few MBs of RAM.

Rustcrates.ioMozilla Public License 2.0rustinfrastructure
crates.io/crates/sonic-server
21.3k615
gofr-dev/gofr

An opinionated GoLang framework for accelerated microservice development. Built in support for databases and observability.

GoGo ModulesApache License 2.0gogolang
gofr.dev
21.1k1.8k
elysiajs/elysia

Ergonomic Framework for Humans

TypeScriptnpmMIT Licenseframeworktypescript
elysiajs.com
18.7k556
ory/hydra

Internet-scale OpenID Certified™ OpenID Connect and OAuth2.1 provider that integrates with your user management through headless APIs. Solve OIDC/OAuth2 user cases over night. Consume as a service on Ory Network or self-host. Trusted by OpenAI and many others for scale and security. Written in Go.

GoGo ModulesApache License 2.0hydraoauth2
ory.com
17.4k1.6k
Grasscutters/Grasscutter

A server software reimplementation for a certain anime game.

JavaMavenGNU Affero General Public License v3.0javakcp
grasscutter.io
16.8k4.3k