Skip to content

Commit

Permalink
needs testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jpillora committed Aug 9, 2022
1 parent b4a6994 commit 7b66312
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@ module github.com/jpillora/installer

go 1.18

require github.com/jpillora/opts v1.1.2
require (
github.com/jpillora/opts v1.1.2
github.com/jpillora/requestlog v1.0.0
)

require (
github.com/andrew-d/go-termutil v0.0.0-20150726205930-009166a695a2 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-multierror v1.0.0 // indirect
github.com/jpillora/ansi v1.0.2 // indirect
github.com/jpillora/requestlog v1.0.0 // indirect
github.com/jpillora/sizestr v1.0.0 // indirect
github.com/posener/complete v1.2.2-0.20190308074557-af07aa5181b3 // indirect
github.com/tomasen/realip v0.0.0-20180522021738-f0c99a92ddce // indirect
Expand Down
14 changes: 12 additions & 2 deletions scripts/install.sh.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,18 @@ function install {
fi
#move into PATH or cwd
chmod +x $TMP_BIN || fail "chmod +x failed"
{{ if .SudoMove }}echo "using sudo to move binary..."{{ end }}
{{ if .SudoMove }}sudo {{ end }}mv $TMP_BIN $OUT_DIR/$PROG || fail "mv failed" #FINAL STEP!
#move without sudo
OUT=$(mv $TMP_BIN $OUT_DIR/$PROG 2>&1)
STATUS=$?
# failed and string contains "permission denied"
if [ $STATUS -ne 0 ]; then
if [[ $OUT =~ "permission denied" ]]; then
echo "mv with sudo..."
sudo mv $TMP_BIN $OUT_DIR/$PROG || fail "mv failed"
else
fail "mv failed"
fi
fi
echo "{{ if .MoveToPath }}Installed at{{ else }}Downloaded to{{ end }} $OUT_DIR/$PROG"
#done
cleanup
Expand Down

0 comments on commit 7b66312

Please sign in to comment.