-
Notifications
You must be signed in to change notification settings - Fork 165
/
feed.sh
63 lines (57 loc) · 1.5 KB
/
feed.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/sh
# MihomoTProxy's feed
# check env
if [[ ! -x "/bin/opkg" && ! -x "/usr/bin/apk" || ! -x "/sbin/fw4" ]]; then
echo "only supports OpenWrt build with firewall4!"
exit 1
fi
# include openwrt_release
. /etc/openwrt_release
# get branch/arch
arch="$DISTRIB_ARCH"
branch=
case "$DISTRIB_RELEASE" in
*"23.05"*)
branch="openwrt-23.05"
;;
*"24.10"*)
branch="openwrt-24.10"
;;
"SNAPSHOT")
branch="SNAPSHOT"
;;
*)
echo "unsupported release: $DISTRIB_RELEASE"
exit 1
;;
esac
if [ -x "/bin/opkg" ]; then
# add key
echo "add key"
key_build_pub_file="key-build.pub"
curl -s -L -o "$key_build_pub_file" "https://github.com/morytyann/OpenWrt-mihomo/raw/refs/heads/main/key-build.pub"
opkg-key add "$key_build_pub_file"
rm -f "$key_build_pub_file"
# add feed
echo "add feed"
if (grep -q mihomo /etc/opkg/customfeeds.conf); then
sed -i '/mihomo/d' /etc/opkg/customfeeds.conf
fi
echo "src/gz mihomo https://morytyann.github.io/OpenWrt-mihomo/$branch/$arch/mihomo" >> /etc/opkg/customfeeds.conf
# update feeds
echo "update feeds"
opkg update
elif [ -x "/usr/bin/apk" ]; then
# add key
# todo: implement add key for apk
# add feed
echo "add feed"
if (grep -q mihomo /etc/apk/repositories.d/customfeeds.list); then
sed -i '/mihomo/d' /etc/apk/repositories.d/customfeeds.list
fi
echo "https://morytyann.github.io/OpenWrt-mihomo/$branch/$arch/mihomo/packages.adb" >> /etc/apk/repositories.d/customfeeds.list
# update feeds
echo "update feeds"
apk update --allow-untrusted
fi
echo "success"