找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
广告投放联系QQ68610888
查看: 1182|回复: 1

求助启动脚本语法问题!!!

[复制链接]
发表于 2019-7-6 15:54 | 显示全部楼层 |阅读模式
本帖最后由 liuxichi 于 2019-7-6 15:56 编辑

系统日志报错!!!
Sat Jul  6 15:49:25 2019 daemon.err uhttpd[2836]: sh: /etc/init.d/frp: line 195: syntax error: unexpected ")" (expecting "fi")
Sat Jul  6 15:49:25 2019 daemon.err uhttpd[2836]: /etc/rc.common: /etc/init.d/frp: line 195: syntax error: unexpected ")" (expecting "fi")
Sat Jul  6 15:49:27 2019 daemon.err uhttpd[2836]: sh: /etc/init.d/frp: line 195: syntax error: unexpected ")" (expecting "fi")
Sat Jul  6 15:49:27 2019 daemon.err uhttpd[2836]: /etc/rc.common: /etc/init.d/frp: line 195: syntax error: unexpected ")" (expecting "fi")
Sat Jul  6 15:49:27 2019 daemon.err uhttpd[2836]: /etc/rc.common: /etc/init.d/frp: line 195: syntax error: unexpected ")" (expecting "fi")

启动脚本如下
#!/bin/sh /etc/rc.common
#Author: monokoo <realstones2012@gmail.com>
#Thanks to FW867's help

START=95
SERVICE_WRITE_PID=1
SERVICE_DAEMONIZE=1

LOGFILE="/var/etc/frp/frpc.log"

echo_date(){
        local log=$1
        echo $(date +%Y/%m/%d\ %X): "$log" >> $LOGFILE
}

Reduce_Log(){
        local log=$1
        [ ! -f "$log" ] && return
        local sc=200
        [ -n "$2" ] && sc=$2
        local count=$(grep -c "" $log)
        if [ $count -gt $sc ];then
                let count=count-$sc
                sed -i "1,$count d" $log
        fi
}

conf_proxy_add() {

        local cfg="$1"
        local tmpconf="$2"
        local enable type domain_type custom_domains remote_port local_ip local_port enable_http_auth enable_host_header_rewrite host_header_rewrite
        local subdomain use_encryption use_compression http_user http_pwd remark locations
        local enable_plugin plugin plugin_http_user plugin_http_passwd plugin_unix_path stcp_role stcp_secretkey stcp_servername
        
        config_get_bool enable "$cfg" enable 1
        [ "$enable" -gt 0 ] || return 1
        
        config_get type "$cfg" type
        config_get custom_domains "$cfg" custom_domains
        config_get subdomain "$cfg" subdomain
        config_get remote_port "$cfg" remote_port
        config_get local_ip "$cfg" local_ip
        config_get local_port "$cfg" local_port
        config_get locations "$cfg" locations
        config_get host_header_rewrite "$cfg" host_header_rewrite
        config_get http_user "$cfg" http_user
        config_get http_pwd "$cfg" http_pwd
        config_get remark "$cfg" remark
        config_get plugin "$cfg" plugin
        config_get plugin_http_user "$cfg" plugin_http_user
        config_get plugin_http_passwd "$cfg" plugin_http_passwd
        config_get plugin_unix_path "$cfg" plugin_unix_path
        config_get stcp_role "$cfg" stcp_role
        config_get stcp_secretkey "$cfg" stcp_secretkey
        config_get stcp_servername "$cfg" stcp_servername


        [ -n "$remark" ] && [ -n "$type" ] || return 1
        
        echo "" >>$tmpconf
        echo "[$remark]" >>$tmpconf
        echo "type=$type" >>$tmpconf
        [ -n "$custom_domains" ] && echo "custom_domains=$custom_domains" >>$tmpconf
        [ -n "$subdomain" ] && echo "subdomain=$subdomain" >>$tmpconf
        [ -n "$remote_port" ] && echo "remote_port=$remote_port" >>$tmpconf
        [ -z "$stcp_role" ] && [ -n "$local_ip" ] && echo "local_ip=$local_ip" >>$tmpconf
        [ -z "$stcp_role" ] && [ -n "$local_port" ] && echo "local_port=$local_port" >>$tmpconf
        [ -n "$locations" ] && echo "locations=$locations" >>$tmpconf
        [ -n "$http_user" -a -n "$http_pwd" ] && {
                echo "http_user=$http_user" >>$tmpconf
                echo "http_pwd=$http_pwd" >>$tmpconf
        }
        [ -n "$host_header_rewrite" ] && echo "host_header_rewrite=$host_header_rewrite" >>$tmpconf
        [ -n "$plugin" ] && echo "plugin=$plugin" >>$tmpconf
        [ -n "$plugin_http_user" -a -n "$plugin_http_passwd" ] && {
                echo "plugin_http_user=$plugin_http_user" >>$tmpconf
                echo "plugin_http_passwd=$plugin_http_passwd" >>$tmpconf
        }
        [ -n "$plugin_unix_path" ] && echo "plugin_unix_path=$plugin_unix_path" >>$tmpconf
        
        [ -n "$stcp_role" ] && {
                if [ "$stcp_role" == "vistor" ]; then
                        echo "role=$stcp_role" >>$tmpconf
                        [ -n "$local_ip" ] && echo "bind_addr=$local_ip" >>$tmpconf
                        [ -n "$local_port" ] && echo "bind_port=$local_port" >>$tmpconf
                        [ -n "$stcp_servername" ] && echo "server_name=$stcp_servername" >>$tmpconf || return 1
                else
                        [ -n "$local_ip" ] && echo "local_ip=$local_ip" >>$tmpconf
                        [ -n "$local_port" ] && echo "local_port=$local_port" >>$tmpconf
                fi
                [ -n "$stcp_secretkey" ] && echo "sk=$stcp_secretkey" >>$tmpconf || return 1
        }
        
        

        frp_write_bool use_encryption $cfg 1
        frp_write_bool use_compression $cfg 1

}

frp_write_bool() {
        local opt="$1"
        local config="$2"
        local def="$3"
        local val

        config_get_bool val $config "$opt" "$def"
        if [ "$val" -eq 0 ]; then
                echo "${opt}=false" >> $tmpconf
        else
                echo "${opt}=true" >> $tmpconf
        fi
}

frp_add_cru(){
time=$1
if [ ! -f "/etc/crontabs/root" ] || [ -z "$(cat /etc/crontabs/root | grep frp)" ]; then
  sed -i '/frp/d' /etc/crontabs/root >/dev/null 2>&1
  echo "*/$time * * * * /etc/init.d/frp restart" >> /etc/crontabs/root
fi

}

frp_del_cru(){
if [ ! -f "/etc/crontabs/root" ] || [ -n "$(cat /etc/crontabs/root | grep frp)" ]; then
  sed -i '/frp/d' /etc/crontabs/root >/dev/null 2>&1
fi
}

download_binary(){
        echo_date "寮
我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2019-7-6 15:56 | 显示全部楼层
echo_date "寮
我的恩山、我的无线 The best wifi forum is right here.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

有疑问请添加管理员QQ86788181|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )

GMT+8, 2024-4-26 22:34

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

| 江苏省互联网有害信息举报中心 举报信箱:js12377 | @jischina.com.cn 举报电话:025-88802724 本站不良内容举报信箱:68610888@qq.com 举报电话:0519-86695797

快速回复 返回顶部 返回列表