diff --git a/latest/install-kcp-server.sh b/latest/install-kcp-server.sh new file mode 100644 index 0000000..96607b1 --- /dev/null +++ b/latest/install-kcp-server.sh @@ -0,0 +1,561 @@ +#! /bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH +#=============================================================================================== +# System Required: CentOS Debian or Ubuntu (32bit/64bit) +# Description: Install kcp-Server(XiaoBao) for CentOS Debian or Ubuntu +# Author: Clang +# Intro: http://koolshare.cn/forum-72-1.html +#=============================================================================================== +version="1.4" +str_program_dir="/usr/local/kcp-server" +program_x64_download_url=https://github.com/clangcn/kcp-server/raw/master/latest/kcp_server +program_x86_download_url=https://github.com/clangcn/kcp-server/raw/master/latest/kcp_server_386 +program_init_download_url=https://raw.githubusercontent.com/clangcn/kcp-server/master/kcp-server.init +str_install_shell=https://raw.githubusercontent.com/clangcn/kcp-server/master/install-kcp-server.sh + +function fun_clang.cn(){ + echo "" + echo "#####################################################################" + echo "# Install kcp-Server(XiaoBao) for CentOS Debian or Ubuntu(32/64bit)" + echo "# Intro: http://koolshare.cn/forum-72-1.html" + echo "# Author: Clang" + echo "# Version ${version}" + echo "#####################################################################" + echo "" +} + +function fun_set_text_color(){ + COLOR_RED='\E[1;31m' + COLOR_GREEN='\E[1;32m' + COLOR_YELOW='\E[1;33m' + COLOR_BLUE='\E[1;34m' + COLOR_PINK='\E[1;35m' + COLOR_PINKBACK_WHITEFONT='\033[45;37m' + COLOR_END='\E[0m' +} +# Check if user is root +function rootness(){ + if [[ $EUID -ne 0 ]]; then + fun_clang.cn + echo "Error:This script must be run as root!" 1>&2 + exit 1 + fi +} + +function get_char(){ + SAVEDSTTY=`stty -g` + stty -echo + stty cbreak + dd if=/dev/tty bs=1 count=1 2> /dev/null + stty -raw + stty echo + stty $SAVEDSTTY +} + +# Check OS +function checkos(){ + if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then + OS=CentOS + elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then + OS=Debian + elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then + OS=Ubuntu + else + echo "Not support OS, Please reinstall OS and retry!" + exit 1 + fi +} + +# Get version +function getversion(){ + if [[ -s /etc/redhat-release ]];then + grep -oE "[0-9.]+" /etc/redhat-release + else + grep -oE "[0-9.]+" /etc/issue + fi +} + +# CentOS version +function centosversion(){ + local code=$1 + local version="`getversion`" + local main_ver=${version%%.*} + if [ $main_ver == $code ];then + return 0 + else + return 1 + fi +} + +# Check OS bit +function check_os_bit(){ + if [[ `getconf WORD_BIT` = '32' && `getconf LONG_BIT` = '64' ]] ; then + Is_64bit='y' + else + Is_64bit='n' + fi +} + +function check_centosversion(){ +if centosversion 5; then + echo "Not support CentOS 5.x, please change to CentOS 6,7 or Debian or Ubuntu and try again." + exit 1 +fi +} + +# Disable selinux +function disable_selinux(){ + if [ -s /etc/selinux/config ] && grep 'SELINUX=enforcing' /etc/selinux/config; then + sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config + setenforce 0 + fi +} + +# Check port +function fun_check_port(){ + strServerPort="$1" + if [ ${strServerPort} -ge 1 ] && [ ${strServerPort} -le 65535 ]; then + checkServerPort=`netstat -ntulp | grep "\b:${strServerPort}\b"` + if [ -n "${checkServerPort}" ]; then + echo "" + echo -e "${COLOR_RED}Error:${COLOR_END} Port ${COLOR_GREEN}${strServerPort}${COLOR_END} is ${COLOR_PINK}used${COLOR_END},view relevant port:" + netstat -ntulp | grep "\b:${strServerPort}\b" + fun_input_port + else + serverport="${strServerPort}" + fi + else + echo "Input error! Please input correct numbers." + fun_input_port + fi +} + +# input port +function fun_input_port(){ + server_port="8989" + echo "" + echo -e "Please input Server Port [1-65535](Don't the same SSH Port ${COLOR_RED}${sshport}${COLOR_END})" + read -p "(Default Server Port: ${server_port}):" serverport + [ -z "${serverport}" ] && serverport="${server_port}" + fun_check_port "${serverport}" +} + +# Random password +function fun_randstr(){ + index=0 + strRandomPass="" + for i in {a..z}; do arr[index]=$i; index=`expr ${index} + 1`; done + for i in {A..Z}; do arr[index]=$i; index=`expr ${index} + 1`; done + for i in {0..9}; do arr[index]=$i; index=`expr ${index} + 1`; done + for i in {1..16}; do strRandomPass="$strRandomPass${arr[$RANDOM%$index]}"; done + echo $strRandomPass +} +# ====== check packs ====== +function check_nano(){ + nano -V + if [[ $? -le 1 ]] ;then + echo " Run nano success" + else + echo " Run nano failed" + if [ "${OS}" == 'CentOS' ]; then + echo " Install centos nano ..." + yum -y install nano + else + echo " Install debian/ubuntu nano ..." + apt-get update -y + apt-get install -y nano + fi + fi + echo $result +} +function check_net-tools(){ + netstat -V + if [[ $? -le 6 ]] ;then + echo " Run net-tools success" + else + echo " Run net-tools failed" + if [ "${OS}" == 'CentOS' ]; then + echo " Install centos net-tools ..." + yum -y install net-tools + else + echo " Install debian/ubuntu net-tools ..." + apt-get update -y + apt-get install -y net-tools + fi + fi + echo $result +} +function check_iptables(){ + iptables -V + if [[ $? -le 1 ]] ;then + echo " Run iptables success" + else + echo " Run iptables failed" + if [ "${OS}" == 'CentOS' ]; then + echo " Install centos iptables ..." + yum -y install iptables policycoreutils libpcap libpcap-devel + else + echo " Install debian/ubuntu iptables ..." + apt-get update -y + apt-get install -y iptables libpcap-dev + fi + fi + echo $result +} +function check_curl(){ + curl -V + if [[ $? -le 1 ]] ;then + echo " Run curl success" + else + echo " Run curl failed" + if [ "${OS}" == 'CentOS' ]; then + echo " Install centos curl ..." + yum -y install curl curl-devel + else + echo " Install debian/ubuntu curl ..." + apt-get update -y + apt-get install -y curl + fi + fi + echo $result +} + +# ====== pre_install ====== +function pre_install_clang(){ + #config setting + echo " Please input your kcp-Server(XiaoBao) server_port and password" + echo "" + sshport=`netstat -anp |grep ssh | grep '0.0.0.0:'|cut -d: -f2| awk 'NR==1 { print $1}'` + #defIP=`ifconfig | grep 'inet addr:'| grep -v '127.0.0.' | cut -d: -f2 | awk 'NR==1 { print $1}'` + #if [ "${defIP}" = "" ]; then + check_curl + defIP=$(curl -s -4 ip.clang.cn | sed -r 's/\r//') + #fi + echo -e "You VPS IP:${COLOR_GREEN}${defIP}${COLOR_END}" + fun_input_port + echo "" + server_pwd=`fun_randstr` + read -p "Please input Password (Default Password: ${server_pwd}):" serverpwd + if [ "${serverpwd}" = "" ]; then + serverpwd="${server_pwd}" + fi + echo "" + set_iptables="n" + echo -e "\033[33mDo you want to set iptables?\033[0m" + read -p "(if you want please input: y,Default [no]):" set_iptables + + case "${set_iptables}" in + y|Y|Yes|YES|yes|yES|yEs|YeS|yeS) + echo "You will set iptables!" + set_iptables="y" + ;; + n|N|No|NO|no|nO) + echo "You will NOT set iptables!" + set_iptables="n" + ;; + *) + echo "The iptables is not set!" + set_iptables="n" + esac + + echo "" + echo "============== Check your input ==============" + echo -e "Your Server IP:${COLOR_GREEN}${defIP}${COLOR_END}" + echo -e "Your Server Port:${COLOR_GREEN}${serverport}${COLOR_END}" + echo -e "Your Password:${COLOR_GREEN}${serverpwd}${COLOR_END}" + echo "==============================================" + echo "" + echo "Press any key to start...or Press Ctrl+c to cancel" + + char=`get_char` + + echo "============== Install packs ==============" + if [ "${OS}" == 'CentOS' ]; then + #yum -y update + yum -y install wget psmisc + else + apt-get update -y + apt-get install -y wget psmisc + fi + + [ ! -d ${str_program_dir} ] && mkdir -p ${str_program_dir} + cd ${str_program_dir} + echo $PWD + +# Config file +cat > ${str_program_dir}/config.json<<-EOF +{ + "server":"${defIP}", + "redir_port":0, + "tuncrypt":0, + "sndwnd":128, + "rcvwnd":1024, + "mtu":1400, + "mode":"fast", + "port_password": + { + "${serverport}": "${serverpwd}" + }, + "_comment": + { + "${serverport}": "The server port comment" + } +} +EOF +cat > ${str_program_dir}/client.json<<-EOF +{ + "server":"${defIP}", + "server_port":${serverport}, + "password":"${serverpwd}", + "socks5_port":1080, + "redir_port":0, + "tuncrypt":0, + "sndwnd":128, + "rcvwnd":1024, + "mtu":1400, + "mode":"fast" +} +EOF + chmod 400 ${str_program_dir}/config.json + rm -f ${str_program_dir}/kcp-server + if [ "${Is_64bit}" == 'y' ] ; then + if [ ! -s ${str_program_dir}/kcp-server ]; then + if ! wget --no-check-certificate ${program_x64_download_url} -O ${str_program_dir}/kcp-server; then + echo "Failed to download kcp-server file!" + exit 1 + fi + fi + else + if [ ! -s ${str_program_dir}/kcp-server ]; then + if ! wget --no-check-certificate ${program_x86_download_url} -O ${str_program_dir}/kcp-server; then + echo "Failed to download kcp-server file!" + exit 1 + fi + fi + fi + [ ! -x ${str_program_dir}/kcp-server ] && chmod 755 ${str_program_dir}/kcp-server + if [ ! -s /etc/init.d/kcp-server ]; then + if ! wget --no-check-certificate ${program_init_download_url} -O /etc/init.d/kcp-server; then + echo "Failed to download kcp-server.init file!" + exit 1 + fi + fi + [ ! -x /etc/init.d/kcp-server ] && chmod +x /etc/init.d/kcp-server + if [ "${OS}" == 'CentOS' ]; then + chmod +x /etc/init.d/kcp-server + chkconfig --add kcp-server + else + chmod +x /etc/init.d/kcp-server + update-rc.d -f kcp-server defaults + fi + + if [ "$set_iptables" == 'y' ]; then + check_iptables + # iptables config + iptables -I INPUT -p udp --dport ${serverport} -j ACCEPT + iptables -I INPUT -p tcp --dport ${serverport} -j ACCEPT + iptables -I INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT + if [ "${OS}" == 'CentOS' ]; then + service iptables save + else + echo '#!/bin/bash' > /etc/network/if-post-down.d/iptables + echo 'iptables-save > /etc/iptables.rules' >> /etc/network/if-post-down.d/iptables + echo 'exit 0;' >> /etc/network/if-post-down.d/iptables + chmod +x /etc/network/if-post-down.d/iptables + + echo '#!/bin/bash' > /etc/network/if-pre-up.d/iptables + echo 'iptables-restore < /etc/iptables.rules' >> /etc/network/if-pre-up.d/iptables + echo 'exit 0;' >> /etc/network/if-pre-up.d/iptables + chmod +x /etc/network/if-pre-up.d/iptables + fi + fi + [ -s /etc/init.d/kcp-server ] && ln -s /etc/init.d/kcp-server /usr/bin/kcp-server + /etc/init.d/kcp-server start + ${str_program_dir}/kcp-server --version + echo "" + fun_clang.cn + #install successfully + echo "" + echo "Congratulations, kcp-Server(XiaoBao) install completed!" + echo -e "Your Server IP:${COLOR_GREEN}${defIP}${COLOR_END}" + echo -e "Your Server Port:${COLOR_GREEN}${serverport}${COLOR_END}" + echo -e "Your Password:${COLOR_GREEN}${serverpwd}${COLOR_END}" + echo -e "Your MTU:${COLOR_GREEN}1400${COLOR_END}" + # echo -e "Your Local Port:${COLOR_GREEN}1080${COLOR_END}" + echo "" + echo -e "kcp-Server(XiaoBao) status manage: ${COLOR_PINKBACK_WHITEFONT}/etc/init.d/kcp-server${COLOR_END} {${COLOR_GREEN}start${COLOR_END}|${COLOR_PINK}stop${COLOR_END}|${COLOR_YELOW}restart${COLOR_END}}" +} +############################### install function ################################## +function install_program_server_clang(){ + fun_clang.cn + checkos + check_centosversion + check_os_bit + disable_selinux + clear + fun_clang.cn + check_net-tools + if [ -s ${str_program_dir}/kcp-server ] && [ -s /etc/init.d/kcp-server ]; then + echo "kcp-Server(XiaoBao) is installed!" + else + pre_install_clang + fi +} +############################### configure function ################################## +function configure_program_server_clang(){ + check_nano + if [ -s ${str_program_dir}/config.json ]; then + nano ${str_program_dir}/config.json + else + echo "kcp-Server(XiaoBao) configuration file not found!" + fi +} +############################### uninstall function ################################## +function uninstall_program_server_clang(){ + fun_clang.cn + if [ -s /etc/init.d/kcp-server ] || [ -s ${str_program_dir}/kcp-server ] ; then + echo "============== Uninstall kcp-Server(XiaoBao) ==============" + save_config="n" + echo -e "${COLOR_YELOW}Do you want to keep the configuration file?${COLOR_END}" + read -p "(if you want please input: y,Default [no]):" save_config + + case "${save_config}" in + y|Y|Yes|YES|yes|yES|yEs|YeS|yeS) + echo "" + echo "You will keep the configuration file!" + save_config="y" + ;; + n|N|No|NO|no|nO) + echo "" + echo "You will NOT to keep the configuration file!" + save_config="n" + ;; + *) + echo "" + echo "will NOT to keep the configuration file!" + save_config="n" + esac + checkos + /etc/init.d/kcp-server stop + if [ "${OS}" == 'CentOS' ]; then + chkconfig --del kcp-server + else + update-rc.d -f kcp-server remove + fi + rm -f /usr/bin/kcp-server /etc/init.d/kcp-server /var/run/kcp-server.pid /root/kcp-server-install.log /root/kcp-server-update.log + if [ "${save_config}" == 'n' ]; then + rm -fr ${str_program_dir} + else + rm -f ${str_program_dir}/kcp-server ${str_program_dir}/kcp-server.log + fi + echo "kcp-Server(XiaoBao) uninstall success!" + else + echo "kcp-Server(XiaoBao) Not install!" + fi + echo "" +} +############################### update function ################################## +function update_program_server_clang(){ + fun_clang.cn + check_curl + if [ -s /etc/init.d/kcp-server ] || [ -s ${str_program_dir}/kcp-server ] ; then + echo "============== Update kcp-Server(XiaoBao) ==============" + checkos + check_centosversion + check_os_bit + killall kcp-server + remote_shell_version=`curl -s ${str_install_shell} | sed -n '/'^version'/p' | cut -d\" -f2` + remote_init_version=`curl -s ${program_init_download_url} | sed -n '/'^version'/p' | cut -d\" -f2` + local_init_version=`sed -n '/'^version'/p' /etc/init.d/kcp-server | cut -d\" -f2` + install_shell=${strPath} + if [ ! -z ${remote_shell_version} ] || [ ! -z ${remote_init_version} ];then + update_flag="false" + if [[ "${version}" < "${remote_shell_version}" ]];then + echo "========== Update kcp-Server(XiaoBao) install-kcp-server.sh ==========" + if ! wget --no-check-certificate ${str_install_shell} -O ${install_shell}/install-kcp-server.sh; then + echo "Failed to download install-kcp-server.sh file!" + exit 1 + else + echo -e "${COLOR_GREEN}install-kcp-server.sh Update successfully !!!${COLOR_END}" + update_flag="true" + fi + fi + if [[ "${local_init_version}" < "${remote_init_version}" ]];then + echo "========== Update kcp-Server(XiaoBao) /etc/init.d/kcp-server ==========" + if ! wget --no-check-certificate ${program_init_download_url} -O /etc/init.d/kcp-server; then + echo "Failed to download kcp-server.init file!" + exit 1 + else + echo -e "${COLOR_GREEN}/etc/init.d/kcp-server Update successfully !!!${COLOR_END}" + update_flag="true" + fi + fi + if [ "${update_flag}" == 'true' ]; then + echo -e "${COLOR_GREEN}Update shell successfully !!!${COLOR_END}" + echo "" + echo -e "${COLOR_GREEN}Please Re-run${COLOR_END} ${COLOR_PINKBACK_WHITEFONT}$0 update${COLOR_END}" + echo "" + exit 1 + fi + fi + [ ! -d ${str_program_dir} ] && mkdir -p ${str_program_dir} + rm -f /usr/bin/kcp-server ${str_program_dir}/kcp-server + if [ "${Is_64bit}" == 'y' ] ; then + if [ ! -s ${str_program_dir}/kcp-server ]; then + if ! wget --no-check-certificate ${program_x64_download_url} -O ${str_program_dir}/kcp-server; then + echo "Failed to download kcp-server file!" + exit 1 + fi + fi + else + if [ ! -s ${str_program_dir}/kcp-server ]; then + if ! wget --no-check-certificate ${program_x86_download_url} -O ${str_program_dir}/kcp-server; then + echo "Failed to download kcp-server file!" + exit 1 + fi + fi + fi + [ ! -x ${str_program_dir}/kcp-server ] && chmod 755 ${str_program_dir}/kcp-server + if [ "${OS}" == 'CentOS' ]; then + chmod +x /etc/init.d/kcp-server + chkconfig --add kcp-server + else + chmod +x /etc/init.d/kcp-server + update-rc.d -f kcp-server defaults + fi + [ -s /etc/init.d/kcp-server ] && ln -s /etc/init.d/kcp-server /usr/bin/kcp-server + /etc/init.d/kcp-server start + ${str_program_dir}/kcp-server -version + echo "kcp-Server(XiaoBao) update success!" + else + echo "kcp-Server(XiaoBao) Not install!" + fi + echo "" +} +clear +strPath=`pwd` +rootness +fun_set_text_color +# Initialization +action=$1 +[ -z $1 ] +case "$action" in +install) + install_program_server_clang 2>&1 | tee /root/kcp-server-install.log + ;; +config) + configure_program_server_clang + ;; +uninstall) + uninstall_program_server_clang 2>&1 | tee /root/kcp-server-uninstall.log + ;; +update) + update_program_server_clang 2>&1 | tee /root/kcp-server-update.log + ;; +*) + fun_clang.cn + echo "Arguments error! [${action} ]" + echo "Usage: `basename $0` {install|uninstall|update|config}" + ;; +esac diff --git a/latest/kcp-server.init b/latest/kcp-server.init new file mode 100644 index 0000000..7944a5e --- /dev/null +++ b/latest/kcp-server.init @@ -0,0 +1,181 @@ +#! /bin/bash +# chkconfig: 2345 55 25 +# Description: Startup script for kcp-server on Debian. Place in /etc/init.d and +# run 'update-rc.d -f kcp-server defaults', or use the appropriate command on your +# distro. For CentOS/Redhat run: 'chkconfig --add ngrokd' +#======================================================= +# System Required: CentOS/Debian/Ubuntu (32bit/64bit) +# Description: Manager for kcp-server, Written by Clang +# Author: Clang +# Intro: http://koolshare.cn/forum-72-1.html +#======================================================= +### BEGIN INIT INFO +# Provides: kcp-server +# Required-Start: $all +# Required-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: starts the kcp-server +# Description: starts kcp-server using start-stop +### END INIT INFO + +PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin +ProgramName="kcp-server" +ProgramPath="/usr/local/kcp-server" +NAME=kcp-server +BIN=${ProgramPath}/${NAME} +CONFIGFILE=${ProgramPath}/config.json +LOGFILE=${ProgramPath}/kcp-server.log +SCRIPTNAME=/etc/init.d/${NAME} +PID_DIR=/var/run +PID_FILE=$PID_DIR/kcp-server.pid +version="1.1" +RET_VAL=0 + +[ -x $BIN ] || exit 0 + +fun_clangcn() +{ + echo "" + echo "#############################################################" + echo "# Manager ${NAME} v${version} for CentOS/Debian/Ubuntu (32bit/64bit)" + echo "# Intro: http://koolshare.cn/forum-72-1.html" + echo "# Author: Clang" + echo "#############################################################" + echo "" +} + +fun_check_run(){ + if netstat -ntupl | grep -q ${NAME};then + return 0 + else + rm -f $PID_FILE + return 1 + fi +} +fun_load_config(){ + if [ ! -r ${CONFIGFILE} ]; then + echo "config file ${CONFIGFILE} not found" + return 1 + fi +} +fun_start() +{ + if [ "${arg1}" = "start" ]; then + fun_clangcn + fi + if [ ! -d $PID_DIR ]; then + mkdir -p $PID_DIR || echo "failed creating PID directory ${PID_DIR}"; exit 1 + fi + if fun_check_run; then + echo "${ProgramName} (pid `pidof $NAME`) already running." + return 0 + fi + fun_load_config + echo -n "Starting ${ProgramName}..." + ${BIN} -c ${CONFIGFILE} > ${LOGFILE} 2>&1 & + PID=`pidof ${NAME}` + echo $PID > $PID_FILE + sleep 0.3 + if ! fun_check_run; then + echo "start failed" + return 1 + fi + echo " done" + echo "${ProgramName} (pid `pidof $NAME`)is running." + echo "read ${LOGFILE} for log" + return 0 +} + +fun_stop(){ + if [ "${arg1}" = "stop" ] || [ "${arg1}" = "restart" ]; then + fun_clangcn + fi + if fun_check_run; then + echo -n "Stoping ${ProgramName} (pid `pidof $NAME`)... " + kill `pidof $NAME` + if [ "$?" != 0 ] ; then + echo " failed" + exit 1 + else + echo " done" + rm -f $PID_FILE + fi + else + echo "${ProgramName} is not running." + fi +} +fun_restart(){ + fun_stop + fun_start +} +fun_status(){ + if netstat -ntulp | grep -q ${NAME}; then + PID=`pidof ${NAME}` + echo "${ProgramName} (pid $PID) is running..." + netstat -ntulp | grep "${NAME}" + else + echo "${ProgramName} is stopped" + exit 0 + fi +} +checkos(){ + if grep -Eqi "CentOS" /etc/issue || grep -Eq "CentOS" /etc/*-release; then + OS=CentOS + elif grep -Eqi "Debian" /etc/issue || grep -Eq "Debian" /etc/*-release; then + OS=Debian + elif grep -Eqi "Ubuntu" /etc/issue || grep -Eq "Ubuntu" /etc/*-release; then + OS=Ubuntu + else + echo "Not support OS, Please reinstall OS and retry!" + exit 1 + fi +} +check_nano(){ + nano -V + #echo $? + if [[ $? -le 1 ]] ;then + echo " Run nano success" + else + echo " Run nano failed" + checkos + if [ "${OS}" == 'CentOS' ]; then + echo " Install centos nano ..." + #yum -y update + yum -y install nano + else + echo " Install debian/ubuntu nano ..." + apt-get update -y + apt-get install -y nano + fi + fi + # if [[ ! -d "$result" ]]; then + # echo "not found" + # else + # echo "found" + # fi + echo $result +} +fun_config(){ + check_nano + if [ -s ${CONFIGFILE} ]; then + nano ${CONFIGFILE} + else + echo "${ProgramName} configuration file not found!" + fi +} + +arg1=$1 +arg2=$2 +[ -z ${arg1} ] +case "${arg1}" in + start|stop|restart|status|config) + fun_${arg1} ${arg2} + ;; + *) + fun_clangcn + echo "Usage: $SCRIPTNAME {start|stop|restart|status|config}" + RET_VAL=1 + ;; +esac +exit $RET_VAL