add airconnect

This commit is contained in:
jjm2473 2022-12-14 21:18:58 +08:00
parent 2060083b30
commit a5f21b3217
8 changed files with 181 additions and 22 deletions

View File

@ -0,0 +1,51 @@
#
# Copyright (C) 2015 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=airconnect
PKG_VERSION:=1.0.13
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_VERSION:=9fc8c184da22d6b34a5b093f6ec8cf6ecaf22dbf
PKG_SOURCE_URL_FILE:=$(PKG_SOURCE_VERSION).tar.gz
PKG_SOURCE_URL:=https://github.com/philippe44/AirConnect/archive/
PKG_HASH:=0da27af9a1d49cd83f8381453d5e1b9c6551ad1ce45bbb7b820e5499796c5440
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)/AirConnect-$(PKG_SOURCE_VERSION)
PKG_MAINTAINER:=jjm2473 <jjm2473@gmail.com>
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SECTION:=multimedia
CATEGORY:=Multimedia
TITLE:=AirConnect
URL:=https://github.com/philippe44/AirConnect
endef
define Package/$(PKG_NAME)/description
Use AirPlay to stream to UPnP/Sonos & Chromecast devices
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/aircast-linux-$(ARCH)-static $(1)/usr/bin/aircast
$(INSTALL_BIN) $(PKG_BUILD_DIR)/bin/airupnp-linux-$(ARCH)-static $(1)/usr/bin/airupnp
$(INSTALL_CONF) ./files/airconnect.config $(1)/etc/config/airconnect
$(INSTALL_BIN) ./files/airconnect.init $(1)/etc/init.d/airconnect
endef
$(eval $(call BuildPackage,airconnect))

View File

@ -0,0 +1,5 @@
config main
option 'enabled' '0'
option 'interface' 'lan'
option 'aircast' '1'
option 'airupnp' '1'

View File

@ -0,0 +1,46 @@
#!/bin/sh /etc/rc.common
START=99
STOP=01
USE_PROCD=1
service_triggers() {
procd_add_reload_trigger "airconnect"
}
main_config() {
config_get AIRUPNP_IFACE "$1" interface "lan"
config_get_bool ENABLE_MAIN "$1" enabled 0
config_get_bool ENABLE_AIRCAST "$1" aircast 0
config_get_bool ENABLE_AIRUPNP "$1" airupnp 0
}
start_service() {
config_load airconnect
config_foreach main_config main
[ "$ENABLE_MAIN" = 0 ] && return 0
[ "$ENABLE_AIRCAST" = 0 -a "$ENABLE_AIRUPNP" = 0 ] && return 0
local interface=$(
. /lib/functions/network.sh
network_is_up "$AIRUPNP_IFACE" || exit 0
network_get_device device "$AIRUPNP_IFACE"
printf "%s" "${device:-$AIRUPNP_IFACE}"
)
[ -z "$interface" ] && interface=br-lan
local common_args="-Z -b $interface"
if [ "$ENABLE_AIRUPNP" = 1 ]; then
procd_open_instance
procd_set_param command /usr/bin/airupnp $common_args
procd_set_param respawn
procd_close_instance
fi
if [ "$ENABLE_AIRCAST" = 1 ]; then
procd_open_instance
procd_set_param command /usr/bin/aircast $common_args
procd_set_param respawn
procd_close_instance
fi
}

View File

@ -0,0 +1,15 @@
include $(TOPDIR)/rules.mk
PKG_VERSION:=1.0.0-20221214
PKG_RELEASE:=
LUCI_TITLE:=LuCI support for airconnect
LUCI_PKGARCH:=all
LUCI_DEPENDS:=+airconnect
include $(TOPDIR)/feeds/luci/luci.mk
# call BuildPackage - OpenWrt buildroot signature

View File

@ -0,0 +1,7 @@
module("luci.controller.airconnect", package.seeall)
function index()
entry({"admin", "services", "airconnect"}, alias("admin", "services", "airconnect", "config"), _("AirConnect"), 90).dependent = true
entry({"admin", "services", "airconnect", "config"}, cbi("airconnect"))
end

View File

@ -0,0 +1,34 @@
--[[
LuCI - Lua Configuration Interface
]]--
local m, s, o
m = Map("airconnect", translate("AirConnect"), translate("Use AirPlay to stream to UPnP/Sonos &amp; Chromecast devices"))
s = m:section(TypedSection, "main", translate("Global Settings"))
s.addremove=false
s.anonymous=true
o = s:option(Flag, "enabled", translate("Enable"))
o.default = 0
o.rmempty = false
o = s:option(Value, "interface", translate("Interface"), translate("Network interface for serving, usually LAN"))
o.template = "cbi/network_netlist"
o.nocreate = true
o.default = "lan"
o.datatype = "string"
o:depends("enabled", 1)
o = s:option(Flag, "aircast", translate("Supports Chromecast"), translate("Select this if you have Chromecast devices"))
o.default = 1
o.rmempty = false
o:depends("enabled", 1)
o = s:option(Flag, "airupnp", translate("Supports UPnP/Sonos"), translate("Select this if you have UPnP/Sonos devices"))
o.default = 1
o.rmempty = false
o:depends("enabled", 1)
return m

View File

@ -0,0 +1,23 @@
msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8"
msgid "Use AirPlay to stream to UPnP/Sonos &amp; Chromecast devices"
msgstr "AirConnect 让 UPnP/Sonos 和 Chromecast 设备支持 AirPlay 音频串流"
msgid "Global Settings"
msgstr "全局设置"
msgid "Network interface for serving, usually LAN"
msgstr "提供服务的网络接口,通常是 LAN 口"
msgid "Supports Chromecast"
msgstr "支持 Chromecast 设备"
msgid "Supports UPnP/Sonos"
msgstr "支持 UPnP/Sonos 设备"
msgid "Select this if you have Chromecast devices"
msgstr "如果你有 Chromecast 设备就选中这个"
msgid "Select this if you have UPnP/Sonos devices"
msgstr "如果你有 UPnP/Sonos 设备就选中这个"

View File

@ -1,22 +0,0 @@
local fs = require "nixio.fs"
s = SimpleForm("scriptview")
view_cfg = s:field(TextValue, "conf")
view_cfg.rmempty = false
view_cfg.rows = 43
function sync_value_to_file(value, file)
value = value:gsub("\r\n?", "\n")
local old_value = fs.readfile(file)
if value ~= old_value then fs.writefile(file, value) end
end
function view_cfg.cfgvalue()
return fs.readfile("/usr/share/jellyfin/install.sh") or ""
end
function view_cfg.write(self, section, value)
sync_value_to_file(value, "/usr/share/jellyfin/install.sh")
end
return s