mirror of
https://github.com/farmOS/farmOS.git
synced 2024-02-23 11:37:38 +01:00
Refactor docker-entrypoint.sh to use functions.
This commit is contained in:
parent
13cf34d528
commit
8b0c03d6ff
|
@ -1,29 +1,52 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# If the sites folder exists, preserve it by temporarily moving it up one dir.
|
# Function for archiving the sites folder.
|
||||||
if [ -e /var/www/html/sites ]; then
|
archive_sites () {
|
||||||
echo >&2 "Existing sites folder detected. Moving temporarily..."
|
|
||||||
mv /var/www/html/sites /var/www/sites
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Remove the existing farmOS codebase, if it exists.
|
# If the sites folder exists, preserve it by temporarily moving it up one dir.
|
||||||
if [ -e /var/www/html/index.php ]; then
|
if [ -e /var/www/html/sites ]; then
|
||||||
echo >&2 "Removing existing farmOS codebase..."
|
echo >&2 "Existing sites folder detected. Moving temporarily..."
|
||||||
find /var/www/html -mindepth 1 -delete
|
mv /var/www/html/sites /var/www/sites
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Download the packaged release of farmOS, if a dev environment is not desired.
|
# Function for restoring the sites folder.
|
||||||
if ! $FARMOS_DEV; then
|
restore_sites () {
|
||||||
|
|
||||||
|
# Restore the sites folder.
|
||||||
|
if [ -e /var/www/sites ]; then
|
||||||
|
echo >&2 "Restoring sites directory..."
|
||||||
|
rm -r /var/www/html/sites \
|
||||||
|
&& mv /var/www/sites /var/www/html/sites
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Change ownership of the sites folder.
|
||||||
|
chown -R www-data:www-data /var/www/html/sites
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function for deleting the farmOS codebase.
|
||||||
|
delete_farmos () {
|
||||||
|
|
||||||
|
# Remove the existing farmOS codebase, if it exists.
|
||||||
|
if [ -e /var/www/html/index.php ]; then
|
||||||
|
echo >&2 "Removing existing farmOS codebase..."
|
||||||
|
find /var/www/html -mindepth 1 -delete
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function for downloading and unpacking a farmOS release.
|
||||||
|
build_farmos_release () {
|
||||||
|
|
||||||
# Download and unpack farmOS release.
|
# Download and unpack farmOS release.
|
||||||
echo >&2 "Downloading farmOS $FARMOS_VERSION..."
|
echo >&2 "Downloading farmOS $FARMOS_VERSION..."
|
||||||
curl -SL "http://ftp.drupal.org/files/projects/farm-${FARMOS_VERSION}-core.tar.gz" -o /usr/src/farm-${FARMOS_VERSION}-core.tar.gz
|
curl -SL "http://ftp.drupal.org/files/projects/farm-${FARMOS_VERSION}-core.tar.gz" -o /usr/src/farm-${FARMOS_VERSION}-core.tar.gz
|
||||||
echo >&2 "Unpacking farmOS $FARMOS_VERSION..."
|
echo >&2 "Unpacking farmOS $FARMOS_VERSION..."
|
||||||
tar -xvzf /usr/src/farm-${FARMOS_VERSION}-core.tar.gz -C /var/www/html/ --strip-components=1
|
tar -xvzf /usr/src/farm-${FARMOS_VERSION}-core.tar.gz -C /var/www/html/ --strip-components=1
|
||||||
|
}
|
||||||
|
|
||||||
# Or, build a development environment.
|
# Function for building a dev branch of farmOS.
|
||||||
else
|
build_farmos_dev () {
|
||||||
|
|
||||||
# Clone the farmOS installation profile, if it doesn't already exist.
|
# Clone the farmOS installation profile, if it doesn't already exist.
|
||||||
if ! [ -e /var/farmOS/build-farm.make ]; then
|
if ! [ -e /var/farmOS/build-farm.make ]; then
|
||||||
|
@ -38,18 +61,29 @@ else
|
||||||
drush make --working-copy --no-gitinfofile /var/farmOS/build-farm.make /tmp/farmOS \
|
drush make --working-copy --no-gitinfofile /var/farmOS/build-farm.make /tmp/farmOS \
|
||||||
&& cp -r /tmp/farmOS/. /var/www/html \
|
&& cp -r /tmp/farmOS/. /var/www/html \
|
||||||
&& rm -r /tmp/farmOS
|
&& rm -r /tmp/farmOS
|
||||||
|
}
|
||||||
|
|
||||||
fi
|
# Function for building farmOS.
|
||||||
|
build_farmos () {
|
||||||
|
|
||||||
|
# If a development environment is desired, build from dev branch. Otherwise,
|
||||||
|
# build from official packaged release.
|
||||||
|
if $FARMOS_DEV; then
|
||||||
|
build_farmos_dev
|
||||||
|
else
|
||||||
|
build_farmos_release
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Archive the sites folder and delete the farmOS codebase.
|
||||||
|
archive_sites
|
||||||
|
delete_farmos
|
||||||
|
|
||||||
|
# Build farmOS.
|
||||||
|
build_farmos
|
||||||
|
|
||||||
# Restore the sites folder.
|
# Restore the sites folder.
|
||||||
if [ -e /var/www/sites ]; then
|
restore_sites
|
||||||
echo >&2 "Restoring sites directory..."
|
|
||||||
rm -r /var/www/html/sites \
|
|
||||||
&& mv /var/www/sites /var/www/html/sites
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Change ownership of the sites folder.
|
|
||||||
chown -R www-data:www-data /var/www/html/sites
|
|
||||||
|
|
||||||
# Execute the arguments passed into this script.
|
# Execute the arguments passed into this script.
|
||||||
echo "Attempting: $@"
|
echo "Attempting: $@"
|
||||||
|
|
Loading…
Reference in a new issue