-
Notifications
You must be signed in to change notification settings - Fork 14
/
gce_ubuntu.sh
55 lines (50 loc) · 2.57 KB
/
gce_ubuntu.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#! /bin/bash
# prompt for archiving bucket and key if available
echo 'WebPageTest server install script for servers running on Google Compute Engine.'
printf "\n"
echo 'If tests are to be archived to Google cloud storage you will need a developer key and a bucket configured in cloud storage.'
echo 'To generate a developer key:'
echo ' 1. Open the Cloud Storage Settings page in the Google Cloud Platform Console:'
echo ' https://console.cloud.google.com/storage/settings?_ga=2.247736327.-1841576041.1479520090'
echo ' 2. Select Interoperability.'
echo ' 3. If you have not set up interoperability before, click Enable interoperability access.'
echo ' 4. Click Create a new key.'
printf "\n"
read -p "Bucket name (leave empty if not using cloud storage): " STORAGE_BUCKET
if [ $STORAGE_BUCKET != '' ]; then
while [[ $STORAGE_KEY == '' ]]
do
read -p "Developer Key: " STORAGE_KEY
done
while [[ $STORAGE_SECRET == '' ]]
do
read -p "Developer Secret: " STORAGE_SECRET
done
fi
printf "\nStarting installation"
sudo date
# First run the common ubuntu installer
cd ~
wget https://raw.githubusercontent.com/WPO-Foundation/wptserver-install/master/ubuntu.sh
chmod +x ubuntu.sh
. ./ubuntu.sh
if [ $STORAGE_BUCKET != '' ]; then
echo "archive_days=1" >> /var/www/webpagetest/www/settings/settings.ini
echo "archive_api=1" >> /var/www/webpagetest/www/settings/settings.ini
echo "archive_s3_server=commondatastorage.googleapis.com" >> /var/www/webpagetest/www/settings/settings.ini
echo "archive_s3_key=$STORAGE_KEY" >> /var/www/webpagetest/www/settings/settings.ini
echo "archive_s3_secret=$STORAGE_SECRET" >> /var/www/webpagetest/www/settings/settings.ini
echo "archive_s3_bucket=$STORAGE_BUCKET" >> /var/www/webpagetest/www/settings/settings.ini
fi
cp /var/www/webpagetest/www/settings/locations.ini.GCE-sample /var/www/webpagetest/www/settings/locations.ini
INTERNAL_HOSTNAME=$(curl "http://metadata.google.internal/computeMetadata/v1/instance/hostname" -H "Metadata-Flavor: Google")
clear
echo 'Setup is complete. System reboot is recommended.'
echo 'Locations have been configured for all of the GCE regions in /var/www/webpagetest/www/settings/locations.ini'
echo 'The settings can be tweaked if needed in /var/www/webpagetest/www/settings/settings.ini'
printf "\n"
echo "The location key to use when configuring agents is: $LOCATIONKEY"
echo "The 'wpt_data' metadata for agents to connect to this server is:"
echo " wpt_server=$INTERNAL_HOSTNAME wpt_key=$LOCATIONKEY"
printf "\n"
echo "An API key to use for automated testing is: $APIKEY"