32 lines
779 B
Bash
32 lines
779 B
Bash
|
|
#!/bin/sh
|
||
|
|
# install.sh — symlink session-tools/bin/* into ~/bin (idempotent).
|
||
|
|
#
|
||
|
|
# Run this on every host that should have remote-run / tssh available.
|
||
|
|
|
||
|
|
set -eu
|
||
|
|
|
||
|
|
repo_dir=$(cd "$(dirname "$0")" && pwd)
|
||
|
|
target=${HOME}/bin
|
||
|
|
|
||
|
|
mkdir -p "$target"
|
||
|
|
|
||
|
|
for src in "$repo_dir"/bin/*; do
|
||
|
|
name=$(basename "$src")
|
||
|
|
link="$target/$name"
|
||
|
|
if [ -L "$link" ] && [ "$(readlink "$link")" = "$src" ]; then
|
||
|
|
echo "ok: $link -> $src"
|
||
|
|
continue
|
||
|
|
fi
|
||
|
|
if [ -e "$link" ] && [ ! -L "$link" ]; then
|
||
|
|
echo "skip: $link exists and is not a symlink — leaving alone" >&2
|
||
|
|
continue
|
||
|
|
fi
|
||
|
|
ln -sfn "$src" "$link"
|
||
|
|
echo "link: $link -> $src"
|
||
|
|
done
|
||
|
|
|
||
|
|
case ":$PATH:" in
|
||
|
|
*":$target:"*) ;;
|
||
|
|
*) echo "note: add $target to PATH if it isn't already" ;;
|
||
|
|
esac
|