Skip to content

Commit b88d470

Browse files
committed
chore: more versatile tools
1 parent 5fc80cb commit b88d470

File tree

4 files changed

+47
-31
lines changed

4 files changed

+47
-31
lines changed

tools/git/tool/setup.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ export TOOL_DIR=${TOOL_DIR:-/opt/tools/git}
66

77
mkdir -p $TOOL_DIR $TOOL_DIR/bin $TOOL_DIR/lib $TOOL_DIR/libexec $TOOL_DIR/share
88

9-
cp -r ./bin $TOOL_DIR/bin
10-
cp -r ./lib $TOOL_DIR/lib
11-
cp -r ./libexec $TOOL_DIR/libexec
12-
cp -r ./share $TOOL_DIR/share
9+
if [ "$(pwd -P)" != "$TOOL_DIR" ]; then
10+
cp -r ./bin "$TOOL_DIR/bin"
11+
cp -r ./lib "$TOOL_DIR/lib"
12+
cp -r ./libexec "$TOOL_DIR/libexec"
13+
cp -r ./share "$TOOL_DIR/share"
14+
else
15+
printf 'Skipping copy: current directory is %s\n' "$TOOL_DIR" >&2
16+
fi
1317

14-
ln -s $TOOL_DIR/bin/git /usr/local/bin/git
15-
ln -s $TOOL_DIR/bin/git-cvsserver /usr/local/bin/git-cvsserver
16-
ln -s $TOOL_DIR/bin/git-remote-http /usr/local/bin/git-remote-http
17-
ln -s $TOOL_DIR/bin/git-remote-https /usr/local/bin/git-remote-https
18-
ln -s $TOOL_DIR/bin/git-shell /usr/local/bin/git-shell
19-
ln -s $TOOL_DIR/bin/git-upload-archive /usr/local/bin/git-upload-archive
20-
ln -s $TOOL_DIR/bin/git-upload-pack /usr/local/bin/git-upload-pack
21-
ln -s $TOOL_DIR/bin/gitk /usr/local/bin/gitk
22-
ln -s $TOOL_DIR/bin/scalar /usr/local/bin/scalar
18+
for f in "$TOOL_DIR/bin"/*; do
19+
[ -e "$f" ] || continue # skip if glob didn't match
20+
[ -d "$f" ] && continue # skip directories
21+
name="${f##*/}"
22+
ln -sf "$f" "/usr/local/bin/$name"
23+
done

tools/node/tool/setup.sh

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,19 @@ set -eux
44

55
export TOOL_DIR=${TOOL_DIR:-/opt/tools/node}
66

7-
mkdir -p ${TOOL_DIR}
8-
cp -r ./bin ${TOOL_DIR}/bin
9-
cp -r ./include ${TOOL_DIR}/include
10-
cp -r ./lib ${TOOL_DIR}/lib
11-
cp -r ./share ${TOOL_DIR}/share
7+
if [ "$(pwd -P)" != "$TOOL_DIR" ]; then
8+
mkdir -p ${TOOL_DIR}
9+
cp -r ./bin ${TOOL_DIR}/bin
10+
cp -r ./include ${TOOL_DIR}/include
11+
cp -r ./lib ${TOOL_DIR}/lib
12+
cp -r ./share ${TOOL_DIR}/share
13+
else
14+
printf 'Skipping copy: current directory is %s\n' "$TOOL_DIR" >&2
15+
fi
1216

13-
ln -s ${TOOL_DIR}/bin/corepack /usr/local/bin/corepack
14-
ln -s ${TOOL_DIR}/bin/node /usr/local/bin/node
15-
ln -s ${TOOL_DIR}/bin/npm /usr/local/bin/npm
16-
ln -s ${TOOL_DIR}/bin/npx /usr/local/bin/npx
17+
for f in "$TOOL_DIR/bin"/*; do
18+
[ -e "$f" ] || continue # skip if glob didn't match
19+
[ -d "$f" ] && continue # skip directories
20+
name="${f##*/}"
21+
ln -sf "$f" "/usr/local/bin/$name"
22+
done

tools/postgres/tool/setup.sh

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ set -eux
44

55
export TOOL_DIR=${TOOL_DIR:-/opt/tools/postgres}
66

7-
mkdir -p ${TOOL_DIR}
8-
cp -r ./bin ${TOOL_DIR}/bin
9-
cp -r ./include ${TOOL_DIR}/include
10-
cp -r ./lib ${TOOL_DIR}/lib
11-
cp -r ./share ${TOOL_DIR}/share
7+
if [ "$(pwd -P)" != "$TOOL_DIR" ]; then
8+
mkdir -p ${TOOL_DIR}
9+
cp -r ./bin ${TOOL_DIR}/bin
10+
cp -r ./include ${TOOL_DIR}/include
11+
cp -r ./lib ${TOOL_DIR}/lib
12+
cp -r ./share ${TOOL_DIR}/share
13+
else
14+
printf 'Skipping copy: current directory is %s\n' "$TOOL_DIR" >&2
15+
fi
1216

1317
for f in "${TOOL_DIR}/bin"/*; do
1418
[ -e "$f" ] || continue # skip if glob didn't match

tools/zsh/tool/setup.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,15 @@ set -eux
44

55
export TOOL_DIR=${TOOL_DIR:-/opt/tools/zsh}
66

7-
mkdir -p $TOOL_DIR
8-
cp -r ./bin $TOOL_DIR/bin
9-
cp -r ./lib $TOOL_DIR/lib
10-
cp -r ./share $TOOL_DIR/share
7+
if [ "$(pwd -P)" != "$TOOL_DIR" ]; then
8+
mkdir -p ${TOOL_DIR}
9+
cp -r ./bin ${TOOL_DIR}/bin
10+
cp -r ./include ${TOOL_DIR}/include
11+
cp -r ./lib ${TOOL_DIR}/lib
12+
cp -r ./share ${TOOL_DIR}/share
13+
else
14+
printf 'Skipping copy: current directory is %s\n' "$TOOL_DIR" >&2
15+
fi
1116

1217
for f in "$TOOL_DIR/bin"/*; do
1318
[ -e "$f" ] || continue # skip if glob didn't match

0 commit comments

Comments
 (0)