From 552c32c5e9378b85e52c420c4dd2d7ccc827556f Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Mon, 5 Oct 2015 20:32:10 +0200 Subject: [PATCH] Move main binary to gocryptfs_main That way the wrapper shell script can be named just "gocryptfs" --- .gitignore | 2 +- all.bash | 8 ++++++++ benchmark.bash | 2 ++ gocryptfs | 22 +++++++++++++++++++++ gocryptfs.sh | 14 ------------- main.go => gocryptfs_main/main.go | 0 main_test.go => gocryptfs_main/main_test.go | 4 ++-- 7 files changed, 35 insertions(+), 17 deletions(-) create mode 100755 all.bash create mode 100755 gocryptfs delete mode 100755 gocryptfs.sh rename main.go => gocryptfs_main/main.go (100%) rename main_test.go => gocryptfs_main/main_test.go (98%) diff --git a/.gitignore b/.gitignore index 6072ebf..4e4ddae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ # binary -/gocryptfs +/gocryptfs_main/gocryptfs_main # temporary files created by the tests /tmp diff --git a/all.bash b/all.bash new file mode 100755 index 0000000..08bc7cf --- /dev/null +++ b/all.bash @@ -0,0 +1,8 @@ +#!/bin/bash + +set -eu + +cd gocryptfs_main +echo -n "Compiling... " +go build +echo "done." diff --git a/benchmark.bash b/benchmark.bash index 447581a..baba0f1 100755 --- a/benchmark.bash +++ b/benchmark.bash @@ -2,5 +2,7 @@ set -eux +cd gocryptfs_main + go build go test -bench=. diff --git a/gocryptfs b/gocryptfs new file mode 100755 index 0000000..ce15b97 --- /dev/null +++ b/gocryptfs @@ -0,0 +1,22 @@ +#!/bin/bash + +# Simple wrapper that runs the gocryptfs process in the background + +set -eu + +dir=$(dirname "$0") +main="$dir/gocryptfs_main/gocryptfs_main" + +if [ ! -x $main ]; then + echo "Error: gocryptfs_main executable not found. Run ./all.bash to build it." + exit 1 +fi + +# This needs user input and cannot run in the background +if [[ $* == *--init* ]]; then + "$main" $* +else + "$main" $* & + sleep 0.1 + disown +fi diff --git a/gocryptfs.sh b/gocryptfs.sh deleted file mode 100755 index 689708c..0000000 --- a/gocryptfs.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -# Run the gocryptfs process in the background - -set -eu - -dir=$(dirname "$0") - -# This needs user input and cannot run in the background -if [[ $* == *--init* ]]; then - "$dir/gocryptfs" $* -else - "$dir/gocryptfs" $* & disown -fi diff --git a/main.go b/gocryptfs_main/main.go similarity index 100% rename from main.go rename to gocryptfs_main/main.go diff --git a/main_test.go b/gocryptfs_main/main_test.go similarity index 98% rename from main_test.go rename to gocryptfs_main/main_test.go index 2f606bc..218c256 100644 --- a/main_test.go +++ b/gocryptfs_main/main_test.go @@ -13,7 +13,7 @@ import ( "time" ) -const tmpDir = "tmp/" +const tmpDir = "../tmp/" const plainDir = tmpDir + "plain/" const cipherDir = tmpDir + "cipher/" @@ -53,7 +53,7 @@ func TestMain(m *testing.M) { } //c := exec.Command("./gocryptfs", "--zerokey", "--cpuprofile", "/tmp/gcfs.cpu", cipherDir, plainDir) - c := exec.Command("./gocryptfs", "--zerokey", cipherDir, plainDir) + c := exec.Command("./gocryptfs_main", "--zerokey", cipherDir, plainDir) c.Stdout = os.Stdout c.Stderr = os.Stderr go c.Run()