blob: a297cf2c4b4dd70caeface2ab3b5e8260ca58ebf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/bin/bash
# Wrapper that runs the gocryptfs process in the background
# and exits on SIGUSR1
#
# Written in shell because Go does not support daemonization natively
set -eu
trap "exit 0" SIGUSR1
shopt -u huponexit
dir=$(dirname $(readlink -f "$0"))
main="$dir/gocryptfs_main"
if [ ! -x "$main" ]
then
main="$GOPATH/bin/gocryptfs_main"
fi
if [ ! -x "$main" ]
then
echo "Error: gocryptfs_main executable not found. Run ./all.bash to build it."
exit 1
fi
# A backgrounded process gets /dev/null as stdin per default.
# Explicitly set stdin to the current stdin so we can ask the user for input.
"$main" $* < /proc/self/fd/0 & wait
# The "& wait" is neccessary because bash only processes signals when
# executing internal commands
# We did not get USR1 - something went wrong
exit 1
|