开发者

Error in bash script

I created a small script to start openvpn but when I try to execute it i get the followi开发者_如何学Gong error message and i don't know what i did wrong as i'm not that good with this language:

/etc/init.d/ovpn start
Options error: Unrecognized option or missing parameter(s) in [CMD-LINE]:1: cd (2.1.0)
Use --help for more information.

Here's my code:

#!/bin/sh -e

CONFIG_DIR=/etc/openvpn


start_vpn () {
    # load the firewall
    $CONFIG_DIR/firewall.sh

    # load TUN/TAP kernel module
    modprobe tun

    # enable IP forwarding
    echo 1 > /proc/sys/net/ipv4/ip_forward

    openvpn --cd $dir --daemon --config server.conf
}
stop_vpn () {
    killall -TERM openvpn
}

case "$1" in
start)
  start_vpn
  ;;
stop)
  stop_vpn
  ;;
restart)
  stop_vpn
  start_vpn
  ;;
*)
  echo "Usage: $0 {start|stop|restart}" >&2
  exit 1
  ;;
esac

exit 0

# vim:set ai sts=2 sw=2 tw=0:


$dir seems not to be initialized, causing the --cd option to openvpn to fail (directory not specified).


I don't see anything wrong with the script. It looks like an error from the openvpn program who does not recognize the --cd option in the argument list. Check if your openvpn program supports this option.


Try changing your shebang to #!/bin/bash. Also try to find out what $dir since i don't see it declared

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