Browse Source

ttyd: update to 1.5.2 and add init script

Signed-off-by: Richard Yu <yurichard3839@gmail.com>
lilik-openwrt-22.03
Richard Yu 5 years ago
parent
commit
9e325b47cb
No known key found for this signature in database GPG Key ID: D16286AFD4E1FFF3
3 changed files with 109 additions and 2 deletions
  1. +6
    -2
      utils/ttyd/Makefile
  2. +5
    -0
      utils/ttyd/files/ttyd.config
  3. +98
    -0
      utils/ttyd/files/ttyd.init

+ 6
- 2
utils/ttyd/Makefile View File

@ -8,12 +8,12 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=ttyd
PKG_VERSION:=1.5.1
PKG_VERSION:=1.5.2
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/tsl0922/ttyd/tar.gz/$(PKG_VERSION)?
PKG_HASH:=817d33d59834f9a76af99f689339722fc1ec9f3c46c9a324665b91cb44d79ee8
PKG_HASH:=b5b62ec2ce08add0173e6d1dfdd879e55f02f9490043e89f389981a62e87d376
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
@ -41,6 +41,10 @@ endef
define Package/ttyd/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/ttyd $(1)/usr/bin/
$(INSTALL_DIR) $(1)/etc/config/
$(INSTALL_CONF) ./files/ttyd.config $(1)/etc/config/ttyd
$(INSTALL_DIR) $(1)/etc/init.d/
$(INSTALL_BIN) ./files/ttyd.init $(1)/etc/init.d/ttyd
endef
$(eval $(call BuildPackage,ttyd))

+ 5
- 0
utils/ttyd/files/ttyd.config View File

@ -0,0 +1,5 @@
config ttyd
option interface '@lan'
option command '/usr/libexec/login.sh'

+ 98
- 0
utils/ttyd/files/ttyd.init View File

@ -0,0 +1,98 @@
#!/bin/sh /etc/rc.common
START=99
STOP=50
USE_PROCD=1
NAME=ttyd
PROG=/usr/bin/$NAME
validate_section_ttyd()
{
uci_load_validate ttyd ttyd "$1" "$2" \
'enable:bool:1' \
'port:port' \
'interface:string' \
'credential:string' \
'uid:uinteger' \
'gid:uinteger' \
'signal:uinteger' \
'url_arg:bool' \
'readonly:bool' \
'client_option:list(string)' \
'terminal_type:string' \
'check_origin:bool' \
'max_clients:uinteger' \
'once:bool' \
'index:string' \
'ipv6:bool' \
'ssl:bool' \
'ssl_cert:file' \
'ssl_key:file' \
'ssl_ca:file' \
'debug:uinteger' \
'command:string'
}
ttyd_instance()
{
[ "$2" = 0 ] || {
echo "validation failed"
return 1
}
[ "$enable" = 0 ] && return 1
[ -z "$command" ] && return 1
[ "${interface::1}" = @ ] && {
interface=$(
. /lib/functions/network.sh
network_get_device device "${interface:1}"
echo -n "$device"
)
}
[ "$url_arg" = 0 ] && url_arg=""
[ "$readonly" = 0 ] && readonly=""
[ "$check_origin" = 0 ] && check_origin=""
[ "$once" = 0 ] && once=""
[ "$ipv6" = 0 ] && ipv6=""
[ "$ssl" = 0 ] && ssl=""
procd_open_instance
procd_set_param command "$PROG" \
${port:+-p $port} \
${interface:+-i $interface} \
${credential:+-c $credential} \
${uid:+-u $uid} \
${gid:+-g $gid} \
${signal:+-s $signal} \
${url_arg:+-a} \
${readonly:+-R} \
${terminal_type:+-T $terminal_type} \
${check_origin:+-O} \
${max_clients:+-m $max_clients} \
${once:+-o} \
${index:+-I $index} \
${ipv6:+-6} \
${ssl:+-S} \
${ssl_cert:+-C $ssl_cert} \
${ssl_key:+-K $ssl_key} \
${ssl_ca:+-A $ssl_ca} \
${debug:+-d}
config_list_foreach "$1" client_option "procd_append_param command -t"
procd_append_param command $command
procd_set_param stdout 1
procd_set_param stderr 1
procd_close_instance
}
start_service() {
config_load "$NAME"
config_foreach validate_section_ttyd ttyd ttyd_instance
}
shutdown() {
# close all open connections
killall "$NAME"
}

Loading…
Cancel
Save