-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 7344b22
Showing
30 changed files
with
1,647 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
release.tgz | ||
build | ||
build/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Copyright 2020 Cobin Bluth | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# gsh : The Missing Host Manager | ||
|
||
`gsh` intends to offer a new way to manage sets of hosts and a collection of accompanying scripts and files. | ||
You can organize your inventory of hosts with groups and labels. You can add scripts and files (like configs) to your inventory. Then, `gsh` works over ssh, and you can execute scripts and/or copy files en masse to your groups of servers. | ||
See TODO section below for future plans. | ||
|
||
### Requirements | ||
|
||
This should work on any linux host, like your workstation. Mac os builds are being tested. | ||
Access to some ssh servers is needed to use all the features of `gsh`. Currently only bash is supported, with plans for more languages. | ||
|
||
### Installation | ||
|
||
#### A) Use Go Install | ||
To build with go install: | ||
```bash | ||
$ go install github.com/cbluth/gsh | ||
``` | ||
|
||
#### B) Clone via git, and build in docker | ||
|
||
To build in docker, golang not need to be installed: | ||
```bash | ||
$ git clone https://github.com/cbluth/gsh && cd gsh | ||
$ ./build.sh # this will make a `release.tgz` file | ||
$ tar -xzvf release.tgz # makes linux and mac builds | ||
$ sudo cp ./build/gsh-linux /usr/local/bin/gsh | ||
$ sudo chmod a+rx /usr/local/bin/gsh | ||
``` | ||
|
||
#### C) Clone via git, and build locally | ||
|
||
|
||
To build with go build: | ||
```bash | ||
$ git clone https://github.com/cbluth/gsh && cd gsh | ||
$ go build . -o gsh | ||
$ sudo cp gsh /usr/local/bin/gsh | ||
$ sudo chmod a+rx /usr/local/bin/gsh | ||
``` | ||
|
||
## How To Use It?? | ||
|
||
You can use `gsh` to execute scripts over ssh, and manage an inventory of servers.<br /> | ||
For usage, see [the docs](docs/) | ||
|
||
## Hack or Contribute | ||
This project intentionally avoids importing 3rd party libraries, and tries to stick to the basic libraries provided by golang. | ||
All contributions and bug reports are welcome, please just open an issue on the github issues page. | ||
This is a new project, with lots of issues, if you see any bugs, please report them! :) | ||
|
||
To hack on this project, git clone to anywhere, and edit the code directly. | ||
After applying edits to the codebase, you can use `./gsh.sh` to compile and run `gsh` via go, with the same arguments as running the program normally; eg: `./gsh.sh make host dev0 address=dev0.local` | ||
|
||
## License | ||
|
||
This project is licensed under the MIT License, see the [LICENSE](LICENSE) file for details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# builds the project in temp docker env | ||
# | ||
set -e | ||
|
||
PROJECT="$(grep module go.mod | awk '{print $2}')" | ||
SCRIPTPATH="$(dirname "$(readlink -f "${0}")")" | ||
DOCKERTAG="${PROJECT}-build:tmp" | ||
BINARY="${PROJECT}" | ||
SILENT="${1}" # ./build.sh -s | ||
DOCKERFILE="$(cat << EOF | ||
FROM golang:latest as build | ||
SHELL ["/bin/bash", "-c"] | ||
WORKDIR /build | ||
ADD . /build | ||
RUN GOOS=linux GOARCH=amd64 go build \ | ||
-a \ | ||
-o /build/${PROJECT}-linux \ | ||
. | ||
RUN GOOS=darwin GOARCH=amd64 go build \ | ||
-a \ | ||
-o /build/${PROJECT}-darwin \ | ||
. | ||
FROM golang:latest | ||
COPY --from=build /build/${PROJECT}-linux /build/ | ||
COPY --from=build /build/${PROJECT}-darwin /build/ | ||
CMD ["bash", "-c", "tar -cv /build/ | gzip"] | ||
EOF | ||
)" | ||
|
||
spinner() | ||
{ | ||
# http://fitnr.com/showing-a-bash-spinner.html | ||
local pid=$1 | ||
local delay=0.15 | ||
local spinstr='|/-\' | ||
while [ "$(ps a | awk '{print $1}' | grep $pid)" ]; do | ||
local temp=${spinstr#?} | ||
printf " [%c] " "$spinstr" | ||
local spinstr=$temp${spinstr%"$temp"} | ||
sleep $delay | ||
printf "\b\b\b\b\b\b" | ||
done | ||
printf " \b\b\b\b" | ||
} | ||
|
||
build() | ||
{ | ||
pushd "${SCRIPTPATH}/" > /dev/null 2>&1 | ||
echo | ||
echo "Using temporary docker build environment..." | ||
echo | ||
docker build \ | ||
-t "${DOCKERTAG}" \ | ||
-f - \ | ||
. <<< "${DOCKERFILE}" | ||
docker run --rm "${DOCKERTAG}" > "release.tgz" | ||
# docker rmi "${DOCKERTAG}" | ||
# chmod a+rx "${BINARY}" | ||
echo | ||
# echo "Removed temporary build environment" | ||
# echo | ||
popd > /dev/null 2>&1 | ||
echo -n "Build time:" | ||
} | ||
|
||
echo -n "Building... " | ||
if [[ ! "${SILENT}" == "-s" ]] ; then | ||
( | ||
time build | ||
echo | ||
# echo "${PROJECT^^} project executable: ${HOME}/.local/bin/${BINARY}" | ||
# echo | ||
) & | ||
else | ||
(build) > /dev/null 2>&1 & | ||
fi | ||
|
||
spinner $! | ||
|
||
# cp "${BINARY}" "${HOME}/.local/bin/" | ||
|
||
echo "Done!" |
Oops, something went wrong.