LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 706|回复: 1

[求助]谁能为某些网通特殊拨号程序for linux写一个ebuild?

[复制链接]
发表于 2005-8-9 01:34:44 | 显示全部楼层 |阅读模式
程序在这里下载
http://218.29.0.252/self.html

另外,谁能帮忙把附带的启动脚本格式化为Gentoo风格?

附带的启动脚本

  1. #!/bin/sh

  2. EXCUTE_NAME="racer"
  3. X_NAME="race"

  4. verify_system()
  5. {
  6.   #check if this is a linux platform, if not linux, alert and quit
  7.   if [ `uname` != "Linux" ]; then
  8.         echo "This process being available ONLY on Linux"
  9.         return 1
  10.   fi

  11.   #check if it's root, otherwise quit
  12.   if [ `whoami` != "root" ]; then
  13.         echo "No more than root has previlege to run this process"
  14.         return 1
  15.   fi
  16.   #check size of log file
  17.   if [ -f "ecou.log" ]; then
  18.         FSIZE=`du -ks ecou.log | awk '{print $1}'`
  19.         if [ $FSIZE -gt 1000 ]; then
  20.                 >ecou.log       #clear the log file
  21.         fi
  22.   else
  23.              >ecou.log
  24.   fi

  25.   return 0
  26. }

  27. find_ecou()
  28. {
  29.    #FINDNUM=`ps -ef | grep "$EXCUTE_NAME" | grep -v grep | wc -l`
  30.    FINDNUM=`pgrep -nx "$EXCUTE_NAME" | wc -l`
  31.    if [ $FINDNUM -eq 0 ]; then
  32.         return 1
  33.    else
  34.         return 0
  35.    fi
  36. }

  37. start_ecou()
  38. {
  39.   if find_ecou
  40.   then
  41.         echo "The pocess is running"
  42.         exit
  43.   fi

  44.   #to which interface link with Internet
  45.   INTERNUM=`ifconfig -a | grep "HWaddr" | wc -l`
  46.   if [ $INTERNUM -eq 0 ]; then
  47.         echo "No net Interface can be found, may you type command such as insmod and ifup eth0 first"
  48.         return 1
  49.   fi

  50.   #if more than ONE eth installed, have to select one
  51.   CMPNUM=0
  52.   if [ "$INTERNUM" -gt "$CMPNUM" ]; then
  53.         ifconfig -a | grep "HWaddr" | awk '
  54.           BEGIN {
  55.                 i=0;
  56.                 printf("All names of your net interface installed\n");
  57.                 printf("-----------------------------------------\n");
  58.           }
  59.           {
  60.                 printf("\t%s\t%d\n", $1, i);
  61.                 i++;
  62.           }'
  63.          echo -n "Input one name to hace access with Internet (eth0): "
  64.          read INTERNAME
  65.          if [ ! $INTERNAME ]; then   #default name is eth0
  66.                 INTERNAME="eth0"
  67.          fi
  68.          #if the name input is correct or not
  69.          TMP_NUM=`ifconfig -a | grep "HWaddr" | grep "$INTERNAME" | wc -l`
  70.          if [ $TMP_NUM -eq 0 ]; then
  71.                 echo "You have input an invalid name of net interface"
  72.                 return 1
  73.          fi
  74.   else
  75.         INTERNAME=`ifconfig -a |grep "HWaddr" | awk '{print $1}'`
  76.   fi
  77.   echo "The name of interface is: " $INTERNAME

  78.   #okey, we have got correct env & parameters to run this process
  79.   #However, definitly necessary ini files as well as process file must be found
  80.   #in the same path
  81.   if [ ! -f "racer.ini" ]; then
  82.         echo "Warning: No relative file racer.ini found, re-creating"
  83.         echo "Server1=218.29.0.227" >racer.ini
  84.         echo "Server2=218.29.0.228" >>racer.ini
  85.   fi

  86.   if [ ! -f "$X_NAME" ]; then
  87.         echo "Unable to find process to run, try re-install your process again!"        return 1
  88.   fi

  89.   if [ ! -x "$X_NAME" ]; then
  90.         chmod +x $X_NAME
  91.   fi

  92.   if [ ! -L "$EXCUTE_NAME" ]; then
  93.         ln -s $X_NAME $EXCUTE_NAME
  94.   fi

  95.   ./$EXCUTE_NAME $INTERNAME

  96.   RETVAL=$?
  97.   if [ ! $RETVAL -eq 0 ]; then
  98.         echo "Failed to run the process"
  99.   else
  100.         echo "$EXCUTE_NAME has been started successfully"
  101.   fi

  102.   return 0
  103. }

  104. #for help info
  105. usage()
  106. {
  107.         echo "Usage: $0 {[start]|[status]|[stop]}"
  108. }

  109. #to stop ecou
  110. stop_ecou()
  111. {
  112.     #ps -ef | grep "$EXCUTE_NAME" | grep -v grep | awk '{print $2}' | xargs kill -SIGINT 2>/dev/null
  113.     pgrep -nx "$EXCUTE_NAME" | xargs kill -SIGINT 2>/dev/null
  114.     FINDNUM=1
  115.     while [ ! $FINDNUM -eq 0 ]
  116.     do
  117.         #FINDNUM=`ps -ef | grep "$EXCUTE_NAME" | grep -v grep | wc -l`
  118.         FINDNUM=`pgrep -nx "$EXCUTE_NAME" | wc -l`
  119.         sleep 1
  120.     done
  121.     if [ $? -eq 0 ]; then
  122.         echo "The process has been halted successfully"
  123.     else
  124.         echo "Failed to terminate the process OR the process is not running"
  125.     fi
  126. }

  127. #to tell status
  128. tell_status()
  129. {
  130.    #ps -ef | grep "$EXCUTE_NAME" | grep -v grep | awk '{print $2}' | xargs kill  -SIGUSR1 2>/dev/null
  131.    pgrep -nx "$EXCUTE_NAME" | xargs kill  -SIGUSR1 2>/dev/null
  132.    if [ $? -eq 0 ]; then
  133.         return;
  134.    else
  135.         echo "No status returned for $EXCUTE_NAME"
  136.    fi
  137. }

  138. #main
  139.   PARAM_NUM=$#
  140.   if [ ! $PARAM_NUM -eq 1 ]; then
  141.     usage
  142.     exit
  143.   fi

  144.   if [ -n $RACERC ]; then
  145.       cd $RACERC
  146.   fi

  147.   if ! verify_system
  148.   then
  149.      exit
  150.   fi

  151.   case $1 in
  152.         start)  start_ecou;;
  153.         status) tell_status;;
  154.         stop)   stop_ecou;;
  155.         *)      usage;;
  156.   esac
复制代码
发表于 2005-8-9 01:53:28 | 显示全部楼层
他原来的不是很好用么 ?
回复 支持 反对

使用道具 举报

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

本版积分规则

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