Skip to content

Commit 1a7e8c5

Browse files
authored
Merge pull request #231 from skodak/basedir
simplify basedir variable setting
2 parents b88d66d + 92b9f88 commit 1a7e8c5

File tree

3 files changed

+10
-11
lines changed

3 files changed

+10
-11
lines changed

bin/moodle-docker-compose

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
#!/usr/bin/env bash
22
set -e
33

4+
# First find out if this was called from symlink,
5+
# then find the real path of parent directory.
6+
# This is needed because macOS does not have GNU realpath.
7+
thisfile=$( readlink "${BASH_SOURCE[0]}" ) || thisfile="${BASH_SOURCE[0]}"
8+
basedir="$( cd "$( dirname "$thisfile" )/../" && pwd -P )"
9+
410
if [ ! -d "$MOODLE_DOCKER_WWWROOT" ];
511
then
612
echo 'Error: $MOODLE_DOCKER_WWWROOT is not set or not an existing directory'
@@ -13,15 +19,6 @@ then
1319
exit 1
1420
fi
1521

16-
# Nasty portable way to the directory of this script, following symlink,
17-
# because readlink -f not on OSX. Thanks stack overflow..
18-
SOURCE="${BASH_SOURCE[0]}"
19-
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
20-
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
21-
SOURCE="$(readlink "$SOURCE")"
22-
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
23-
done
24-
basedir="$( cd -P "$( dirname "$SOURCE" )/../" && pwd )"
2522
export ASSETDIR="${basedir}/assets"
2623

2724
# Test if we have docker compose v2, and keep quiet if we don't.

bin/moodle-docker-wait-for-app

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"
4+
thisfile=$( readlink "${BASH_SOURCE[0]}" ) || thisfile="${BASH_SOURCE[0]}"
5+
basedir="$( cd "$( dirname "$thisfile" )/../" && pwd -P )"
56

67
if [[ ! -z "$MOODLE_DOCKER_BROWSER" ]] && [[ "$MOODLE_DOCKER_BROWSER" == "chrome" ]] && ([[ ! -z "$MOODLE_DOCKER_APP_PATH" ]] || [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]] || [[ ! -z "$MOODLE_APP_VERSION" ]]);
78
then

bin/moodle-docker-wait-for-db

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )"
4+
thisfile=$( readlink "${BASH_SOURCE[0]}" ) || thisfile="${BASH_SOURCE[0]}"
5+
basedir="$( cd "$( dirname "$thisfile" )/../" && pwd -P )"
56

67
if [ -z "$MOODLE_DOCKER_DB" ];
78
then

0 commit comments

Comments
 (0)