Skip to content

paulbickford/update-server

Repository files navigation

UpdateServer

A tool to send a command to multiple servers using SSH connections.

Requirements

Linux.

Each server must be configured with an SSH key pair in order to login without a password.

Installation

Clone repo.

This bakeware project compiles into single executable. It uses the Mix releases process to build binaries and place then into _build/prod/rel/bakeware/my_script

  1. Install zstd to enable compression during assembly.
  2. Build with MIX_ENV=prod, so dev dependencies are not included in binary.
  3. Clean build directory.
  4. Build release.
$ export MIX_ENV=prod
$ rm -fr \_build
$ mix deps.get
$ mix release

Binary will be in _build/prod/rel/bakeware/my_script.

In mix.exs, the binary wil be copied to the linux system path. You may need to change this location.

defp release do
  [
    ...
    steps: [:assemble, &Bakeware.assemble/1, &copy_to_system/1],
    ...
  ]
end

defp copy_to_system(release_struct) do
  System.cmd("sudo", [
    "cp",
    "-T",
    "_build/prod/rel/bakeware/update_server",
    "/usr/local/bin/update-server"
  ])

  IO.puts("Copied binary to /usr/local/bin/update-server")
  release_struct
end

Usage

When started on the command line, the application will create a window and read a list of servers from the disk. A connection to each server will be attempted and a command, if given, will be sent to each. The commands and responses will be shown in each server's section of the window.

$ update-server <cmd>

Each connected server will be listed with an associated ordinal number (essentially a shortcut) to allow easier command line input. These numbers are associated to the server at runtime and no not persist between sessions.

Subsequent commands given in the console will be sent to all servers unless preceded by -s <server_number>, in which case the command will be sent only to the given server.

Switches

-a [--add] name
Add server, or list of servers separated by spaces and enclosed in quotes, to default servers list and connect to server.
-c [--close] server_number
Close connection to server.
-d [--delete] name
Delete server from file. Does not close connection, if connected.
-h [--help]
Help
-l [--list]
List connected servers with codes.
-o [--open] name
Open connection to server, server_number, or list of servers separated by spaces and enclosed in quotes, but do not add to default servers list.
-p [--persisted]
List persisted (default) servers.
-q [--quit]
Quit application.
-s [--server] server_number
Server_number to send command to.

About

Tool to send a command to multiple servers using SSH connections.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages