Memcached no longer autostarts on install on ubuntu - wtf...
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 10_before_install.bash
1 #!/bin/bash
2
3 source maint/travis-ci_scripts/common.bash
4 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
5
6 # Different boxes we run on may have different amount of hw threads
7 # Hence why we need to query
8 # Originally we used to read /sys/devices/system/cpu/online
9 # but it is not available these days (odd). Thus we fall to
10 # the alwas-present /proc/cpuinfo
11 # The oneliner is a tad convoluted - basicaly what we do is
12 # slurp the entire file and get the index off the last
13 # `processor    : XX` line
14 export NUMTHREADS=$(( $(perl -0777 -n -e 'print (/ (?: .+ ^ processor \s+ : \s+ (\d+) ) (?! ^ processor ) /smx)' < /proc/cpuinfo) + 1 ))
15
16 run_or_err "Installing common tools from APT" "sudo apt-get install --allow-unauthenticated -y libapp-nopaste-perl tree"
17 # FIXME - the debian package is oddly broken - uses a bin/env based shebang
18 # so nothing works under a brew. Fix here until #debian-perl patches it up
19 sudo /usr/bin/perl -p -i -e 's|#!/usr/bin/env perl|#!/usr/bin/perl|' $(which nopaste)
20
21 if [[ "$CLEANTEST" != "true" ]]; then
22 ### apt-get invocation - faster to grab everything at once
23   #
24   # FIXME these debconf lines should automate the firebird config but do not :(((
25   sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/enabled\tboolean\ttrue" | debconf-set-selections'
26   sudo bash -c 'echo -e "firebird2.5-super\tshared/firebird/sysdba_password/new_password\tpassword\t123" | debconf-set-selections'
27
28   APT_PACKAGES="memcached firebird2.5-super firebird2.5-dev expect"
29   run_or_err "Installing packages ($APT_PACKAGES)" "sudo apt-get install --allow-unauthenticated -y $APT_PACKAGES"
30
31 ### config memcached
32   run_or_err "Starting memcached" "sudo /etc/init.d/memcached start"
33   export DBICTEST_MEMCACHED=127.0.0.1:11211
34
35 ### config mysql
36   run_or_err "Creating MySQL TestDB" "mysql -e 'create database dbic_test;'"
37   export DBICTEST_MYSQL_DSN='dbi:mysql:database=dbic_test;host=127.0.0.1'
38   export DBICTEST_MYSQL_USER=root
39
40 ### config pg
41   run_or_err "Creating PostgreSQL TestDB" "psql -c 'create database dbic_test;' -U postgres"
42   export DBICTEST_PG_DSN='dbi:Pg:database=dbic_test;host=127.0.0.1'
43   export DBICTEST_PG_USER=postgres
44
45 ### conig firebird
46   # poor man's deb config
47   EXPECT_FB_SCRIPT='
48     spawn dpkg-reconfigure --frontend=text firebird2.5-super
49     expect "Enable Firebird server?"
50     send "\177\177\177\177yes\r"
51     expect "Password for SYSDBA"
52     send "123\r"
53     sleep 1
54     wait
55     sleep 1
56   '
57   # creating testdb
58   # FIXME - this step still fails from time to time >:(((
59   # has to do with the FB reconfiguration I suppose
60   # for now if it fails twice - simply skip FB testing
61   for i in 1 2 ; do
62
63     run_or_err "Re-configuring Firebird" "
64       sync
65       DEBIAN_FRONTEND=text sudo expect -c '$EXPECT_FB_SCRIPT'
66       sleep 1
67       sync
68       # restart the server for good measure
69       sudo /etc/init.d/firebird2.5-super stop || true
70       sleep 1
71       sync
72       sudo /etc/init.d/firebird2.5-super start
73       sleep 1
74       sync
75     "
76
77     if run_or_err "Creating Firebird TestDB" \
78       "echo \"CREATE DATABASE '/var/lib/firebird/2.5/data/dbic_test.fdb';\" | sudo isql-fb -u sysdba -p 123"
79     then
80       export DBICTEST_FIREBIRD_DSN=dbi:Firebird:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
81       export DBICTEST_FIREBIRD_USER=SYSDBA
82       export DBICTEST_FIREBIRD_PASS=123
83
84       export DBICTEST_FIREBIRD_INTERBASE_DSN=dbi:InterBase:dbname=/var/lib/firebird/2.5/data/dbic_test.fdb
85       export DBICTEST_FIREBIRD_INTERBASE_USER=SYSDBA
86       export DBICTEST_FIREBIRD_INTERBASE_PASS=123
87
88       break
89     fi
90
91   done
92
93 ### oracle
94   # FIXME: todo
95   #DBICTEST_ORA_DSN=dbi:Oracle:host=localhost;sid=XE
96   #DBICTEST_ORA_USER=dbic_test
97   #DBICTEST_ORA_PASS=123
98   #DBICTEST_ORA_EXTRAUSER_DSN=dbi:Oracle:host=localhost;sid=XE
99   #DBICTEST_ORA_EXTRAUSER_USER=dbic_test_extra
100   #DBICTEST_ORA_EXTRAUSER_PASS=123
101   #ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/client
102 fi