atftp 在SUSE Linux中的源代码安装配置方法

tftp协议一般用在PXE启动,常用的有atftp和tftpd-hpa,推荐使用atftp,因为atftp是唯一的免费的符合RFC规范的TFTP服务器。


下载atftp
http://down1.chinaunix.net/distfiles/atftp-0.7.tar.gz


考虑到有的Linux系统没有start-stop-daemon程序,可以自行安装。
下面是安装方法,我的SUSE是有的,因此编译后的程序没有经过测试,不保证正确。


下载start-stop-daemon
http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz

 


安装 start-stop-daemon
tar xzvf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
cd apps
gcc –o start-stop-daemon start-stop-daemon.c
cp start-stop-daemon /sbin



安装atftp

如果需要将来的tftp支持pcre参数,需要安装pcre库,因为atftp链接需要。

 

pcre库主页

http://www.pcre.org/

 

下载pcre库源代码

http://ftp.osuosl.org/pub/haiku/releases/r1alpha2/sources/libpcre-8.02_haiku-2010-04-29.tar.xz

 

解压xz文件解压工具

http://tukaani.org/xz/xz-4.999.9beta.tar.bz2

 

$tar xzvf xz-4.999.9beta.tar.bz2
$./configure --prefix=/opt/gnu/xz

$make

$make install

$ln -s /opt/gnu/bin/xz /bin/xz

$xz -d libpcre-8.02_haiku-2010-04-29.tar.xz

$tar xvf libpcre-8.02_haiku-2010-04-29.tar

$cd pcre-8.02

$ ./configure --prefix=/opt/mathlibs/pcre --enable-pcretest-libreadline --enable-pcregrep-libz --enable-pcregrep-libbz2

$make

$make install

$ln -s /opt/mathlibs/pcre/lib/libpcre.so /lib/libpcre.so


$tar xzvf atftp-0.7.tar.gz
$cd atftp-0.7

因为此软件包比较老,目前比较新的gcc编译会有问题。
为了编译它,需要修改两个文件stats.c和argz.h。

 

$sed -i '160,161s/CLK_TCK/CLOCKS_PER_SEC/' stats.c
$sed -i '183,197 s/__THROW//' argz.h

$./configure -prefix=/opt/gnu/atftp --enable-libpcre --enable-debug
$make
$make install
$ln -s /opt/gnu/atftp/sbin/atftpd /usr/sbin/atftpd

 



Xinetd进程启动方式

建立文件/etc/xinetd.d/tftp
$vi  /etc/xinetd.d/tftp

 

内容如下


service tftp
{
id = tftp-udp
disable = no
socket_type = dgram
protocol = udp
wait = yes
user = nobody
nice = 5
server = /opt/gnu/atftp/sbin/atftpd
server_args = /tftpboot
}
$service xinetd restart
$ps –ef|grep atftpd

 

我安装此方法配置后启动失败,没找到原因,如果你也是,可以用下面的守护进程启动方式。



独立守护进程启动方式


vi /etc/init.d/atftpd

#! /bin/sh
# Author: linfengfeiye@gmail.com, template by ro@suse.de
# /etc/init.d/atftpd
#
### BEGIN INIT INFO
# Provides:          atftpd
# Required-Start:    $syslog $network
# Required-Stop:    $syslog $network
# Default-Start:     3 5
# Default-Stop:      0 1 2 4 6
# Description:       Launch atftpd server, a TFTP server useful
#                    for network boot (PXE).
### END INIT INFO
# Determine the base and follow a runlevel link name.
base=${0##*/}
link=${base#*[SK][0-9][0-9]}


. /etc/rc.status
rc_reset

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/atftpd
NAME=atftpd
DESC="Advanced TFTP server"
USE_INETD=true
OPTIONS=""

test -f $DAEMON || { echo "/usr/sbin/atftpd not exists"; rc_failed 5; rc_status -v; rc_exit; }

if [ -f /etc/atftpd.conf ]; then
. /etc/atftpd.conf
fi

if [ "$USE_INETD" = "true" ]; then
echo "not configured in dameon,use xinetd to start atftpd"
rc_failed 6
rc_status -v;
rc_exit;
fi

# Make sure we have --daemon when not using inetd
echo "$OPTIONS"|grep -q -- --daemon || OPTIONS="--daemon $OPTIONS"

case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --oknodo --quiet --exec $DAEMON -- $OPTIONS
rc_status -v;
;;

stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
rc_status -v
;;

restart|reload|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --oknodo --quiet --exec $DAEMON
sleep 1
start-stop-daemon --start --oknodo --quiet --exec $DAEMON -- $OPTIONS
rc_status -v
;;

*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
rc_status -v
;;

esac
exit 0
rc_exit      


守护进程启动方式配置文件


vi /etc/atftpd.conf
USE_INETD=false
OPTIONS="--tftpd-timeout 300 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 --mcast-ttl 1 --maxthread 100 --verbose=5 /tftpboot"



错误:
service atftpd start                                             done
ps –ef|grep atfpd
未启动。
tail /var/log/messages
出现
atftpd: can't bind port :69/udp

 

解决:
找到/etc/xinetd.d/tftp

disable = yes 修改为 disable = no 后保存

运行  service xinetd restart

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
linux系统命令start-stop-daemon的源码及二进制,其也提供了一个服务启动脚本模板。 此程序能帮助你实现将命令行程序变成服务运行,比如将"java -jar xxx.jar" 放在后台执行。 ./start-stop-daemon --help start-stop-daemon 1.9.18 for Debian - small and fast C version written by Marek Michalkiewicz , public domain. Usage: start-stop-daemon -S|--start options ... -- arguments ... start-stop-daemon -K|--stop options ... start-stop-daemon -H|--help start-stop-daemon -V|--version Options (at least one of --exec|--pidfile|--user is required): -x|--exec program to start/check if it is running -p|--pidfile pid file to check -c|--chuid change to this user/group before starting process -w|--chdir change the work directory to 'dir' -u|--user | stop processes owned by this user -n|--name stop processes with this name -s|--signal signal to send (default TERM) -a|--startas program to start (default is ) -N|--nicelevel add incr to the process's nice level -b|--background force the process to detach -m|--make-pidfile create the pidfile before starting -R|--retry check whether processes die, and retry -t|--test test mode, don't do anything -o|--oknodo exit status 0 (not 1) if nothing done -q|--quiet be more quiet -v|--verbose be more verbose Retry is |//... where is one of -|[-] send that signal wait that many seconds forever repeat remainder forever or may be just , meaning //KILL/ Exit status: 0 = done 1 = nothing done (=> 0 if --oknodo) 3 = trouble 2 = with --retry, processes wouldn't die

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值