0

I have this init script to run uwsgi. It works, but only on the start command. All the other commands give me this error:

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

It seems like the colons should be there from the tutorials I am reading, and yet it is telling me to remove them?

#!/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
1
  • 1
    esac goes at the end, after all of the options. Doing a google search for 'case bash' leads you to page that shows you a clear example, for an init script no less.
    – yoonix
    Feb 23, 2015 at 21:27

1 Answer 1

1

Get rid of the esac keywords before the ;;s. There should only be one at the very end to match the initial case keyword.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.