Skip to content

Commit 0bf96f1

Browse files
authored
Merge pull request #59 from NuCivic/proposed_release_for_tag_1501274745
1501274745: Proposed release for 7.x-1.13.6
2 parents 3c67a4f + 3cac483 commit 0bf96f1

File tree

98 files changed

+1030
-640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1030
-640
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
/**
4+
* @file
5+
* Routing-script for the built-in PHP web server.
6+
*
7+
* The built-in webserver should only be used for development and testing as it
8+
* has a number of limitations that makes running Drupal on it highly insecure
9+
* and somewhat limited.
10+
*
11+
* In particular be aware that:
12+
* - The server is single-threaded, any requests made during the execution of
13+
* the main request will hang until the main request has been completed.
14+
* - The webserver does not enforce any of the settings in .htaccess in
15+
* particular a remote user will be able to download files that normally
16+
* would be protected from direct access such as .module files.
17+
*
18+
* Usage:
19+
* php -S localhost:8888 .ht.router.php
20+
*
21+
* @see http://php.net/manual/en/features.commandline.webserver.php
22+
*/
23+
24+
$url = parse_url($_SERVER['REQUEST_URI']);
25+
if (file_exists('.' . $url['path'])) {
26+
// Serve the requested resource as-is.
27+
return FALSE;
28+
}
29+
// The use of a router-script means that a number of $_SERVER variables has to
30+
// be updated to point to the index-file.
31+
$index_file_absolute = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . 'index.php';
32+
$index_file_relative = DIRECTORY_SEPARATOR . 'index.php';
33+
// SCRIPT_FILENAME will point to the router-script itself, it should point to
34+
// the full path to index.php.
35+
$_SERVER['SCRIPT_FILENAME'] = $index_file_absolute;
36+
// SCRIPT_NAME and PHP_SELF will either point to /index.php or contain the full
37+
// virtual path being requested depending on the url being requested. They
38+
// should always point to index.php relative to document root.
39+
$_SERVER['SCRIPT_NAME'] = $index_file_relative;
40+
$_SERVER['PHP_SELF'] = $index_file_relative;
41+
// Require the main index-file and let core take over.
42+
require $index_file_absolute;
+18-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
require 'yaml'
22

3+
# Deep merge only available in ruby >= 3.0
4+
# TODO: replace defaults with custom deep_merge
5+
36
begin
47
CONFIG = YAML.load_file("config/config.yml")
58
rescue Exception => msg
69
puts "Loading of Configuration errored out with: #{msg}."
710
puts "Using default CONFIG instead."
8-
CONFIG = {"circle" => {"skip_features" => []}}
11+
CONFIG = {}
12+
end
13+
14+
if not CONFIG.has_key? "circle"
15+
CONFIG["circle"] = {}
916
end
1017

18+
if not CONFIG["circle"].has_key? "skip_features"
19+
CONFIG["circle"]["skip_features"] = []
20+
end
1121

22+
if not CONFIG.has_key? "default"
23+
CONFIG["default"] = {}
24+
end
25+
26+
if not CONFIG["default"].has_key? "https_everywhere"
27+
CONFIG["default"]["https_everywhere"] = false
28+
end
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
require "./dkan/.ahoy/.scripts/config.rb"
2+
3+
if CONFIG["default"]["https_everywhere"]
4+
url="surl"
5+
else
6+
url="url"
7+
end
8+
9+
url=`ahoy drush --uri="$(ahoy docker #{url})" uli`
10+
os =`uname`
11+
12+
if os =~ /Darwin/
13+
`open #{url}`
14+
else
15+
puts url
16+
end

profiles/dkan/.ahoy/.scripts/drupal-rebuild.sh

+7-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,13 @@ fi
1212

1313
drush --root=docroot make --concurrency=$concurrency --prepare-install dkan/drupal-org-core.make docroot --yes
1414

