将goagent作为开机启动服务
Goagent无疑是免费资源中较为稳定的,安装地址 https://code.google.com/p/goagent/ 请自行解决。
开机启动脚本
详细信息见:
https://github.com/edrun/autostart/blob/master/goagent
sudo vim gedit /etc/init.d/goagent #加入下面内容
脚本内容
#! /bin/sh
### BEGIN INIT INFO
# Provides: goagent
# Required-Start: $remote_fs $all
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: goagent daemon
### END INIT INFO
PATH=/sbin:/usr/sbin:/bin:/usr/bin
NAME=goagent
DAEMON=/opt/goagent/goagent-goagent-7aab997/local/proxy.py
PIDFILE=/var/run/$NAME.pid
. /lib/init/vars.sh
. /lib/lsb/init-functions
do_start()
{
if [ -f $PIDFILE ]; then
start-stop-daemon --pidfile $PIDFILE --status
case "$?" in
0)
echo "$NAME is running !"
return 0
;;
1|3)
#nothing to do
;;
*)
echo "unable to determine status !"
return 1
;;
esac
fi
echo "starting $NAME ..."
start-stop-daemon --start --quiet --background --oknodo --exec $DAEMON --make-pidfile --pidfile $PIDFILE
echo 'done.'
return 0
}
do_stop()
{
echo "stopping $NAME ..."
if [ -f $PIDFILE ]; then
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
rm -f $PIDFILE
fi
echo 'done.'
}
do_status()
{
start-stop-daemon --pidfile $PIDFILE --status
case "$?" in
0)
echo "$NAME is running!"
;;
1|3)
echo "$NAME is not running!"
;;
*)
echo "unable to determine status!"
;;
esac
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
status)
do_status
;;
*)
echo "Usage: $0 start|stop" >&2
exit 3
;;
esac
加入自启动
sudo apt-get install sysv-rc-conf sudo sysv-rc-conf

测试
sudo service goagent start
输出如下:
hl@hl-NV57H:~$ psaux|grep goagent’? See http://procps.sf.net/faq.html
Warning: bad ps syntax, perhaps a bogus ’
root 1360 0.3 0.3 18020 14172 ? S 20:55 0:25 python /opt/goagent/goagent-goagent-7aab997/local/proxy.py
hl 5838 0.2 0.2 19360 9364 pts/3 S+ 22:11 0:06 vim 2013-05-08-ubuntu-longe-goagent.textile
hl 6322 0.0 0.0 5812 836 pts/2 S+ 22:50 0:00 grep —color=auto goagent