mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-02 08:53:56 +08:00
This commit is contained in:
1 parent
f6683ec9ac
commit
7b7c6e31cd
18 files changed
+976
-544
No files matched your search
+16
-13
@@ -1,17 +1,14 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-only
|
||||
#
|
||||
# Copyright (C) 2021-2025 sirpdboy <herboy2008@gmail.com>
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
#
|
||||
#
|
||||
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=lucky
|
||||
PKG_VERSION:=2.27.2
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
PKGARCH:=all
|
||||
LUCKY_CONF_DIR := /etc/config/lucky.daji
|
||||
LUCKY_TMP_BACKUP := /tmp/luckyconfdir
|
||||
|
||||
ifeq ($(ARCH),mipsel)
|
||||
LUCKY_ARCH:=mipsle_softfloat
|
||||
@@ -29,8 +26,8 @@ ifeq ($(ARCH),arm)
|
||||
ifeq ($(BOARD),bcm53xx)
|
||||
LUCKY_ARCH:=armv6
|
||||
else
|
||||
LUCKY_ARCH:=armv7
|
||||
endif
|
||||
LUCKY_ARCH:=armv7
|
||||
endif
|
||||
endif
|
||||
ifeq ($(BOARD),bcm53xx)
|
||||
LUCKY_ARCH:=armv6
|
||||
@@ -66,15 +63,20 @@ define Package/$(PKG_NAME)/description
|
||||
Main functions of Lucky: ipv4/ipv6 portforward,ddns,IOT wake on lan ,reverse proxy and more...
|
||||
endef
|
||||
|
||||
|
||||
|
||||
|
||||
define Build/Prepare
|
||||
[ ! -f $(PKG_BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz ] && wget https://github.com/gdy666/lucky/releases/download/v$(PKG_VERSION)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz -O $(PKG_BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz
|
||||
tar -xzvf $(PKG_BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz -C $(PKG_BUILD_DIR) || exit 1
|
||||
tar -xzvf $(PKG_BUILD_DIR)/$(PKG_NAME)_$(PKG_VERSION)_Linux_$(LUCKY_ARCH).tar.gz -C $(PKG_BUILD_DIR)
|
||||
endef
|
||||
|
||||
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/lucky
|
||||
/etc/lucky/*
|
||||
endef
|
||||
|
||||
define Build/Compile
|
||||
endef
|
||||
|
||||
@@ -83,9 +85,10 @@ define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/etc/init.d/
|
||||
$(INSTALL_DIR) $(1)/etc/config/
|
||||
$(INSTALL_BIN) $(PKG_BUILD_DIR)/lucky $(1)/usr/bin/lucky
|
||||
$(INSTALL_BIN) $(CURDIR)/files/luckyarch.bin $(1)/usr/bin/luckyarch
|
||||
$(INSTALL_BIN) ./files/lucky.init $(1)/etc/init.d/lucky
|
||||
$(INSTALL_CONF) $(CURDIR)/files/lucky.config $(1)/etc/config/lucky
|
||||
$(INSTALL_CONF) $(CURDIR)/files/luckyuci $(1)/etc/config/lucky
|
||||
endef
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
|
||||
|
||||
$(eval $(call BuildPackage,$(PKG_NAME)))
|
||||
@@ -1,5 +0,0 @@
|
||||
config lucky 'lucky'
|
||||
option logger '1'
|
||||
option port '16601'
|
||||
option configdir '/etc/lucky'
|
||||
option enabled '0'
|
||||
+23
-58
@@ -1,83 +1,48 @@
|
||||
#!/bin/sh /etc/rc.common
|
||||
#
|
||||
# Copyright (C) 2021-2025 sirpdboy <herboy2008@gmail.com> https://github.com/sirpdboy/luci-app-lucky
|
||||
|
||||
# This file is part of lucky .
|
||||
#
|
||||
# This is free software, licensed under the Apache License, Version 2.0 .
|
||||
# Copyright (C) 2021-2024 daji <https://github.com/gdy666/lucky>
|
||||
|
||||
START=99
|
||||
STOP=15
|
||||
USE_PROCD=1
|
||||
|
||||
CONF=lucky
|
||||
PROG=/usr/bin/lucky
|
||||
CONFDIR=/etc/lucky
|
||||
DEFAULT_PRO_CONF='/etc/config/lucky.daji/'
|
||||
|
||||
get_config() {
|
||||
config_get_bool enabled $1 enabled 0
|
||||
config_get_bool logger $1 logger 1
|
||||
config_get port $1 port 16601
|
||||
config_get SafeURL $1 safe
|
||||
config_get delay $1 delay 0
|
||||
lucky_instance() {
|
||||
local cfg="$1"
|
||||
local enabled configdir logger
|
||||
|
||||
}
|
||||
config_get_bool enabled "$cfg" enabled 0
|
||||
config_get configdir "$cfg" configdir "$DEFAULT_PRO_CONF"
|
||||
config_get_bool logger "$cfg" logger 1
|
||||
|
||||
init_config(){
|
||||
config_load "$CONF"
|
||||
config_foreach get_config "$CONF"
|
||||
}
|
||||
[ "$enabled" -eq 1 ] || return 0
|
||||
|
||||
init_confdir(){
|
||||
[ -d $CONFDIR ] || mkdir -p $CONFDIR 2>/dev/null
|
||||
}
|
||||
[ -d "$configdir" ] || mkdir -p "$configdir" 2>/dev/null
|
||||
|
||||
LOG(){
|
||||
echo "$1"
|
||||
logger -t lucky -p warn "$1"
|
||||
}
|
||||
|
||||
start_instance() {
|
||||
enabled=$(uci -q get $CONF.$CONF.enabled ) || enabled="0"
|
||||
logger=$(uci -q get $CONF.$CONF.logger ) || logger="1"
|
||||
port=$(uci -q get $CONF.$CONF.port ) || port="16601"
|
||||
SafeURL=$(uci -q get $CONF.$CONF.safe ) || SafeURL=" "
|
||||
delay=$(uci -q get $CONF.$CONF.delay ) || delay="5"
|
||||
SafeURL="${SafeURL##*( )}"
|
||||
SafeURL="${SafeURL%%*( )}"
|
||||
|
||||
init_confdir
|
||||
[ x$enabled = x1 ] || return 1
|
||||
[ $(awk -F. '{print $1}' /proc/uptime) -lt "120" ] && sleep $delay
|
||||
$(which lucky) -setconf -key AdminWebListenPort -value $port -cd $CONFDIR
|
||||
if [ -z "$SafeURL" ] ; then
|
||||
$(which lucky) -rCancelSafeURL
|
||||
else
|
||||
$(which lucky) -setconf -key SafeURL -value "$SafeURL" -cd $CONFDIR
|
||||
fi
|
||||
|
||||
procd_open_instance
|
||||
procd_set_param command $PROG
|
||||
procd_append_param command -cd $CONFDIR
|
||||
procd_open_instance "$cfg"
|
||||
procd_set_param command "$PROG" -cd "$configdir"
|
||||
procd_set_param respawn
|
||||
procd_set_param stderr 1
|
||||
procd_set_param stdout "$logger"
|
||||
procd_set_param stderr "$logger"
|
||||
procd_close_instance
|
||||
LOG "lucky is start."
|
||||
|
||||
}
|
||||
|
||||
start_service() {
|
||||
pgrep -f $PROG | xargs kill -9 >/dev/null 2>&1
|
||||
start_instance
|
||||
# 强制清理可能脱离 procd 管控的独立进程(如通过 Lucky 面板自行更新/重启产生的孤儿进程)
|
||||
local pids=$(pidof /usr/bin/lucky)
|
||||
[ -n "$pids" ] && kill -9 $pids >/dev/null 2>&1 || true
|
||||
|
||||
config_load lucky
|
||||
config_foreach lucky_instance lucky
|
||||
}
|
||||
|
||||
stop_service() {
|
||||
pgrep -f $PROG | xargs kill -9 >/dev/null 2>&1
|
||||
LOG "lucky is stop."
|
||||
local pids=$(pidof /usr/bin/lucky)
|
||||
[ -n "$pids" ] && kill -9 $pids >/dev/null 2>&1 || true
|
||||
}
|
||||
|
||||
service_triggers() {
|
||||
procd_add_reload_trigger lucky
|
||||
procd_add_reload_trigger "lucky"
|
||||
}
|
||||
|
||||
reload_service() {
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
cputype=$(uname -ms | tr ' ' '_' | tr '[A-Z]' '[a-z]')
|
||||
[ -n "$(echo $cputype | grep -E "linux.*armv.*")" ] && cpucore="armv5"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*armv7.*")" ] && [ -n "$(cat /proc/cpuinfo | grep vfp)" ] && [ ! -d /jffs/clash ] && cpucore="armv7"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*aarch64.*|linux.*armv8.*")" ] && cpucore="arm64"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*86.*")" ] && cpucore="i386"
|
||||
[ -n "$(echo $cputype | grep -E "linux.*86_64.*")" ] && cpucore="x86_64"
|
||||
if [ -n "$(echo $cputype | grep -E "linux.*mips.*")" ];then
|
||||
mipstype=$(echo -n I | hexdump -o 2>/dev/null | awk '{ print substr($2,6,1); exit}') #通过判断大小端判断mips或mipsle
|
||||
[ "$mipstype" = "0" ] && cpucore="mips_softfloat" || cpucore="mipsle_softfloat"
|
||||
fi
|
||||
|
||||
echo $cpucore
|
||||
@@ -0,0 +1,4 @@
|
||||
config lucky
|
||||
option enabled '0'
|
||||
option logger '1'
|
||||
option configdir '/etc/config/lucky.daji'
|
||||
Reference in new issue
Block a user