Raspberry pi 2 finalspeed auto start

preview

为了更好的体验FQ,大神开发了fianlspeed(不过有一点这个是双边加速的),对于bandwagon小机来说再好不过了,

参考

finalspeed 项目地址(好像原作者已经删除了源码):https://github.com/d1sm/finalspeed

finalspeed CLI项目地址:https://github.com/wholeworm/finalspeed

目标

finalspeed server/client GUI 在这里不再累述.
这里主要说明一下无GUI版本在raspberry pi 2 上开机自启服务
在raspberry pi 上运行finalspeed client CLI:

#运行CLI版
sudo java -jar finalspeed.jar -b 

但是怎么让它开机自启呢?

  • 在/etc/init.d/下面创建一个finalspeed 脚本
#!/bin/bash
### BEGIN INIT INFO
# Provides:          FinalSpeedClient
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: FinalSpeed Client Background Service Management
# Description:       Used to ensure FinalSpeed starts/stops etc
### END INIT INFO

DAEMON_PATH="/home/pi/fs"

DAEMON="java -Xss256k -Xmx256m -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true -Dfile.encoding=UTF-8 -jar finalspeed.jar -b > log"
DAEMONOPTS=""

NAME=FinalSpeed
DESC="Runs FinalSpeed"
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

case "$1" in
start)
       printf "Starting $NAME..."
       cd $DAEMON_PATH
       PID=`$DAEMON $DAEMONOPTS > /dev/null 2>&1 & echo $!`
       #echo "Saving PID" $PID " to " $PIDFILE
       if [ -z $PID ]; then
           printf "%s " "Fail"
       else
           echo $PID > $PIDFILE
           printf "%s " " OK"
       fi
;;
status)
       printf "Checking $NAME..."
       if [ -f $PIDFILE ]; then
           PID=`cat $PIDFILE`
           if [ -z "`ps axf | grep ${PID} | grep -v grep`" ]; then
               printf "%s " "Process dead but pidfile exists"
           else
               echo " Running"
           fi
       else
           printf "%s " " Service not running"
       fi
;;
stop)
       printf "Stopping $NAME"
           PID=`cat $PIDFILE`
           cd $DAEMON_PATH
       if [ -f $PIDFILE ]; then
           kill -HUP $PID
           printf "%s " " OK"
           rm -f $PIDFILE
       else
           printf "%s " "pidfile not found"
       fi
;;

restart)
   $0 stop
   $0 start
;;

*)
       echo "Usage: $0 {status|start|stop|restart}"
       exit 1
esac
  • 加上权限
chmod +x /etc/init.d/finalspeed
  • 启动/关闭/重启 finalspeed服务
sudo service finalspeed start
sudo service finalspeed stop
sudo service finalspeed restart
  • 开机自启finalspeed
sudo update-rc.d finalspeed defaults
  • 取消finalspeed 开机自启
sudo update-rc.d -f finalspeed remove

评论

还没有人评论,抢个沙发吧...

Viagle Blog

欢迎来到我的个人博客网站