32 lines
1.2 KiB
Bash
Executable File
32 lines
1.2 KiB
Bash
Executable File
#!/bin/sh
|
|
# One-command setup of mihomo-kit on OpenWrt (nikki), over ssh on the router:
|
|
# wget -qO- https://git.sam-hub.net/sam/mihomo-kit/raw/branch/main/install.sh | sh
|
|
# or after tools/push.sh from a computer:
|
|
# sh /etc/nikki/kit/install.sh
|
|
# Installs nikki if needed, asks a few questions, builds the profiles and starts one.
|
|
set -eu
|
|
KIT_URL=${KIT_URL:-https://git.sam-hub.net/sam/mihomo-kit/archive/main.tar.gz}
|
|
KIT_DIR=/etc/nikki/kit
|
|
|
|
here=$(cd "$(dirname "$0")" 2>/dev/null && pwd || echo /nonexistent)
|
|
mkdir -p "$KIT_DIR"
|
|
if [ -f "$here/router/mihomo-kit.sh" ]; then
|
|
[ "$here" = "$KIT_DIR" ] || cp -r "$here/templates" "$here/presets" "$here/router" "$here/luci" "$KIT_DIR/"
|
|
else
|
|
tmp=/tmp/mihomo-kit.$$
|
|
mkdir -p "$tmp"
|
|
echo "downloading $KIT_URL"
|
|
wget -qO "$tmp/kit.tgz" "$KIT_URL"
|
|
tar xzf "$tmp/kit.tgz" -C "$tmp"
|
|
src=$(find "$tmp" -path '*/router/mihomo-kit.sh' | head -n 1)
|
|
[ -n "$src" ] || { echo "error: no router/mihomo-kit.sh in $KIT_URL" >&2; exit 1; }
|
|
src=${src%/router/mihomo-kit.sh}
|
|
for d in templates presets router luci; do
|
|
rm -rf "${KIT_DIR:?}/$d"
|
|
cp -r "$src/$d" "$KIT_DIR/"
|
|
done
|
|
rm -rf "$tmp"
|
|
fi
|
|
# stdin may be the piped script: the wizard reads answers from /dev/tty
|
|
exec sh "$KIT_DIR/router/mihomo-kit.sh" setup
|