This commit is contained in:
Wang Sen Di
2025-11-27 13:07:07 +08:00
parent 000a12d3f2
commit 3f40114dd9
2 changed files with 6 additions and 15 deletions

View File

@@ -6,15 +6,7 @@
_script_path_this=$(realpath "$(ps -p $$ -o args= 2>/dev/null | awk '{print $2}')")
_latter="${_script_path_this#/apps/data}"
if [[ "$CONTAINER_NAME" == "" ]]; then CONTAINER_NAME=$(grep devices </proc/self/cgroup | grep -Po '[0-9a-z]{64}' | cut -c1-12); fi
if [[ "${APPS_DATA}" == "" ]]; then APPS_DATA=$(docker inspect "$CONTAINER_NAME" -f '{{range .Mounts}}{{if eq .Destination "/apps/data"}}{{.Source}}{{end}}{{end}}'); fi
if [[ "${APPS_DATA}" == "" ]]; then
# echo "nsenter.sh 未挂载 /apps/data 到外部路径"
_data_upper_dir=$(docker inspect "$CONTAINER_NAME" -f '{{.GraphDriver.Data.UpperDir}}')
_absolute_path="${_data_upper_dir}$_script_path_this"
else
_absolute_path="${APPS_DATA}$_latter"
fi
_absolute_path="${APPS_DATA}$_latter"
nsenter --mount=/host/proc/1/ns/mnt --net=/host/proc/1/ns/net /usr/bin/bash "$_absolute_path"
exit