mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 14:23:38 +00:00
add adbyby ram for 4M tiny rom
This commit is contained in:
parent
09e34de60a
commit
91217e1135
@ -142,7 +142,7 @@ menu "Target Images"
|
||||
int "Block size (in KiB)"
|
||||
depends on TARGET_ROOTFS_SQUASHFS
|
||||
default 64 if LOW_MEMORY_FOOTPRINT
|
||||
default 256
|
||||
default 1024
|
||||
|
||||
menuconfig TARGET_ROOTFS_UBIFS
|
||||
bool "ubifs"
|
||||
|
@ -13,11 +13,7 @@ __target_inc=1
|
||||
DEVICE_TYPE?=router
|
||||
|
||||
# Default packages - the really basic set
|
||||
DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd ip-full \
|
||||
iptables-mod-nat-extra kmod-nf-nathelper kmod-nf-nathelper-extra kmod-macvlan block-mount automount \
|
||||
default-settings ipset-lists luci luci-app-ddns luci-app-sqm luci-app-upnp luci-app-adbyby-plus luci-app-autoreboot \
|
||||
luci-app-filetransfer luci-app-shadowsocksr-pro luci-app-usb-printer luci-app-vsftpd ddns-scripts_aliyun luci-app-xlnetacc \
|
||||
luci-app-pptp-server luci-app-ipsec-vpnd luci-app-vlmcsd luci-app-wifischedule luci-app-wol luci-app-sfe luci-app-nlbwmon
|
||||
DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools uclient-fetch logd
|
||||
# For nas targets
|
||||
DEFAULT_PACKAGES.nas:=block-mount fdisk lsblk mdadm
|
||||
# For router targets
|
||||
|
105
package/lean/adbyby-ram/Makefile
Normal file
105
package/lean/adbyby-ram/Makefile
Normal file
@ -0,0 +1,105 @@
|
||||
#
|
||||
# Copyright (C) 2017 adbyby-ram
|
||||
# Copyright (C) 2017 yushi studio <ywb94@qq.com>
|
||||
#
|
||||
# This is free software, licensed under the GNU General Public License v3.
|
||||
# See /LICENSE for more information.
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=adbyby-ram
|
||||
PKG_VERSION:=1.0
|
||||
|
||||
|
||||
PKG_LICENSE:=GPLv3
|
||||
PKG_LICENSE_FILES:=LICENSE
|
||||
PKG_MAINTAINER:=yushi studio <ywb94@qq.com>
|
||||
|
||||
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
define Package/luci-app-adbyby-ram
|
||||
SECTION:=luci
|
||||
CATEGORY:=LuCI
|
||||
SUBMENU:=3. Applications
|
||||
TITLE:=adbyby-ram LuCI interface
|
||||
URL:=https://github.com/ywb94/adbyby-ram
|
||||
PKGARCH:=all
|
||||
endef
|
||||
|
||||
define Package/luci-app-adbyby-ram/description
|
||||
LuCI Support for adbyby-ram.
|
||||
endef
|
||||
|
||||
define Build/Prepare
|
||||
$(foreach po,$(wildcard ${CURDIR}/files/luci/i18n/*.po), \
|
||||
po2lmo $(po) $(PKG_BUILD_DIR)/$(patsubst %.po,%.lmo,$(notdir $(po)));)
|
||||
endef
|
||||
|
||||
define Build/Configure
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
define Package/luci-app-adbyby-ram/prerm
|
||||
#!/bin/sh
|
||||
# check if we are on real system
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
/etc/init.d/adbyby_ram disable
|
||||
/etc/init.d/adbyby_ram stop
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
define Package/luci-app-adbyby-ram/postinst
|
||||
#!/bin/sh
|
||||
if [ -z "$${IPKG_INSTROOT}" ]; then
|
||||
chmod 755 /etc/init.d/adbyby_ram >/dev/null 2>&1
|
||||
/etc/init.d/adbyby_ram enable >/dev/null 2>&1
|
||||
fi
|
||||
exit 0
|
||||
endef
|
||||
|
||||
ifeq ($(ARCH),mips)
|
||||
define Package/luci-app-adbyby-ram/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
|
||||
$(INSTALL_DATA) ./files/luci/controller/adbyby.lua $(1)/usr/lib/lua/luci/controller/adbyby.lua
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/adbyby.*.lmo $(1)/usr/lib/lua/luci/i18n
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
|
||||
$(INSTALL_DATA) ./files/luci/model/cbi/*.lua $(1)/usr/lib/lua/luci/model/cbi/
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) ./files/adbyby_ar71xx.sh $(1)/usr/bin/adbyby.sh
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/adbyby.config $(1)/etc/config/adbyby
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/adbyby.init $(1)/etc/init.d/adbyby_ram
|
||||
endef
|
||||
endif
|
||||
|
||||
ifeq ($(ARCH),mipsel)
|
||||
define Package/luci-app-adbyby-ram/install
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/controller
|
||||
$(INSTALL_DATA) ./files/luci/controller/adbyby.lua $(1)/usr/lib/lua/luci/controller/adbyby.lua
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/i18n
|
||||
$(INSTALL_DATA) $(PKG_BUILD_DIR)/adbyby.*.lmo $(1)/usr/lib/lua/luci/i18n
|
||||
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/model/cbi
|
||||
$(INSTALL_DATA) ./files/luci/model/cbi/*.lua $(1)/usr/lib/lua/luci/model/cbi/
|
||||
$(INSTALL_DIR) $(1)/usr/bin
|
||||
$(INSTALL_BIN) ./files/adbyby_ramips.sh $(1)/usr/bin/adbyby.sh
|
||||
$(INSTALL_DIR) $(1)/etc/config
|
||||
$(INSTALL_DATA) ./files/adbyby.config $(1)/etc/config/adbyby
|
||||
$(INSTALL_DIR) $(1)/etc/init.d
|
||||
$(INSTALL_BIN) ./files/adbyby.init $(1)/etc/init.d/adbyby_ram
|
||||
endef
|
||||
endif
|
||||
|
||||
$(eval $(call BuildPackage,luci-app-adbyby-ram))
|
3
package/lean/adbyby-ram/files/adbyby.config
Normal file
3
package/lean/adbyby-ram/files/adbyby.config
Normal file
@ -0,0 +1,3 @@
|
||||
|
||||
config adbyby 'adbyby'
|
||||
option enable '0'
|
58
package/lean/adbyby-ram/files/adbyby.init
Normal file
58
package/lean/adbyby-ram/files/adbyby.init
Normal file
@ -0,0 +1,58 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
|
||||
######################################################################
|
||||
#
|
||||
# Function : Run adbyby in RAM
|
||||
#
|
||||
# Creater : ywb94@qq.com, 2017-02-16
|
||||
#
|
||||
# Copyright : yushi studio
|
||||
#
|
||||
######################################################################
|
||||
|
||||
START=80
|
||||
|
||||
|
||||
start() {
|
||||
/etc/init.d/adbyby_ram enabled
|
||||
if [ $? == 1 ]; then
|
||||
return
|
||||
fi
|
||||
#不重复启动
|
||||
icount=`ps -w|grep adbyby.sh|grep -v grep|wc -l`
|
||||
icount2=`netstat -nautp|grep adbyby|grep -v grep|wc -l`
|
||||
|
||||
if [ $icount = 0 -a $icount2 = 0 ] ;then
|
||||
/usr/bin/adbyby.sh &
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
stop() {
|
||||
#确保清除防火墙规则
|
||||
i=0
|
||||
icount=`iptables -t nat -L|grep "ports 8118"|wc -l`
|
||||
while [ $i -le 10 -a $icount -gt 1 ]
|
||||
do
|
||||
let i=i+1
|
||||
iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8118
|
||||
icount=`iptables -t nat -L|grep "ports 8118"|wc -l`
|
||||
done
|
||||
|
||||
|
||||
if [ -f /tmp/adbyby/bin/stopadbb ] ;then
|
||||
cd /tmp/adbyby/bin
|
||||
./stopadbb 2>/dev/null
|
||||
fi
|
||||
|
||||
icount=`ps -w|grep adbyby.sh|grep -v grep|wc -l`
|
||||
if [ $icount -gt 0 ] ;then
|
||||
mid=`ps -w|grep adbyby.sh|grep -v grep|awk '{print $1}'`
|
||||
kill -9 $mid
|
||||
fi
|
||||
}
|
||||
|
||||
restart() {
|
||||
stop
|
||||
start
|
||||
}
|
49
package/lean/adbyby-ram/files/adbyby_ar71xx.sh
Normal file
49
package/lean/adbyby-ram/files/adbyby_ar71xx.sh
Normal file
@ -0,0 +1,49 @@
|
||||
#!/bin/sh
|
||||
cd /tmp
|
||||
#等待网络连接成功
|
||||
wget_ok="0"
|
||||
#rm -f 7620n.tar.gz
|
||||
rm -f ar71xx.tar.gz
|
||||
|
||||
while [ "$wget_ok" = "0" ]
|
||||
do
|
||||
#wget http://update.adbyby.com/download/7620n.tar.gz
|
||||
wget http://update.adbyby.com/download/ar71xx.tar.gz
|
||||
if [ "$?" == "0" ]; then
|
||||
wget_ok="1"
|
||||
else
|
||||
sleep 30
|
||||
fi
|
||||
done
|
||||
#解压、启动adbyby
|
||||
mkdir -p adbyby
|
||||
#tar -zvxf 7620n.tar.gz -C ./adbyby
|
||||
tar -zvxf ar71xx.tar.gz -C ./adbyby
|
||||
|
||||
#更新一次规则
|
||||
murl=`cat /tmp/adbyby/bin/update.info|grep lazy.txt|awk '{print $1}'`
|
||||
|
||||
if [ ${#murl} -gt 5 ] ;then
|
||||
murl2=`cat /tmp/adbyby/bin/update.info|grep lazy.txt|awk '{print $2}'`
|
||||
mfile="/tmp/adbyby/bin"${murl2//\\//}
|
||||
wget $murl -O $mfile
|
||||
fi
|
||||
|
||||
murl=`cat /tmp/adbyby/bin/update.info|grep video.txt|awk '{print $1}'`
|
||||
if [ ${#murl} -gt 5 ] ;then
|
||||
murl2=`cat /tmp/adbyby/bin/update.info|grep video.txt|awk '{print $2}'`
|
||||
mfile="/tmp/adbyby/bin"${murl2//\\//}
|
||||
wget $murl -O $mfile
|
||||
fi
|
||||
|
||||
murl=`cat /tmp/adbyby/bin/update.info|grep user.action|awk '{print $1}'`
|
||||
if [ ${#murl} -gt 5 ] ;then
|
||||
murl2=`cat /tmp/adbyby/bin/update.info|grep user.action|awk '{print $2}'`
|
||||
mfile="/tmp/adbyby/bin"${murl2//\\//}
|
||||
wget $murl -O $mfile
|
||||
fi
|
||||
|
||||
|
||||
cd ./adbyby/bin
|
||||
./startadbb
|
||||
|
48
package/lean/adbyby-ram/files/adbyby_ramips.sh
Normal file
48
package/lean/adbyby-ram/files/adbyby_ramips.sh
Normal file
@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
cd /tmp
|
||||
#等待网络连接成功
|
||||
wget_ok="0"
|
||||
rm -f 7620n.tar.gz
|
||||
#rm -f ar71xx.tar.gz
|
||||
|
||||
while [ "$wget_ok" = "0" ]
|
||||
do
|
||||
wget http://update.adbyby.com/download/7620n.tar.gz
|
||||
#wget http://update.adbyby.com/download/ar71xx.tar.gz
|
||||
if [ "$?" == "0" ]; then
|
||||
wget_ok="1"
|
||||
else
|
||||
sleep 30
|
||||
fi
|
||||
done
|
||||
#解压、启动adbyby
|
||||
mkdir -p adbyby
|
||||
tar -zvxf 7620n.tar.gz -C ./adbyby
|
||||
#tar -zvxf ar71xx.tar.gz -C ./adbyby
|
||||
|
||||
#更新一次规则
|
||||
murl=`cat /tmp/adbyby/bin/update.info|grep lazy.txt|awk '{print $1}'`
|
||||
|
||||
if [ ${#murl} -gt 5 ] ;then
|
||||
murl2=`cat /tmp/adbyby/bin/update.info|grep lazy.txt|awk '{print $2}'`
|
||||
mfile="/tmp/adbyby/bin"${murl2//\\//}
|
||||
wget $murl -O $mfile
|
||||
fi
|
||||
|
||||
murl=`cat /tmp/adbyby/bin/update.info|grep video.txt|awk '{print $1}'`
|
||||
if [ ${#murl} -gt 5 ] ;then
|
||||
murl2=`cat /tmp/adbyby/bin/update.info|grep video.txt|awk '{print $2}'`
|
||||
mfile="/tmp/adbyby/bin"${murl2//\\//}
|
||||
wget $murl -O $mfile
|
||||
fi
|
||||
|
||||
murl=`cat /tmp/adbyby/bin/update.info|grep user.action|awk '{print $1}'`
|
||||
if [ ${#murl} -gt 5 ] ;then
|
||||
murl2=`cat /tmp/adbyby/bin/update.info|grep user.action|awk '{print $2}'`
|
||||
mfile="/tmp/adbyby/bin"${murl2//\\//}
|
||||
wget $murl -O $mfile
|
||||
fi
|
||||
|
||||
cd ./adbyby/bin
|
||||
./startadbb
|
||||
|
10
package/lean/adbyby-ram/files/luci/controller/adbyby.lua
Normal file
10
package/lean/adbyby-ram/files/luci/controller/adbyby.lua
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
module("luci.controller.adbyby", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access("/etc/config/adbyby") then
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin","services", "adbyby"}, cbi("adbyby"), _("Adbyby"), 20)
|
||||
end
|
38
package/lean/adbyby-ram/files/luci/i18n/adbyby.zh-cn.po
Normal file
38
package/lean/adbyby-ram/files/luci/i18n/adbyby.zh-cn.po
Normal file
@ -0,0 +1,38 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "Not exist"
|
||||
msgstr "不存在"
|
||||
|
||||
msgid "AD Block"
|
||||
msgstr "广告屏蔽"
|
||||
|
||||
msgid "Disable"
|
||||
msgstr "停用"
|
||||
|
||||
msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Running Status"
|
||||
msgstr "运行状态"
|
||||
|
||||
msgid "Lazy rules time"
|
||||
msgstr "Lazy规则日期"
|
||||
|
||||
msgid "Video rules time"
|
||||
msgstr "Video规则日期"
|
||||
|
||||
msgid "Running"
|
||||
msgstr "运行中"
|
||||
|
||||
msgid "Not Running"
|
||||
msgstr "未运行"
|
||||
|
||||
msgid "Wait Connect.."
|
||||
msgstr "等待联网"
|
||||
|
||||
msgid "Enable Adbyby"
|
||||
msgstr "是否启用Adbyby"
|
||||
|
||||
msgid "Adbyby"
|
||||
msgstr "广告屏蔽"
|
72
package/lean/adbyby-ram/files/luci/model/cbi/adbyby.lua
Normal file
72
package/lean/adbyby-ram/files/luci/model/cbi/adbyby.lua
Normal file
@ -0,0 +1,72 @@
|
||||
|
||||
local m, s, o,oo
|
||||
local Run_flag=0
|
||||
local lazy_time=translate("Not exist")
|
||||
local video_time=translate("Not exist")
|
||||
local sys = require "luci.sys"
|
||||
icount=tonumber(sys.exec("ps -w | grep adbyby |grep -v grep| wc -l"))
|
||||
if tonumber(icount)>0 then
|
||||
icount=tonumber(sys.exec("netstat -nautp | grep adbyby |grep -v grep| wc -l"))
|
||||
if tonumber(icount)>0 then
|
||||
Run_flag=1
|
||||
else
|
||||
Run_flag=2
|
||||
end
|
||||
end
|
||||
|
||||
if nixio.fs.access("/tmp/adbyby/bin/data/lazy.txt") then
|
||||
time_cmd="awk 'NR==1{print $3\" \"$4}' /tmp/adbyby/bin/data/lazy.txt"
|
||||
lazy_time=sys.exec(time_cmd)
|
||||
end
|
||||
|
||||
if nixio.fs.access("/tmp/adbyby/bin/data/video.txt") then
|
||||
time_cmd="awk 'NR==1{print $3\" \"$4}' /tmp/adbyby/bin/data/video.txt"
|
||||
video_time=sys.exec(time_cmd)
|
||||
end
|
||||
m = Map("adbyby", translate("AD Block"))
|
||||
|
||||
|
||||
s = m:section(NamedSection, "adbyby","adbyby", "")
|
||||
s.addremove = false
|
||||
|
||||
oo = s:option(ListValue, "enable",translate("Enable Adbyby"))
|
||||
oo:value("0", translate("Disable"))
|
||||
oo:value("1", translate("Enable"))
|
||||
oo.widget = "radio"
|
||||
oo.advance_second_title = true
|
||||
oo.orientation = "horizontal"
|
||||
|
||||
o=s:option(DummyValue, "runstatus",translate("Running Status"))
|
||||
o.rawhtml = true
|
||||
if Run_flag==1 then
|
||||
o.value="<font color='green'>" .. translate("Running") .. "</font>"
|
||||
elseif Run_flag==0 then
|
||||
o.value="<font color='red'>" .. translate("Not Running") .. "</font>"
|
||||
else
|
||||
o.value="<font color='blue'>" .. translate("Wait Connect..") .. "</font>"
|
||||
end
|
||||
|
||||
o=s:option(DummyValue, "version1",translate("Lazy rules time"))
|
||||
o.rawhtml = true
|
||||
o.value="<font color='blue'>" .. lazy_time .. "</font>"
|
||||
|
||||
o=s:option(DummyValue, "version2",translate("Video rules time"))
|
||||
o.rawhtml = true
|
||||
o.value="<font color='blue'>" .. video_time .. "</font>"
|
||||
|
||||
local apply = luci.http.formvalue("cbi.apply")
|
||||
if apply then
|
||||
local m_enable=luci.http.formvalue("cbid.adbyby.adbyby.enable")
|
||||
if m_enable=="0" then
|
||||
luci.sys.call("/etc/init.d/adbyby_ram disable")
|
||||
luci.sys.call("/etc/init.d/adbyby_ram stop")
|
||||
else
|
||||
luci.sys.call("/etc/init.d/adbyby_ram enable")
|
||||
luci.sys.call("/etc/init.d/adbyby_ram start")
|
||||
end
|
||||
|
||||
|
||||
--luci.http.redirect(luci.dispatcher.build_url("admin/services/adbyby"))
|
||||
end
|
||||
|
||||
return m
|
Loading…
Reference in New Issue
Block a user