summaryrefslogtreecommitdiff
path: root/doc/special_remotes
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2013-12-27 14:30:00 -0400
committerGravatar Joey Hess <joey@kitenet.net>2013-12-27 14:30:00 -0400
commitce82c8985963aacdd991507c305523eed130a81b (patch)
treef392f9419ae559eef827c6cc4d7481fcf7932a9b /doc/special_remotes
parente7af7e2c476f07a3d314503a30c61e2e97d7275f (diff)
make directory absolute (mostly as an example of using SETCONFIG)
Diffstat (limited to 'doc/special_remotes')
-rwxr-xr-xdoc/special_remotes/external/example.sh18
1 files changed, 15 insertions, 3 deletions
diff --git a/doc/special_remotes/external/example.sh b/doc/special_remotes/external/example.sh
index 60425dfac..97f8a2813 100755
--- a/doc/special_remotes/external/example.sh
+++ b/doc/special_remotes/external/example.sh
@@ -21,6 +21,11 @@ getconfig () {
ask GETCONFIG "$1"
}
+# Stores a value in the remote's configuration.
+setconfig () {
+ echo SETCONFIG "$1" "$2"
+}
+
# Sets LOC to the location to use to store a key.
calclocation () {
ask DIRHASH "$1"
@@ -60,13 +65,20 @@ while read line; do
# (Note that this is not run every time, only when
# git annex initremote or git annex enableremote is
# run.)
+
getconfig directory
- mydirectory="$RET"
+ # Input directory could be relative; make it
+ # absolute, and store that.
+ mydirectory="$(readlink -f "$RET")"
+ setconfig directory "$mydirectory"
if [ -z "$mydirectory" ]; then
echo INITREMOTE-FAILURE "You need to set directory="
else
- mkdir -p "$mydirectory"
- echo INITREMOTE-SUCCESS
+ if mkdir -p "$mydirectory"; then
+ echo INITREMOTE-SUCCESS
+ else
+ echo INITREMOTE-FAILURE "Failed to write to $mydirectory"
+ fi
fi
;;
PREPARE)