30 lines
971 B
Bash
Executable file
30 lines
971 B
Bash
Executable file
#!/bin/sh
|
|
# install.sh — symlink smart-lan-router/bin/* into the first PATH dir that
|
|
# exists ($HOME/bin, then $HOME/.local/bin). Idempotent.
|
|
#
|
|
# The tools locate data/mesh-hosts.json by resolving their own symlink chain and
|
|
# walking up to the repo, so running them via the installed symlink works the
|
|
# same as running them from the repo dir.
|
|
|
|
set -eu
|
|
|
|
repo_dir=$(cd "$(dirname "$0")" && pwd)
|
|
|
|
target=""
|
|
for candidate in "$HOME/bin" "$HOME/.local/bin"; do
|
|
if [ -d "$candidate" ]; then target="$candidate"; break; fi
|
|
done
|
|
[ -n "$target" ] || { mkdir -p "$HOME/.local/bin"; target="$HOME/.local/bin"; }
|
|
|
|
echo "installing into $target"
|
|
for src in "$repo_dir"/bin/*; do
|
|
[ -f "$src" ] || continue
|
|
name=$(basename "$src")
|
|
link="$target/$name"
|
|
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 "ok: $name -> $src"
|
|
done
|