【问题标题】:Syntax error of ";; unexpected" on simple init script for DebianDebian 的简单初始化脚本上的“;;意外”的语法错误
【发布时间】:2015-02-23 20:54:41
【问题描述】:

我有这个初始化脚本来运行 uwsgi。它有效,但仅适用于启动命令。所有其他命令都给我这个错误:

/etc/init.d/uwsgi: 27: /etc/init.d/uwsgi: Syntax error: ";;" unexpected

似乎我正在阅读的教程中应该有冒号,但它却告诉我删除它们?

#!/bin/sh
### BEGIN INIT INFO
# Provides:          uwsgi
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description:       This script manages uWSGI.
### END INIT INFO

DAEMON=/var/www/app/venv/bin/uwsgi
PIDFILE=/var/run/uwsgi.pid
DAEMON_ARGS="--ini /var/www/app/conf/uwsgi/app.ini --pidfile /var/run/uwsgi.pid"

. /lib/init/vars.sh
. /lib/lsb/init-functions

case "$1" in
  start)
  echo "Starting"
  start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
    || return 1
  start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
    $DAEMON_ARGS 1> /dev/null 2>&1 \
    || return 2
  esac
  ;;
  stop)
  echo "Stopping"
  start-stop-daemon --stop --quiet --retry=QUIT/30/KILL/5 --pidfile $PIDFILE --name uwsgi
  RETVAL="$?"
  [ "$RETVAL" = 2 ] && return 2
  start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  [ "$?" = 2 ] && return 2
  rm -f $PIDFILE
  return "$RETVAL"
  esac
  ;;
  status)
  status_of_proc "$DAEMON" "uwsgi" && exit 0 || exit $?
  ;;
  reload)
  echo "Reloading"
  start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name uwsgi
  return 0
  ;;
  *)
  echo "Usage: /etc/init.d/uwsgi {start|stop|status|reload|force-reload}" >&2
  exit 3
  ;;
esac
exit 0

【问题讨论】:

  • esac 在最后,在 all 选项之后。在谷歌上搜索“case bash”会引导你到一个页面,该页面向你展示了一个清晰的示例,同样是一个 init 脚本。

标签: linux bash shell init


【解决方案1】:

去掉;;s 之前的esac 关键字。最后应该只有一个匹配最初的 case 关键字。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多