Skip to content

Commit 9e4943e

Browse files
committed
Improve setup scripts all around
1 parent 8a3f251 commit 9e4943e

6 files changed

+74
-41
lines changed

README.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@ Note that the <code>scripts/bootstrap.sh</code> script calls these for
4040
you. But if something goes wrong / you want to know more:
4141

4242
* <code>scripts/bootstrap_server_ubuntu.sh</code>: Will configure an
43-
Ubuntu 12 server (install packages and enable apache modules, etc).
44-
45-
* <code>scripts/bootstrap_mysql.sh</code>: Creates a database and user
46-
with specified password. Use these values in your
47-
<code>wp-config-local.php</code> file (see below).
43+
Ubuntu 12 server (install packages, set up apache, set up
44+
mysql). Should be run as root.
4845

4946
* <code>scripts/bootstrap_checkout.sh</code>: Sets up this checkout by
5047
downloading git submodules, creating a virtual Python environment,
51-
etc.
48+
etc. Should be run as this user (does not touch system files).
5249

5350
Happy hacking!

required_packages.txt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
apache2
2+
python-virtualenv
3+
python-pip
4+
gcc
5+
python-dev
6+
libxml2
7+
libxml2-dev
8+
libxslt1.1
9+
libxslt-dev
10+
php5
11+
php5-mysql
12+
python-librdf
13+
libapache2-mod-fcgid
14+
libapache2-mod-macro
15+
mysql-server
16+
mysql-client

scripts/bootstrap.sh

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
3+
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
24

35
function usage {
4-
echo "Usage: $0 <hostname> <db> <dbuser>"
6+
echo "Usage: $0 <hostname>
57
exit 1
68
}
9+
[ -z "$1" ] && usage;
710
8-
[ -z "$3" ] && usage;
9-
10-
HOSTNAME=${1}
11-
DB=${2}
12-
DBUSER=${3}
13-
14-
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}/.." )" && pwd )"
15-
16-
sudo ${TOPDIR}/scripts/bootstrap_server_ubuntu.sh
17-
${TOPDIR}/scripts/bootstrap_mysql.sh "${DB}" "${DBUSER}"
11+
sudo ${TOPDIR}/scripts/bootstrap_server_ubuntu.sh ${1}
1812
${TOPDIR}/scripts/bootstrap_checkout.sh

scripts/bootstrap_checkout.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
#!/bin/bash
22

33
CUR=`pwd`
4-
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}/.." )" && pwd )"
4+
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
5+
6+
echo ${TOPDIR}
7+
exit
58

69
cd ${TOPDIR}
710

scripts/bootstrap_mysql.sh

-15
This file was deleted.

scripts/bootstrap_server_ubuntu.sh

+45-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,30 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
3+
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )"
24

35
HOSTNAME=${1:-creativecommons.org}
4-
TOPDIR="$( cd "$( dirname "${BASH_SOURCE[0]}/.." )" && pwd )"
6+
DBNAME=${2:-wordpress}
7+
DBUSER=${3:-dbuser}
8+
DBPASS=${4:-}
59

6-
apt-get -y install apache2 python-virtualenv python-pip gcc python-dev libxml2 libxml2-dev libxslt1.1 libxslt-dev php5 php5-mysql python-librdf libapache2-mod-fcgid libapache-mod-macro mysql-server mysql-client
10+
#
11+
# Install base system dependencies
12+
#
713

8-
for i in macro php5 rewrite ssl fcgid
9-
do
10-
a2enmod $i
11-
done
14+
apt-get update
15+
if apt-get -y install `cat ${TOPDIR}/required_packages.txt`
16+
then
17+
echo "Required packages installed, proceeding with setup."
18+
else
19+
echo "Could not install required packages, aborting setup."
20+
exit 1
21+
fi
22+
23+
#
24+
# Configure Apache:
25+
#
26+
27+
# 1. Copy config files into place
1228

1329
if grep -q "apache.conf" /etc/apache2/httpd.conf
1430
then
@@ -33,10 +49,32 @@ cat <<EOF > /etc/apache2/sites-available/${HOSTNAME}
3349
</VirtualHost>
3450
EOF
3551

52+
# 2. Create logging directory
53+
3654
mkdir /var/log/apache2/${HOSTNAME}
3755
chown root.adm /var/log/apache2/${HOSTNAME}
3856
chmod 750 /var/log/apache2/${HOSTNAME}
3957

58+
# 3. Enable mods and site
59+
60+
for i in macro php5 rewrite ssl fcgid
61+
do
62+
a2enmod $i
63+
done
64+
4065
a2ensite ${HOSTNAME}
4166

67+
# 4. Restart Apache
68+
4269
service apache2 restart
70+
71+
#
72+
# Create a MySQL DB for WordPress
73+
#
74+
75+
echo "Enter the MySQL root password:"
76+
mysql -u root -p mysql <<EOF
77+
CREATE DATABASE ${DBNAME};
78+
CREATE USER '${DBUSER}'@'localhost' IDENTIFIED BY '${DBPASS}';
79+
GRANT ALL PRIVILEGES ON *.* TO '${DBUSER}'@'localhost' WITH GRANT OPTION;
80+
EOF

0 commit comments

Comments
 (0)