Skip to content

Instantly share code, notes, and snippets.

@d0zingcat
Created February 7, 2022 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d0zingcat/5d60819bae88b3d91dfbe6c3d8d206a0 to your computer and use it in GitHub Desktop.
Save d0zingcat/5d60819bae88b3d91dfbe6c3d8d206a0 to your computer and use it in GitHub Desktop.
bootstrap for openwrt on r2s
#!/bin/sh
set -x
install_openclash() {
opkg remove dnsmasq
opkg install dnsmasq-full
opkg install luci
opkg install luci-base
opkg install iptables opkg install coreutils
opkg install coreutils-nohup
opkg install bash
opkg install curl
opkg install jsonfilter
opkg install ca-certificates
opkg install ipset
opkg install ip-full
opkg install iptables-mod-tproxy
opkg install kmod-tun #TUN模式
opkg install luci-compat
repo_path='vernesong/OpenClash'
latest_tag=$(get_latest_release $repo_path)
if [ -n $latest_tag ]
then
ipk_url=$(get_release_by_tag $repo_path $latest_tag)
proxy_url=$(echo $ipk_url | sed 's/github.com/github.com.cnpmjs.org/')
echo $proxy_url
curl -L $proxy_url -O
filename=$(basename $proxy_url)
echo $filename
opkg install $filename
fi
}
install_essentials() {
opkg install vim
}
update_dist_source() {
sed 's|https://downloads.openwrt.org/|https://mirror.sjtu.edu.cn/openwrt/|g' /etc/opkg/distfeeds.conf -i
opkg update
}
get_latest_release() {
curl -s "https://api.github.com/repos/$1/releases?page=1&per_page=1" | # Get latest release from GitHub api
grep '"tag_name":' | # Get tag line
sed -E 's/.*"([^"]+)".*/\1/' # Pluck JSON value
}
get_release_by_tag() {
curl -s "https://api.github.com/repos/$1/releases/tags/$2" |
grep '"browser_download_url":' |
sed -E 's/.*"([^"]+)".*/\1/'
}
pwd=`pwd`
cd /tmp
#update_dist_source
#install_essentials
#install_openclash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment