| #!/usr/bin/env bash |
| |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| |
| __my_ip=$(ifconfig|grep 'inet '|grep -v '127.0.0.1'| \ |
| head -1|awk '{print $2}') |
| pgmodeler() { |
| killall -0 quartz-wm > /dev/null 2>&1 |
| if [ $? -ne 0 ]; then |
| echo "ERROR: Quartz is not running. Start Quartz and try again." |
| else |
| socat TCP-LISTEN:6001,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" & |
| SOCAT_PGM_PID=$! |
| docker run --rm \ |
| -e HOME \ |
| -e XAUTHORITY=/tmp/xauth -v ~/.Xauthority:/tmp/xauth \ |
| -e DISPLAY=$__my_ip:1 --net host -v $HOME:$HOME \ |
| ${1+"$@"} kayvan/pgmodeler |
| kill $SOCAT_PGM_PID |
| fi |
| } |
| |
| pgmodeler.indockernet() { |
| killall -0 quartz-wm > /dev/null 2>&1 |
| if [ $? -ne 0 ]; then |
| echo "ERROR: Quartz is not running. Start Quartz and try again." |
| else |
| socat TCP-LISTEN:6001,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" & |
| SOCAT_PGM_PID=$! |
| docker run --rm \ |
| --network localpg_default \ |
| -e HOME \ |
| -e XAUTHORITY=/tmp/xauth -v ~/.Xauthority:/tmp/xauth \ |
| -e DISPLAY=$__my_ip:1 --net host -v $HOME:$HOME \ |
| ${1+"$@"} kayvan/pgmodeler |
| kill $SOCAT_PGM_PID |
| fi |
| } |