15-
drush --root=docroot -y --verbose $root si minimal --sites-subdir=default --account-pass='admin' --db-url=$1 install_configure_form.update_status_module='array(false,false)' &&
15+
drush --root=docroot -y --verbose si minimal --sites-subdir=default --account-pass='admin' --db-url=$1 install_configure_form.update_status_module='array(false,false)' &&
1616
ln -s ../../dkan docroot/profiles/dkan
1717
chmod +w docroot/sites/default/settings.php
18-
printf "// DKAN Datastore Fast Import options.\n\$databases['default']['default']['pdo'] = array(\n PDO::MYSQL_ATTR_LOCAL_INFILE => 1,\n PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 1,\n);" >> docroot/sites/default/settings.php
18+
19+
if [ "$AHOY_CMD_PROXY" = "DOCKER" ]; then
20+
printf "// Docker Database Settings\n\$databases['default']['default'] = array(\n 'database' => 'drupal',\n 'username' => 'drupal',\n 'password' => '123',\n 'host' => 'db',\n 'port' => '',\n 'driver' => 'mysql',\n 'prefix' => '',\n);\n" >> docroot/sites/default/settings.php
21+
fi
22+
printf "// DKAN Datastore Fast Import options.\n\$databases['default']['default']['pdo'] = array(\n PDO::MYSQL_ATTR_LOCAL_INFILE => 1,\n PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => 1,\n);\n" >> docroot/sites/default/settings.php
23+
1924
chmod -w docroot/sites/default/settings.php
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
if [ "$HOSTNAME" = "cli" ]; then
3+
HOST=cli
4+
else
5+
HOST=localhost
6+
fi
7+
8+
cp ./dkan/.ahoy/.scripts/.ht.router.php ./docroot/
9+
cd ./docroot
10+
11+
echo $HOST
12+
php -S $HOST:8888 .ht.router.php

profiles/dkan/.ahoy/dkan.ahoy.yml

+18-15
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ commands:
44
drupal-rebuild:
55
usage: 'Builds a drupal site in ./docroot. Requires database url.'
66
cmd: |
7-
if [ "$AHOY_CMD_PROXY" != "DOCKER" ]; then
8-
ARGS="{{args}}"
9-
else
7+
if [ "$AHOY_CMD_PROXY" = "DOCKER" ]; then
108
ARGS=`ahoy docker mysql-url`
119
fi
10+
11+
# If no mysql URL from docker, use passed in args.
12+
if [ "$ARGS" = "" ];then
13+
ARGS="{{args}}"
14+
fi
1215
if [[ "$ARGS" != mysql* ]]; then
1316
echo "You need to specify the drupal db url to use in the form mysql://root:root@localhost/db as an argument."
1417
exit 1
@@ -44,9 +47,11 @@ commands:
4447
mkdir backups
4548
fi
4649
if [ -f backups/last_install.sql ] && ahoy confirm "An existing installation backup exists at backups/last_install.sql, do you want to use that instead of reinstalling from scratch?"; then
47-
ahoy drush sql-drop -y
48-
ahoy drush cc all
49-
ahoy drush sql-cli < backups/last_install.sql
50+
51+
ahoy drush sql-drop -y && \
52+
echo "... Removed tables, restoring DB"
53+
ahoy dkan sqlc < backups/last_install.sql
54+
5055
echo "Installed dkan from backup"
5156
else
5257
if [ "$AHOY_CMD_PROXY" == "DOCKER" ]; then
@@ -193,15 +198,13 @@ commands:
193198
import: dkan/.ahoy/theme.ahoy.yml
194199
hide: true
195200

201+
# Moved to .ahoy.yml
196202
uli:
197-
usage: log into the
203+
usage: Log in via drush
198204
cmd: |
199-
uli=$(ahoy drush uli {{args}} | sed 's/^http.*\/default\/\(.*$\)/\1/g')
200-
url="$(ahoy docker url)/$uli"
201-
os=$(uname)
205+
ruby dkan/.ahoy/.scripts/dkan-uli.rb {{args}}
202206
203-
if [ "$os" = "Darwin" ]; then
204-
open $url
205-
else
206-
echo $url
207-
fi
207+
server:
208+
usage: Provided as an easy way to setup the php server during testing.
209+
cmd:
210+
ahoy cmd-proxy bash dkan/.ahoy/.scripts/server.sh

profiles/dkan/.ahoy/docker-compose.yml

+16-3
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,17 @@
55
web:
66
hostname: web
77
image: nuams/drupal-apache-php:1.0-5.6
8+
# Fix for docker for mac container not starting selenium
9+
# https://forums.docker.com/t/space-in-new-no-proxy-env-var-breaking-old-containers/14075
10+
811
environment:
912
- VIRTUAL_HOST=dkan.docker
13+
- no_proxy=localhost
1014
#- VIRTUAL_PROTO=https
1115
ports:
1216
- "80"
1317
- "443"
18+
- "8888"
1419
volumes:
1520
# PHP configuration overrides
1621
- "./.docker/etc/php5/php.ini:/etc/php5/fpm/conf.d/z_php.ini"
@@ -49,6 +54,7 @@ cli:
4954
environment:
5055
- XDEBUG_CONFIG=idekey=cli
5156
- PHP_IDE_CONFIG=serverName=dkan.docker
57+
- VIRTUAL_HOST=dkan.docker
5258
volumes:
5359
# PHP configuration overrides
5460
- "./.docker/etc/php5/php-cli.ini:/etc/php5/cli/conf.d/z_php.ini"
@@ -64,6 +70,8 @@ cli:
6470
- browser
6571
- memcached
6672
- solr
73+
ports:
74+
- "8888"
6775

