setup.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #!/bin/bash
  2. fw_depends mysql postgresql
  3. cp config.js.tpl config.js
  4. fw_depends cppcms cppcms-cppdb
  5. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${CPPCMS_HOME}/lib:${CPPDB_HOME}/lib
  6. make
  7. #Database
  8. #http://cppcms.com/sql/cppdb/connstr.html
  9. #http://cppcms.com/sql/cppdb/backendref.html
  10. if [ "${DRIVER}" == "mysql" ]; then
  11. dbstring="mysql:host="$DBHOST";database=hello_world;user=benchmarkdbuser;password=benchmarkdbpass;set_charset_name=utf8;@pool_size=10"
  12. else
  13. dbstring="postgresql:host="$DBHOST";dbname=hello_world;user=benchmarkdbuser;password=benchmarkdbpass;@pool_size=10"
  14. fi
  15. sed -i 's|\(.*\)--db--\(.*\)|\1'"$dbstring"'\2|g' config.js
  16. #http://cppcms.com/wikipp/en/page/cppcms_1x_tut_web_server_config#Nginx
  17. #configure Nginx
  18. if [ -n "${NGINX}" ]; then
  19. fw_depends nginx
  20. nginx -c ${TROOT}/nginx.conf
  21. sed -i 's|\(.*\)--api--\(.*\)|\1'"fastcgi"'\2|g' config.js
  22. sed -i 's|\(.*\)--address--\(.*\)|\1"socket" : "/var/tmp/cppcms.sock"\2|g' config.js
  23. #for ip based connection
  24. #sed -i 's|\(.*\)--address--\(.*\)|\1"ip": "127.0.0.1" , "port" : 8081\2|g' config.js
  25. else
  26. sed -i 's|\(.*\)--api--\(.*\)|\1'"http"'\2|g' config.js
  27. sed -i 's|\(.*\)--address--\(.*\)|\1"ip": "0.0.0.0", "port": 8080\2|g' config.js
  28. fi
  29. ./mycppcms -c config.js