summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSean E. Russell <ser@ser1.net>2020-05-24 14:19:10 -0500
committerSean E. Russell <ser@ser1.net>2020-05-24 14:19:10 -0500
commit06ee1ad9491f762d28fb1a748a1af6f8c37eec90 (patch)
treee1e215651af213def730e88bd1fa8d3917366262
parent76236a0993013788573fc53dc8b0a563b2fc1639 (diff)
Merges #125 from @wcdawn, with some minor modifications.
-rw-r--r--README.md2
-rwxr-xr-xscripts/install_without_root.sh45
2 files changed, 47 insertions, 0 deletions
diff --git a/README.md b/README.md
index 9ec4b3d..f773c1c 100644
--- a/README.md
+++ b/README.md
@@ -62,6 +62,8 @@ go build -o gotop ./cmd/gotop
Move `gotop` to somewhere in your `$PATH`.
+If Go is not installed or is the wrong version, and you don't have root access or don't want to upgrade Go, a script is provided to download Go and the gotop sources, compile gotop, and then clean up. See `scripts/install_without_root.sh`.
+
## Usage
Run with `-h` to get an extensive list of command line arguments. Many of these can be configured by creating a configuration file; see the next section for more information. Key bindings can be viewed while gotop is running by pressing the `?` key, or they can be printed out by using the `--list keys` command.
diff --git a/scripts/install_without_root.sh b/scripts/install_without_root.sh
new file mode 100755
index 0000000..9bdf839
--- /dev/null
+++ b/scripts/install_without_root.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+#
+# Builds the gotop executable on machines where Go isn't installed,
+# or is the wrong version, and you don't have root access to upgrade or
+# install Go.
+#
+# You can run this without cloning the entire gotop repository (the script
+# will do this for you.)
+
+set -x
+
+VERSION='1.14.2' # Go version needed to build
+OS='linux'
+ARCH='amd64'
+BUILDDIR=/tmp/gotop-build
+INSTALLDIR=${HOME}/bin
+
+GO_NAME=go${VERSION}.${OS}-${ARCH}
+
+mkdir -p $BUILDDIR
+cd $BUILDDIR
+
+curl https://dl.google.com/go/${GO_NAME}.tar.gz --output ./${GO_NAME}.tar.gz
+
+tar -vxzf ${GO_NAME}.tar.gz
+rm ${GO_NAME}.tar.gz
+
+PATH=$BUILDDIR/go/bin:$PATH
+
+go env -w GOPATH=$BUILDDIR # otherwise go would create a directory in $HOME
+
+rm -rf ./gotop
+git clone https://github.com/xxxserxxx/gotop.git
+cd ./gotop
+go build -o gotop ./cmd/gotop
+
+go clean -modcache # otherwise $BUILDDIR/pkg would need sudo permissions to remove
+
+mkdir -p $INSTALLDIR
+mv gotop ${INSTALLDIR}/gotop
+
+rm -rf $BUILDDIR
+
+printf "gotop installed in ${INSTALLDIR}/gotop\n"
+