Skip to content
This repository was archived by the owner on Mar 4, 2019. It is now read-only.

Commit 4355587

Browse files
committed
Docker containers override /etc/hosts, so try to keep it always up to date.
1 parent 0f5d321 commit 4355587

File tree

10 files changed

+38
-20
lines changed

10 files changed

+38
-20
lines changed

dev/clone.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ rm -rf $dst_dir
2828
cp -a $src_dir $dst_dir
2929

3030
### modify settings.php
31-
domain=$(grep ' localhost' /etc/hosts | head -n 1 | cut -d' ' -f2)
31+
domain=$(head -n 1 /etc/hosts.conf | cut -d' ' -f2)
3232
sub=${dst#*_}
3333
hostname=$sub.$domain
3434
sed -i $dst_dir/sites/default/settings.php \
@@ -37,8 +37,9 @@ sed -i $dst_dir/sites/default/settings.php \
3737
-e "/^\\\$conf\['memcache_key_prefix'\]/c \$conf['memcache_key_prefix'] = '$dst';"
3838

3939
### add to /etc/hosts
40-
sed -i /etc/hosts -e "/^127.0.0.1 $hostname/d"
41-
echo "127.0.0.1 $hostname" >> /etc/hosts
40+
sed -i /etc/hosts.conf -e "/^127.0.0.1 $hostname/d"
41+
echo "127.0.0.1 $hostname" >> /etc/hosts.conf
42+
/etc/hosts_update.sh
4243

4344
### create a drush alias
4445
sed -i /etc/drush/local_bcl.aliases.drushrc.php \

dev/clone_rm.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ rm -f /etc/nginx/sites-{available,enabled}/$target
3030
rm -f /etc/apache2/sites-{available,enabled}/$target{,-ssl}.conf
3131

3232
### remove from /etc/hosts
33-
domain=$(grep ' localhost' /etc/hosts | head -n 1 | cut -d' ' -f2)
33+
domain=$(head -n 1 /etc/hosts.conf | cut -d' ' -f2)
3434
sub=${target#*_}
3535
hostname=$sub.$domain
3636
sed -i /etc/hosts -e "/^127.0.0.1 $hostname/d"
37+
sed -i /etc/hosts.conf -e "/^127.0.0.1 $hostname/d"
3738

3839
### restart services
3940
#for service in php5-fpm memcached mysql nginx

install/config/domain.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ then
2222
fi
2323

2424
echo $domain > /etc/hostname
25-
sed -i /etc/hosts \
26-
-e "/ localhost/c 127.0.0.1 $domain localhost"
25+
sed -i /etc/hosts.conf \
26+
-e "1c 127.0.0.1 $domain"
27+
/etc/hosts_update.sh
2728

2829
### change config files
2930
for file in $(ls /etc/nginx/sites-available/bcl*)

install/install-and-config.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
#!/bin/bash -x
22

3-
### set a temporary hostname
4-
sed -i /etc/hosts \
5-
-e "/^127.0.0.1/c 127.0.0.1 example.org localhost"
6-
hostname example.org
7-
83
### go to the directory of scripts
94
cd $code_dir/install/scripts/
105

install/overlay/etc/hosts

Lines changed: 0 additions & 9 deletions
This file was deleted.

install/overlay/etc/hosts.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
127.0.0.1 example.org
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
### Update /etc/hosts with the entries in /etc/hosts.conf
3+
4+
sed -i /etc/hosts -e '/^### update/,$ d'
5+
echo '### update' >> /etc/hosts
6+
cat /etc/hosts.conf >> /etc/hosts

install/overlay/etc/rc_local.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
### This script runs on the start of the system, like rc.local
3+
4+
### update /etc/hosts with the content of /etc/hosts.conf
5+
/etc/hosts_update.sh
6+
7+
exit 0
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[program:onstart]
2+
3+
command=/etc/rc_local.sh
4+
5+
stdout_logfile=/var/log/supervisor/%(program_name)s.log
6+
stderr_logfile=/var/log/supervisor/%(program_name)s.log
7+
8+
autorestart=false
9+
startretries=0
10+
startsecs=0
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[program:rsyslog]
2+
command=rsyslogd -n
3+
stdout_logfile=/var/log/supervisor/%(program_name)s.log
4+
stderr_logfile=/var/log/supervisor/%(program_name)s.log
5+
autorestart=true

0 commit comments

Comments
 (0)