Запускать команду на экране, когда LSB initscript остановлен

Я пытаюсь заставить сервер Bukkit работать внутри экрана в качестве службы, запущенной из сценария LSB, но я не могу заставить его правильно остановиться . По сути, я хочу, чтобы он снова подключил экран и отправил команду «стоп» на консоль сервера, чтобы он все сохранил, а не просто был убит, но «sudo service bukkit stop» не делает » Похоже, я ничего не сделал с моим сценарием.

Кажется, что он останавливается, если я снова присоединяю экран к терминалу и набираю «стоп» на консоли Bukkit.

Кто-нибудь знает, в чем проблема? Мой сценарий init.d находится ниже ...

#!/bin/bash
### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

cd /etc/minecraftbukkit
case $1 in
 start)
  # Checked the PID file exists and check the actual status of process
  if [ -e $PIDFILE ]; then
   status_of_proc -p $PIDFILE $DAEMON "$NAME process" && status="0" || status="$?"
   # If the status is SUCCESS then don't need to start again.
   if [ $status = "0" ]; then
    exit # Exit
   fi
  fi
  # Start the daemon.
  screen -d -A -m -S "Bukkit152" sh ./bukkitrunner.sh
  ;;
 stop)
  # Stop the daemon.
  screen -d -r "Bukkit152"
  sleep 2
  stop
  ;;
 *)

esac
1
задан 28 February 2016 в 22:56
1 ответ

Управляется, чтобы заставить его работать с экраном в конце концов. Я забыл отправить обратный кэррейдж после команды "stop", также выяснилось, что мне пришлось использовать "stuff" для отправки команд на экран :P

Heres the working code:

#!/bin/bash
### BEGIN INIT INFO
# Provides:          scriptname
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start daemon at boot time
# Description:       Enable service provided by daemon.
### END INIT INFO

cd /etc/minecraftbukkit
case $1 in
 start)
  # Checked the PID file exists and check the actual status of process
  if [ -e $PIDFILE ]; then
   status_of_proc -p $PIDFILE $DAEMON "$NAME process" && status="0" || status="$?"
   # If the status is SUCCESS then don't need to start again.
   if [ $status = "0" ]; then
    exit # Exit
   fi
  fi
  # Start the daemon.
  screen -d -A -m -S "Bukkit152" sh ./bukkitrunner.sh
  ;;
 stop)
  # Stop the daemon.
  screen -S "Bukkit152" -p 0 -X stuff "stop$(printf \\r)"
  sleep 2
  ;;
 *)

esac

Thanks for @chicks for the heads-up about tmux, I'm looking in it in if there's any more problems...

0
ответ дан 4 December 2019 в 06:36

Теги

Похожие вопросы