-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink.sh
executable file
·47 lines (32 loc) · 1.17 KB
/
link.sh
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
set -eo pipefail
cd "$(dirname "${BASH_SOURCE}")";
if [[ ! -f 'readme.md' ]]; then
echo 'readme.md file is not in pwd, something is wrong.';
exit 1;
fi
#pth_to_make="$GOPATH/src/ores/json-logging"
go_proj_path="$GOPATH/src/github.com/oresoftware/json-logging"
tmp_path="/tmp/gotemp/json-logging"
mkdir -p "$go_proj_path"
mkdir -p "$tmp_path"
if [[ ! -d "$go_proj_path" ]]; then
echo "$0: The following path does not exist: $go_proj_path"
echo "$0: The above path needs to exist in order for this script to proceed.";
exit 1;
fi
if [[ -L "$go_proj_path" ]]; then
echo "$0: The following path is already symlinked: $go_proj_path"
echo "$0: The above path is symlinked to '$(realpath "$go_proj_path")'..."
if [[ "$(realpath "$go_proj_path")" != "$tmp_path" ]]; then
echo "But the symlinked path does not match the expected path: $tmp_path"
fi
exit 1;
fi
rm -rf "$tmp_path"
mv "$go_proj_path" "$tmp_path"
#rm -rf "$GOPATH/src/github.com/oresoftware/json-logging"
#mv "/tmp/gotemp/json-logging" "$GOPATH/src/github.com/oresoftware/json-logging" # put it back
#mkdir -p "$pth_to_make";
#rm -rf "$pth_to_make";
ln -sf "$PWD" "$go_proj_path";