@@ -79,24 +79,33 @@ DEFAULT_SSH_PORT=22
7979DEFAULT_SSH_USER=root
8080
8181# ---------------------------------------------------------------------------
82- # The KVM wrapper script is deployed to the **same path** as this entry-point
83- # on the management server. Resolve $0 to an absolute path so that the
84- # remote SSH call uses the correct location regardless of how this script was
85- # invoked (relative path, symlink, etc.).
82+ # Resolve this entry-point's absolute path so we can derive both the KVM
83+ # wrapper path and the log file name from the extension directory name.
84+ #
85+ # Layout:
86+ # management server: /usr/share/cloudstack-management/extensions/<name>/<name>.sh
87+ # KVM host (wrapper): /etc/cloudstack/extensions/<name>/<name>-wrapper.sh
88+ #
89+ # _EXT_DIR_NAME is the basename of the directory containing this script,
90+ # which equals the extension name assigned by CloudStack (e.g.
91+ # "extnet-isolated-gk3yys"). Both the wrapper path and the log file are
92+ # derived from it so that renamed deployments work automatically.
8693#
8794# Callers may still override the remote path via CS_NET_SCRIPT_PATH:
8895# CS_NET_SCRIPT_PATH=/custom/path/wrapper.sh network-namespace.sh <cmd> ...
8996# ---------------------------------------------------------------------------
9097_SELF=" $( readlink -f " $0 " 2> /dev/null \
9198 || realpath " $0 " 2> /dev/null \
9299 || echo " $0 " ) "
93- DEFAULT_SCRIPT_PATH=" ${_SELF} "
94-
95- # Derive the log file name from this script's own basename so that a renamed
96- # deployment (e.g. "my-extension.sh") writes to its own log file instead of
97- # a hardcoded "network-namespace.log".
98100_SCRIPT_BASENAME=" $( basename " ${_SELF} " .sh) "
99- LOG_FILE=" /var/log/cloudstack/management/${_SCRIPT_BASENAME} .log"
101+ _EXT_DIR_NAME=" $( basename " $( dirname " ${_SELF} " ) " ) "
102+
103+ # Remote wrapper path on each KVM host.
104+ DEFAULT_SCRIPT_PATH=" /etc/cloudstack/extensions/${_EXT_DIR_NAME} /${_SCRIPT_BASENAME} -wrapper.sh"
105+
106+ # Log file — under /var/log/cloudstack/extensions/ named after the extension.
107+ LOG_FILE=" /var/log/cloudstack/extensions/${_EXT_DIR_NAME} .log"
108+ mkdir -p " $( dirname " ${LOG_FILE} " ) " 2> /dev/null || true
100109TMPDIR_BASE=/tmp
101110
102111# ---------------------------------------------------------------------------
0 commit comments