bashhub-server/README.md

159 lines
4.8 KiB
Markdown
Raw Normal View History

2020-02-07 16:02:18 +08:00
# bashhub-server
2020-02-10 17:13:19 +08:00
[![Go Report Card](https://goreportcard.com/badge/github.com/nicksherron/bashhub-server)](https://goreportcard.com/report/github.com/nicksherron/bashhub-server) [![Build Status](https://travis-ci.org/nicksherron/bashhub-server.svg?branch=master)](https://travis-ci.org/nicksherron/bashhub-server)
2020-02-07 16:02:18 +08:00
2020-02-10 16:22:08 +08:00
bashhub-server is a private cloud alternative for [bashhub-client](https://github.com/rcaloras/bashhub-client) with some
2020-02-10 14:22:20 +08:00
added features like regex search.
## Features
2020-02-07 16:02:18 +08:00
2020-02-10 18:08:45 +08:00
- Very simple drop in replacement for bashhub.com server and easy to [install](https://github.com/nicksherron/bashhub-server#installation) and get running with existing bashhub-client and bh command.
2020-02-10 14:22:20 +08:00
- All the benefits of bashhub without having to send your shell history to a third-party
2020-02-10 18:08:45 +08:00
- [Regex](https://github.com/nicksherron/bashhub-server#using-regex) search
2020-02-10 17:01:16 +08:00
- Quickly connect any client with access to your server bashhub-sever address/port.
2020-02-10 14:22:20 +08:00
- Written in Go so it's fast and is actively maintained
## Why?
2020-02-10 17:55:58 +08:00
I love the idea behind bashhub. Having my shell history centralized and queryable from various systems whether it
2020-02-10 18:17:28 +08:00
be my home computer or from an ssh session on a server is great. However, even with encryption,
I was weary of sending my shell commands to a third-party server, so bashhub-server was created.
2020-02-10 14:22:20 +08:00
## Installation
#### Homebrew or Linuxbrew
2020-02-10 16:22:08 +08:00
```
2020-02-10 16:07:40 +08:00
$ brew install bashhub-server/latest/bashhub-server
2020-02-10 14:22:20 +08:00
```
#### Docker
2020-02-10 16:22:08 +08:00
```
2020-02-10 16:07:40 +08:00
$ docker pull nicksherron/bashhub-server
2020-02-10 14:22:20 +08:00
```
2020-02-10 23:32:17 +08:00
#### Go
go modules are required
```
GO111MODULE=on go get -u github.com/nicksherron/bashhub-server
```
2020-02-10 14:22:20 +08:00
#### Releases
2020-02-10 17:55:58 +08:00
Binaries for various os and architectures can be found in [releases](https://github.com/nicksherron/bashhub-server/releases).
2020-02-10 16:24:30 +08:00
If your system is not listed just submit a issue requesting your os and architecture.
2020-02-10 14:35:12 +08:00
## Usage
2020-02-10 16:07:40 +08:00
```
$ bashhub-server --help
2020-02-10 14:35:48 +08:00
2020-02-10 14:35:12 +08:00
Usage:
[flags]
[command]
Available Commands:
help Help about any command
version Print the version number and build info
Flags:
2020-02-10 16:26:49 +08:00
-a, --addr string Ip and port to listen and serve on. (default "http://0.0.0.0:8080")
2020-02-10 14:38:49 +08:00
--db string DB location (sqlite or postgres)
2020-02-10 14:35:12 +08:00
-h, --help help for this command
2020-02-10 14:38:49 +08:00
--log string Set filepath for HTTP log. "" logs to stderr.
2020-02-10 14:35:12 +08:00
Use " [command] --help" for more information about a command.
2020-02-10 14:38:49 +08:00
2020-02-10 14:35:12 +08:00
```
### Running
2020-02-10 14:35:12 +08:00
Just run the server
2020-02-10 16:07:40 +08:00
```
$ bashhub-server
_ _ _ _
| | | | | | | | version: v0.1.1
2020-02-10 16:26:49 +08:00
| |__ __ _ ___| |__ | |__ _ _| | address: http://0.0.0.0:8080
2020-02-10 16:07:40 +08:00
| '_ \ / _' / __| '_ \| '_ \| | | | '_ \
| |_) | (_| \__ \ | | | | | | |_| | |_) |
|_.__/ \__,_|___/_| |_|_| |_|\__,_|_.__/
___ ___ _ ____ _____ _ __
/ __|/ _ \ '__\ \ / / _ \ '__|
\__ \ __/ | \ V / __/ |
|___/\___|_| \_/ \___|_|
2020-02-10 16:26:49 +08:00
2020/02/10 03:04:11 Listening and serving HTTP on http://0.0.0.0:8080
2020-02-10 14:35:12 +08:00
```
or on docker
2020-02-10 16:22:08 +08:00
```
2020-02-10 16:07:40 +08:00
$ docker run -d -p 8080:8080 --name bashhub-server nicksherron/bashhub-server
2020-02-10 14:35:12 +08:00
```
2020-02-10 17:23:21 +08:00
Then add ```export BH_URL=http://localhost:8080``` (or whatever you set your bashhub-server address to) to your .zshrc or .bashrc
2020-02-10 16:07:40 +08:00
```
2020-02-10 17:23:21 +08:00
echo "export BH_URL=http://localhost:8080" >> ~/.bashrc
2020-02-10 16:07:40 +08:00
```
or
2020-02-10 16:22:08 +08:00
```
2020-02-10 17:23:21 +08:00
$ echo "export BH_URL=http://localhost:8080" >> ~/.zshr
2020-02-10 16:07:40 +08:00
```
Thats it! Restart your shell and re-run bashhub setup.
```
$ $SHELL && bashhub setup
```
2020-02-10 15:31:44 +08:00
### Changing default db
2020-02-10 16:07:40 +08:00
By default the backend db uses sqlite, with the location for each os shown below.
2020-02-10 15:31:44 +08:00
2020-02-10 16:07:40 +08:00
| os | default |
|---------|----------------------------------------------------------------------------------|
2020-02-10 16:22:08 +08:00
| Unix | $XDG_CONFIG_HOME/bashhub-server/data.db OR $HOME/.config/bashhub-server/data.db |
2020-02-10 16:07:40 +08:00
| Darwin | $HOME/Library/Application Support/bashhub-server/data.db |
| Windows | %AppData%\bashhub-server\data.db |
| Plan 9 | $home/lib/bashhub-server/data.db |
To set a different sqlite db file to use, run
2020-02-10 16:22:08 +08:00
```
2020-02-10 16:07:40 +08:00
$ bashhub-server --db path/to/file.db
```
Postgresql is also supported by bashhub-server. To use postgres specify the postgres uri in the --db flag with the
2020-02-10 16:22:08 +08:00
following format
```
2020-02-10 16:07:40 +08:00
$ bashhub-server --db "postgres://user:password@localhost:5432?sslmode=disable"
```
### Using Regex
2020-02-10 16:07:40 +08:00
bashhub-server supports regex queries sent by the bh command (bashhub-client)
Without regex
2020-02-10 16:22:08 +08:00
```
2020-02-10 16:07:40 +08:00
$ bh bash
bashhub setup
docker pull nicksherron/bashhub-server
bin/bashhub-server version
untar bashhub-server_v0.1.0_darwin_amd64.tar.gz
cd bashhub-server_v0.1.0_darwin_amd64
./bashhub-server version
make build && bin/bashhub-server
cd bashhub-server
brew install bashhub-server/latest/bashhub-server
bashhub-server version
bashhub-server --help
```
With regex
2020-02-10 16:22:08 +08:00
```
2020-02-10 16:07:40 +08:00
$ bh '^bash'
bashhub setup
bashhub-server version
bashhub-server --help
2020-02-10 16:22:08 +08:00
```
2020-02-10 18:06:26 +08:00
all commands with only 6 letters
```
$ bh "^[a-zA-Z]{6}$"
2020-02-10 18:06:40 +08:00
2020-02-10 18:06:26 +08:00
whoami
ggpush
goland
ggpull
```