0

I have a problem with my init service. After I started the service lxd-agent I tried to check its status. I can see in the output of /etc/rc.d/rc.lxd-agent status below message:

daemon:  lxd-agent is running (pid 3351) (client is not running) 

Command lxc exec slackware-vm -- sudo -i redirects me into the proper bash shell. Can I just ignore the above message complaining about that client is not running and everything will work fine? daemon is the following program: http://libslack.org/daemon/.

Here's my /etc/rc.d/rc.lxd-agent script:

#!/bin/sh

PRGNAM="lxd-agent"
BIN="/run/lxd_config/drive/lxd-agent"
PID="/run"
CHDIR="/run/lxd_config/drive"

lxd_agent_start() {
  if /usr/bin/daemon --running --name "${PRGNAM}" --pidfiles "${PID}"; then
    echo "${PRGNAM} is already running."
  else
    echo -n "Starting ${PRGNAM}..."
    /usr/bin/daemon --respawn --name "${PRGNAM}" --pidfiles "${PID}" \
      --chdir "${CHDIR}" -- "${BIN}"
    echo "done."
  fi
}

lxd_agent_stop() {
  if /usr/bin/daemon --running --name "${PRGNAM}" --pidfiles "${PID}"; then
    echo -n "Stopping ${PRGNAM}..."
    /usr/bin/daemon --stop --name "${PRGNAM}" --pidfiles "${PID}"
    echo "done."
  else
    echo "${PRGNAM} is not running."
  fi
}

lxd_agent_restart() {
  if /usr/bin/daemon --running --name "${PRGNAM}" --pidfiles "${PID}"; then
    echo -n "Restarting ${PRGNAM}..."
    /usr/bin/daemon --restart --name "${PRGNAM}" --pidfiles "${PID}"
    echo "done."
  else
    echo "${PRGNAM} is not running."
    exit 1
  fi
}

lxd_agent_status() {
  /usr/bin/daemon --running --name "${PRGNAM}" --pidfiles "${PID}" --verbose
}

case $1 in
  "start")
    lxd_agent_start
    ;;
  "stop")
    lxd_agent_stop
    ;;
  "restart")
    lxd_agent_restart
    ;;
  "status")
    lxd_agent_status
    ;;
  *)
    echo "Usage: $0 {start|stop|restart|status}"
    exit 1
    ;;
esac
qidim
  • 1
  • 1
  • 1
    Some quick tips about your code : 1) don't use caps for custom variables, they are usually reserved for system variables : https://stackoverflow.com/q/673055/2057091 2) you have a typo in`lxd_agent_start`, you wrote `PIS` instead of `PID` – Aserre Sep 02 '21 at 06:28
  • @Aserre the `case $1 in` at the end is what defines the arguments the init-script takes (`status`) is one. I don't see a problem with the client not running. The agent is the server, the lxc-client is simply a command line tool to manage your server. Double check how you are using lxd (container, virtual-machine) and check the documentation. – David C. Rankin Sep 02 '21 at 06:46
  • @Aserre `/etc/rc.d/rc.lxd-agent status`, `lxd_agent_status` function – qidim Sep 02 '21 at 06:46
  • 1
    Excuse me, but I pasted the wrong code. Now is correct. – qidim Sep 02 '21 at 06:49
  • Slack and a lonely few others are the only remaining init-script distros. Everyone else has moved to systemd (which many users have embraced begrudgingly...) – David C. Rankin Sep 02 '21 at 07:02

0 Answers0