Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
帮看看这段代码有没有问题
deepin Talks
912
views ·
0
replies ·
To
floor
Go
洪旭钢
deepin
2016-12-09 23:55
Author
list_servers() {
SERVER_PARAMS=" -SER[Shost:"
config_get host "$1" 'host'
config_get port "$1" 'port'
config_get atoken "$1" 'atoken'
SERVER_PARAMS="${SERVER_PARAMS}""${host}"",Sport:""${port}"
[ ! $atoken ] && SERVER_PARAMS=${SERVER_PARAMS}"]" || SERVER_PARAMS=${SERVER_PARAMS}",Atoken
{atoken}]"
eval ${1}_PARAMS=\$SERVER_PARAMS
}
list_tunnels() {
config_get_bool enabled "$1" 'enabled'
config_get type "$1" 'type'
config_get lhost "$1" 'lhost'
config_get server "$1" 'server'
config_get lport "$1" 'lport'
config_get custom_domain "$1" 'custom_domain'
config_get rport "$1" 'rport'
config_get dname "$1" 'dname'
[ -z "$lhost" ] && lhost="127.0.0.1"
if [ "$enabled" = 1 ]; then
TUNNEL_PARAMS=" -AddTun[Type
{type},Lhost
{lhost},Lport
{lport}"
[ "z"$custom_domain = "z1" ] && DTYPE="Hostname" || DTYPE="Sdname"
[ ${type} = "tcp" ] && \
TUNNEL_PARAMS=${TUNNEL_PARAMS}",Rport
{rport}]" || \
TUNNEL_PARAMS=${TUNNEL_PARAMS}",${DTYPE}
{dname}]"
echo $server" : ngrokc"$TUNNEL_PARAMS
config_foreach list_servers 'servers'
eval "exec /usr/bin ngrokc \$${server}_PARAMS \$TUNNEL_PARAMS 2>&1 > /dev/null & echo \$! >> /tmp ngrokc/${1}.pid"
fi
}
start() {
mkdir -p /tmp ngrokc
config_load 'ngrokc'
[ -f /tmp ngrokc ngrokc_running ] || \
( config_foreach list_tunnels 'tunnel' ; touch /tmp ngrokc ngrokc_running )
}
Reply
Like 0
Favorite
View the author
All Replies
No replies yet
Please
sign
in first
Featured Collection
Change
Nuntia - Modern IMAP/SMTP mail client for Deepin (Beta tester wanted!)
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
Adding a Dancing Spectrum Bar to the Deepin Taskbar | deepin-spectrum
Popular Events
More
SERVER_PARAMS=" -SER[Shost:"
config_get host "$1" 'host'
config_get port "$1" 'port'
config_get atoken "$1" 'atoken'
SERVER_PARAMS="${SERVER_PARAMS}""${host}"",Sport:""${port}"
[ ! $atoken ] && SERVER_PARAMS=${SERVER_PARAMS}"]" || SERVER_PARAMS=${SERVER_PARAMS}",Atoken
eval ${1}_PARAMS=\$SERVER_PARAMS
}
list_tunnels() {
config_get_bool enabled "$1" 'enabled'
config_get type "$1" 'type'
config_get lhost "$1" 'lhost'
config_get server "$1" 'server'
config_get lport "$1" 'lport'
config_get custom_domain "$1" 'custom_domain'
config_get rport "$1" 'rport'
config_get dname "$1" 'dname'
[ -z "$lhost" ] && lhost="127.0.0.1"
if [ "$enabled" = 1 ]; then
TUNNEL_PARAMS=" -AddTun[Type
[ "z"$custom_domain = "z1" ] && DTYPE="Hostname" || DTYPE="Sdname"
[ ${type} = "tcp" ] && \
TUNNEL_PARAMS=${TUNNEL_PARAMS}",Rport
TUNNEL_PARAMS=${TUNNEL_PARAMS}",${DTYPE}
echo $server" : ngrokc"$TUNNEL_PARAMS
config_foreach list_servers 'servers'
eval "exec /usr/bin ngrokc \$${server}_PARAMS \$TUNNEL_PARAMS 2>&1 > /dev/null & echo \$! >> /tmp ngrokc/${1}.pid"
fi
}
start() {
mkdir -p /tmp ngrokc
config_load 'ngrokc'
[ -f /tmp ngrokc ngrokc_running ] || \
( config_foreach list_tunnels 'tunnel' ; touch /tmp ngrokc ngrokc_running )
}