install.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #!/bin/bash
  2. #
  3. # ownCloud
  4. #
  5. # @author Thomas Müller
  6. # @copyright 2014 Thomas Müller thomas.mueller@tmit.eu
  7. #
  8. set -e
  9. DATABASENAME=oc_autotest
  10. DATABASEUSER=oc_autotest
  11. ADMINLOGIN=admin
  12. BASEDIR=$PWD
  13. DBCONFIGS="sqlite mysql pgsql oracle"
  14. PHPUNIT=$(which phpunit)
  15. # set oracle home if it is not set
  16. TRAVIS_ORACLE_HOME="/usr/lib/oracle/xe/app/oracle/product/10.2.0/server"
  17. [ -z "$ORACLE_HOME" ] && ORACLE_HOME=$TRAVIS_ORACLE_HOME
  18. if [ $1 ]; then
  19. FOUND=0
  20. for DBCONFIG in $DBCONFIGS; do
  21. if [ $1 = $DBCONFIG ]; then
  22. FOUND=1
  23. break
  24. fi
  25. done
  26. if [ $FOUND = 0 ]; then
  27. echo -e "Unknown database config name \"$1\"\n" >&2
  28. print_syntax
  29. exit 2
  30. fi
  31. fi
  32. # use tmpfs for datadir - should speedup unit test execution
  33. DATADIR=$BASEDIR/data-autotest
  34. echo "Using database $DATABASENAME"
  35. # create autoconfig for sqlite, mysql and postgresql
  36. cat > ./tests/autoconfig-sqlite.php <<DELIM
  37. <?php
  38. \$AUTOCONFIG = array (
  39. 'installed' => false,
  40. 'dbtype' => 'sqlite',
  41. 'dbtableprefix' => 'oc_',
  42. 'adminlogin' => '$ADMINLOGIN',
  43. 'adminpass' => 'admin',
  44. 'directory' => '$DATADIR',
  45. );
  46. DELIM
  47. cat > ./tests/autoconfig-mysql.php <<DELIM
  48. <?php
  49. \$AUTOCONFIG = array (
  50. 'installed' => false,
  51. 'dbtype' => 'mysql',
  52. 'dbtableprefix' => 'oc_',
  53. 'adminlogin' => '$ADMINLOGIN',
  54. 'adminpass' => 'admin',
  55. 'directory' => '$DATADIR',
  56. 'dbuser' => '$DATABASEUSER',
  57. 'dbname' => '$DATABASENAME',
  58. 'dbhost' => 'localhost',
  59. 'dbpass' => 'owncloud',
  60. );
  61. DELIM
  62. cat > ./tests/autoconfig-pgsql.php <<DELIM
  63. <?php
  64. \$AUTOCONFIG = array (
  65. 'installed' => false,
  66. 'dbtype' => 'pgsql',
  67. 'dbtableprefix' => 'oc_',
  68. 'adminlogin' => '$ADMINLOGIN',
  69. 'adminpass' => 'admin',
  70. 'directory' => '$DATADIR',
  71. 'dbuser' => '$DATABASEUSER',
  72. 'dbname' => '$DATABASENAME',
  73. 'dbhost' => 'localhost',
  74. 'dbpass' => '',
  75. );
  76. DELIM
  77. cat > ./tests/autoconfig-oracle.php <<DELIM
  78. <?php
  79. \$AUTOCONFIG = array (
  80. 'installed' => false,
  81. 'dbtype' => 'oci',
  82. 'dbtableprefix' => 'oc_',
  83. 'adminlogin' => '$ADMINLOGIN',
  84. 'adminpass' => 'admin',
  85. 'directory' => '$DATADIR',
  86. 'dbuser' => '$DATABASENAME',
  87. 'dbname' => 'XE',
  88. 'dbhost' => 'localhost',
  89. 'dbpass' => 'owncloud',
  90. 'loglevel' => 0,
  91. );
  92. DELIM
  93. function execute_tests {
  94. echo "Setup environment for $1 testing ..."
  95. # back to root folder
  96. cd $BASEDIR
  97. # revert changes to tests/data
  98. git checkout tests/data/*
  99. # reset data directory
  100. rm -rf $DATADIR
  101. mkdir $DATADIR
  102. cp tests/preseed-config.php config/config.php
  103. if [ "$1" == "oracle" ] ; then
  104. echo "Load Oracle environment variables so that we can run 'sqlplus'."
  105. . $ORACLE_HOME/bin/oracle_env.sh
  106. echo "create the database"
  107. sqlplus -s -l / as sysdba <<EOF
  108. create user $DATABASENAME identified by owncloud;
  109. alter user $DATABASENAME default tablespace users
  110. temporary tablespace temp
  111. quota unlimited on users;
  112. grant create session
  113. , create table
  114. , create procedure
  115. , create sequence
  116. , create trigger
  117. , create view
  118. , create synonym
  119. , alter session
  120. to $DATABASENAME;
  121. exit;
  122. EOF
  123. fi
  124. # copy autoconfig
  125. cp $BASEDIR/tests/autoconfig-$1.php $BASEDIR/config/autoconfig.php
  126. # trigger installation
  127. echo "INDEX"
  128. php -f index.php
  129. echo "END INDEX"
  130. #test execution
  131. cd tests
  132. #php -f enable_all.php
  133. }
  134. #
  135. # start test execution
  136. #
  137. if [ -z "$1" ]
  138. then
  139. # run all known database configs
  140. for DBCONFIG in $DBCONFIGS; do
  141. execute_tests $DBCONFIG
  142. done
  143. else
  144. execute_tests $1 $2 $3
  145. fi
  146. # show environment
  147. echo "owncloud configuration:"
  148. cat $BASEDIR/config/config.php
  149. echo "data directory:"
  150. ls -ll $DATADIR
  151. echo "nextcloud.log:"
  152. [ -f "$DATADIR/nextcloud.log" ] && cat $DATADIR/nextcloud.log
  153. [ -f "$BASEDIR/data/nextcloud.log" ] && cat $BASEDIR/data/nextcloud.log
  154. cd $BASEDIR