From bc5e37ffd9bcb1f67b88b1933cd7e503d8c6484a Mon Sep 17 00:00:00 2001 From: George Melikov Date: Fri, 17 Jul 2020 16:59:04 +0300 Subject: [PATCH] Start ssh only after full boot Before this change instance may close ssh connection on boot with message: "System is booting up. See pam_nologin(8)" Connection closed by XXX port 22 , so manila think that password/private key is wrong and fails share creation. Closes-bug: #1888569 Change-Id: I032e77e2f16e1d445c72eb3abd99a09c413dabe5 Signed-off-by: George Melikov --- .../install.d/99-start-ssh-after-full-boot | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 elements/manila-ssh/install.d/99-start-ssh-after-full-boot diff --git a/elements/manila-ssh/install.d/99-start-ssh-after-full-boot b/elements/manila-ssh/install.d/99-start-ssh-after-full-boot new file mode 100755 index 0000000..abb2520 --- /dev/null +++ b/elements/manila-ssh/install.d/99-start-ssh-after-full-boot @@ -0,0 +1,24 @@ +#!/bin/bash + +if [ ${DIB_DEBUG_TRACE:-0} -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +DIB_INIT_SYSTEM=$(dib-init-system) +if [ "$DIB_INIT_SYSTEM" == "systemd" ]; then + POSSIBLE_NAMES=("ssh" "sshd") + for SERVICE_NAME in "${POSSIBLE_NAMES[@]}"; do + if [ -f "/lib/systemd/system/$SERVICE_NAME.service" ]; then + sudo cp /lib/systemd/system/$SERVICE_NAME.service \ + /etc/systemd/system/$SERVICE_NAME.service + sudo sed -i "/^After=/ s/$/ multi-user.target/" \ + /etc/systemd/system/$SERVICE_NAME.service + sudo sed -i "s/^WantedBy=multi-user.target//" \ + /etc/systemd/system/$SERVICE_NAME.service + fi + done +else + echo "Not supported for this init system" +fi