#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 2017-2023 OpenFOAM Foundation
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# License
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see .
#
# Script
# openfoam10-macos
#
# Description
# Run script for an OpenFOAM 10 Docker image at:
# https://hub.docker.com/r/openfoam
#
#------------------------------------------------------------------------------
Script=${0##*/}
ver=10
usage () {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat < /dev/null)
[ -n "$user_id" ] || usage "Cannot determine current user ID"
group_id=$(id -g)
home_dir='/home/openfoam'
echo "Launching $0"
echo "User: \"$(id -un)\" (ID $user_id, group ID $group_id)"
ifaces=$(ifconfig | grep ^en | cut -d: -f1)
[ "$ifaces" ] || \
usage "Cannot find a network interface for DISPLAY with ifconfig" \
"Please report an issue at http://bugs.openfoam.org" \
" providing the output of the command: ifconfig"
for i in $ifaces
do
ip=$(ifconfig "$i" | grep inet | awk '$1=="inet" {print $2}')
[ "$ip" ] && break
done
[ "$ip" ] || \
usage "Cannot find a network IP for DISPLAY with ifconfig" \
"Please report an issue at https://bugs.openfoam.org" \
" providing the output of the command: ifconfig"
xhost + "$ip"
[ "$upgrade" ] && docker pull "$docker_image"
# shellcheck disable=SC2086
docker run -it \
--rm \
-e DISPLAY=$IP:0 \
-u "$user_id":"$group_id" \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v "$mount_dir":$home_dir \
$docker_options \
"$docker_image"
[ -n "$custom_xauth" ] && [ -e "$xauth_path" ] && rm "$xauth_path"