|
|
@ -386,8 +386,18 @@ clean_unused_sessions() { |
|
|
|
[ -e "$f" ] || continue |
|
|
|
is_volume_used "$f" && continue |
|
|
|
## XXXvlab: the second rmdir should not be useful |
|
|
|
rm -f "$f" >/dev/null || rmdir "$f" >/dev/null || { |
|
|
|
debug "Unexpected session remnants $f" |
|
|
|
[ -d "$f" ] && { |
|
|
|
err "Unexpected directory as session remnant $(printf "%q" "$f")" >&2 |
|
|
|
echo " - can you contact support to report this issue ?" >&2 |
|
|
|
echo " - as a workaround, you can remove it manually using:" >&2 |
|
|
|
echo "" >&2 |
|
|
|
echo " rm -rf $(printf "%q" "$f")" >&2 |
|
|
|
echo "" >&2 |
|
|
|
return 1 |
|
|
|
} |
|
|
|
rm -f "$f" >/dev/null || { |
|
|
|
err "Couldn't delete $(printf "%q" "$f")" >&2 |
|
|
|
return 1 |
|
|
|
} |
|
|
|
done |
|
|
|
} |
|
|
@ -963,11 +973,16 @@ mk_docker_run_options() { |
|
|
|
) |
|
|
|
fi |
|
|
|
|
|
|
|
clean_unused_sessions |
|
|
|
clean_unused_sessions || return 1 |
|
|
|
filename=$(mktemp -p /tmp/ -t launch_opts-XXXXXXXXXXXXXXXX) |
|
|
|
p0 "${docker_run_opts[@]}" > "$filename" |
|
|
|
hash=$(hash_get < "$filename") || return 1 |
|
|
|
src="$SESSION_DIR/$UID-$hash" |
|
|
|
if [ -d "$src" ]; then |
|
|
|
err "Unexpected directory found in '$src'." |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
|
dest="/var/lib/compose/sessions/$UID-$hash" |
|
|
|
additional_docker_run_opts=( |
|
|
|
"-v" "$SESSION_DIR/$UID-$hash:$dest:ro" |
|
|
@ -984,8 +999,17 @@ mk_docker_run_options() { |
|
|
|
p0 "!env:$var=${!var}" |
|
|
|
done >> "$filename" |
|
|
|
|
|
|
|
if [ -e "$src" ]; then |
|
|
|
## compare content of $src and $filename |
|
|
|
if ! diff -q "$src" "$filename" >/dev/null; then |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
warn "Session already exists but content is different. Squashing." |
|
|
|
fi |
|
|
|
|
|
|
|
mkdir -p "$SESSION_DIR" || return 1 |
|
|
|
mv -f "$filename" "$src" || return 1 |
|
|
|
|
|
|
|
cat "$filename" > "$src" || return 1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
@ -995,6 +1019,10 @@ load_env() { |
|
|
|
if [ -z "$COMPOSE_LAUNCHER_OPTS" ]; then |
|
|
|
mk_docker_run_options "$@" || return 1 |
|
|
|
else |
|
|
|
[ -d "$COMPOSE_LAUNCHER_OPTS" ] && { |
|
|
|
err "Variable \$COMPOSE_LAUNCHER_OPTS provided but it points on a directory." |
|
|
|
return 1 |
|
|
|
} |
|
|
|
set_os || return 1 |
|
|
|
while read-0 opt; do |
|
|
|
if [[ "$opt" == "!env:"* ]]; then |
|
|
|