6876
# Memcached node
6977
# Uncomment the service definition section below and the link in the web service above to start using memcached.
@@ -96,16 +104,21 @@ browser:
96104
- /dev/shm:/dev/shm
97105
# Project root folder mapping
98106
- *project_root
107+
99108
links:
100109
- web
101110
ports:
102-
# - "4444:4444"
103111
- "5900"
104112

113+
# Fix for docker for mac container not starting selenium
114+
# https://forums.docker.com/t/space-in-new-no-proxy-env-var-breaking-old-containers/14075
115+
environment:
116+
- no_proxy=localhost
117+
105118
solr:
106119
hostname: solr
107120
image: devinci/drupal-solr:3.x
108-
#ports:
109-
# - "8983:8983"
121+
ports:
122+
- "8983"
110123
volumes:
111124
- "./.docker/etc/solr/3.x:/var/lib/solr/conf"

profiles/dkan/.ahoy/docker.ahoy.yml

+92-14
Original file line numberDiff line numberDiff line change
@@ -5,39 +5,98 @@ commands:
55
cmd: |
66
cat << EOF
77
# To initialize your environment to use docker.
8-
# Run: eval \$(ahoy docker env)
8+
# Run: eval "\$(ahoy docker env)"
99
# OR
1010
# Add the following to your ~/.bashrc
1111
which docker || (echo "you don't seem to have docker installed. Exiting."; exit 1)
12-
which docker-machine || (echo "you don't seem to have docker-machine installed. Exiting."; exit 1)
1312
which docker-compose || (echo "you don't seem to have docker-compose installed. Exiting."; exit 1)
1413
echo "Setting up docker environment"
1514
export AHOY_CMD_PROXY=DOCKER
16-
docker-machine start default
17-
$(docker-machine env default)
15+
which docker-machine || (echo "you don't seem to have docker-machine installed. Exiting."; exit 1)
16+
if [ ! -z "$DOCKER_MACHINE_NAME" ]; then
17+
docker-machine start default
18+
$(docker-machine env default)
19+
fi
20+
1821
ahoy docker up
1922
EOF
2023
usage: Outputs the commands needed to setup a docker environment.
24+
hostfile:
25+
cmd: |
26+
ip_address="127.0.0.1"
27+
host_name="dkan.docker"
28+
# find existing instances in the host file and save the line numbers
29+
matches_in_hosts="$(grep -n $host_name /etc/hosts | cut -f1 -d:)"
30+
host_entry="${ip_address} ${host_name}"
31+
32+
if [ -z "$matches_in_hosts" ];then
33+
echo "Adding new hosts entry."
34+
echo "$host_entry" | sudo tee -a /etc/hosts > /dev/null
35+
fi
2136
up:
22-
cmd: "ahoy docker compose up -d {{args}}"
37+
cmd: |
38+
if [ -z $AHOY_CMD_PROXY ]; then
39+
echo "AHOY_CMD_PROXY is not set. Run 'ahoy docker env' and follow instructions."
40+
exit 0
41+
fi
42+
ahoy docker compose up -d {{args}}
43+
ahoy docker proxy-up
44+
ahoy docker hostfile
2345
usage: Start the docker-compose containers.
2446
proxy-up:
25-
cmd: "docker run -d -p 80:80 -v /var/run/docker.sock:/tmp/docker.sock:ro jwilder/nginx-proxy"
47+
cmd: |
48+
proxy_image=jwilder/nginx-proxy
49+
# Check if the proxy container is running.
50+
if [ ! "$(docker ps -f name=dkan_proxy -f ancestor=$proxy_image -q)" ];then
51+
# Check if the proxy container stopped.
52+
if [ "$(docker ps -f name=dkan_proxy -f ancestor=$proxy_image -qa)" ];then
53+
echo "Restarting dkan_proxy container"
54+
docker start dkan_proxy
55+
else
56+
echo "Starting dkan_proxy container"
57+
docker run -d --privileged \
58+
-p 80:80 -p 443:443 -p 5959:5900 \
59+
-v /var/run/docker.sock:/tmp/docker.sock:ro \
60+
--name=dkan_proxy jwilder/nginx-proxy
61+
fi
62+
fi
2663
usage: Run the nginx-proxy container
2764
stop:
28-
cmd: "ahoy docker compose stop"
65+
cmd: |
66+
ahoy docker compose stop
67+
proxy_image=jwilder/nginx-proxy
68+
if [ ! -z "$(docker ps -f name=dkan_proxy -f ancestor=$proxy_image -q)" ];then
69+
echo "Stopping dkan_proxy container"
70+
docker stop dkan_proxy
71+
fi
2972
usage: Stop the docker-compose containers (non-destructive).
3073
ps:
3174
cmd: "ahoy docker compose ps"
3275
usage: List the running docker-compose containers.
76+
77+
# Alias for web-ip.
3378
ip:
34-
cmd: "docker-machine ip default"
35-
usage: Show the ip address f the default docker machine VM
79+
cmd: |
80+
if [ -z "$DOCKER_MACHINE_NAME" ]; then
81+
ahoy docker web-ip
82+
else
83+
docker-machine ip default
84+
fi
85+
86+
usage: Show the ip address of the web container
3687
reset:
37-
cmd: "ahoy docker compose stop && ahoy docker compose rm && ahoy docker compose up -d"
88+
cmd: |
89+
ahoy docker destroy
90+
ahoy docker up
3891
usage: Destroy and then restart the docker compose containers.
3992
destroy:
40-
cmd: "ahoy docker compose stop && ahoy docker compose rm"
93+
cmd: |
94+
ahoy docker stop
95+
ahoy docker compose rm
96+
proxy_image=jwilder/nginx-proxy
97+
if [ ! -z "$(docker ps -f name=dkan_proxy -f ancestor=$proxy_image -all -q)" ];then
98+
docker rm dkan_proxy
99+
fi
41100
usage: Destroy all the docker compose containers. (use before deleting folder)
42101
exec:
43102
cmd: |
@@ -82,18 +141,37 @@ commands:
82141
compose:
83142
cmd: docker-compose -f dkan/.ahoy/docker-compose.yml -p "${PWD##*/}" {{args}}
84143
usage: Abstraction for docker-compose
144+
web-host:
145+
cmd: |
146+
echo `ahoy docker exec web printenv VIRTUAL_HOST | tr -d '\r'`
147+
web-ip:
148+
usage: Prints the web container IP address
149+
cmd: |
150+
echo `docker inspect --format '{{ .NetworkSettings.IPAddress }}' $(ahoy docker compose ps -q web)`
85151
url:
86152
usage: Prints the project URL
87153
cmd: |
88-
echo "http://`docker-machine ip default`:`ahoy docker compose port web 80|cut -d ':' -f2`"
154+
if [ -z "$DOCKER_MACHINE_NAME" ]; then
155+
echo "http://`ahoy docker web-host`"
156+
else
157+
echo "http://`docker-machine ip default`:`ahoy docker compose port web 80|cut -d ':' -f2`"
158+
fi
89159
surl:
90160
usage: Prints a secure project URL
91161
cmd: |
92-
echo "https://`docker-machine ip default`:`ahoy docker compose port web 443|cut -d ':' -f2`"
162+
if [ -z "$DOCKER_MACHINE_NAME" ]; then
163+
echo "https://`ahoy docker web-host`:`ahoy docker compose port web 443|cut -d ':' -f2`"
164+
else
165+
echo "https://`docker-machine ip default`:`ahoy docker compose port web 443|cut -d ':' -f2`"
166+
fi
93167
vnc:
94168
usage: Prints the project VNC URL
95169
cmd: |
96-
echo "`docker-machine ip default`:`ahoy docker compose port browser 5900|cut -d ':' -f2`"
170+
if [ -z "$DOCKER_MACHINE_NAME" ]; then
171+
echo "https://`ahoy docker web-host`:`ahoy docker compose port browser 5900|cut -d ':' -f2`"
172+
else
173+
echo "`docker-machine ip default`:`ahoy docker compose port browser 5900|cut -d ':' -f2`"
174+
fi
97175
98176
cleanup:
99177
usage: Clean ups docker unused images and volumes. See http://blog.yohanliyanage.com/2015/05/docker-clean-up-after-yourself/.

profiles/dkan/.ahoy/tests/behat-parse-params.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "minitest/autorun"
2-
require "./.scripts/behat-parse-params.rb"
2+
require "./dkan/.ahoy/.scripts/behat-parse-params.rb"
33

44
class TestBehatParseParams < MiniTest::Unit::TestCase
55

0 commit comments

Comments
 (0)