deploy 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. #!/bin/bash
  2. # This deploy hook gets executed after dependencies are resolved and the
  3. # build hook has been run but before the application has been started back
  4. # up again. This script gets executed directly, so it could be python, php,
  5. # ruby, etc.
  6. # Bash help: http://www.panix.com/~elflord/unix/bash-tute.html
  7. # For information about action hooks supported by OpenShift, consult the documentation:
  8. # http://openshift.github.io/documentation/oo_user_guide.html#the-openshift-directory
  9. ####
  10. # Hubzilla specific deploy script
  11. # Place this file in /.openshift/action_hooks/ (The .openshift folder will be in the root of your repo)
  12. # The file name should be "deploy" such that you have:
  13. # .openshift/action_hooks/deploy
  14. # Conventions: Vars in curley braces have the slash after implied so no need to add it.
  15. # e.g. ${OPENSHIFT_REPO_DIR}php/foobar = /repo/php/foobar
  16. # See all OpenShift vars here:
  17. # https://www.openshift.com/developers/openshift-environment-variables
  18. # HME - NOTE - leftover from original openshift-drupal-deploy
  19. # In config.php you can leverage the enviroment variables like this:
  20. # // Define env vars.
  21. # if (array_key_exists('OPENSHIFT_APP_NAME', $_SERVER)) {
  22. # $src = $_SERVER;
  23. # } else {
  24. # $src = $_ENV;
  25. # }
  26. #
  27. # $conf["file_private_path"] = $src['OPENSHIFT_DATA_DIR'] . "private";
  28. # $conf["file_temporary_path"] = $src['OPENSHIFT_DATA_DIR'] . "tmp";
  29. ####
  30. # Start Deploy
  31. echo "Starting Deploy..."
  32. # Let's create the Hubzilla files directory in the Openshift data folder ($OPENSHIFT_DATA_DIR).
  33. echo "Check for the files directory called store, if not created - create it"
  34. if [ ! -d ${OPENSHIFT_DATA_DIR}store ]; then
  35. mkdir -p ${OPENSHIFT_DATA_DIR}"store/[data]/smarty3"
  36. echo "Done creating files directory"
  37. else
  38. echo "The files directory called store already exists"
  39. fi
  40. ####
  41. # Set permissions on the files directory.
  42. echo "Now chmod 777 -R files"
  43. chmod -R 777 ${OPENSHIFT_DATA_DIR}store
  44. echo "chmod done, permissions set to 777"
  45. ####
  46. # Symlink our files folder to the repo.
  47. # Note the "php" directory below seems to be the best way to serve OpenShift files.
  48. # This is good as that allows us for directories one level above such as tmp and private
  49. echo "Create sym links for writeable directories"
  50. ln -sf ${OPENSHIFT_DATA_DIR}store ${OPENSHIFT_REPO_DIR}store
  51. echo "Files sym links created"
  52. ####
  53. # Copy .htconfig.php from the repo, rename it and place it in the data directory.
  54. # if it's there already, skip it.
  55. if [ ! -f ${OPENSHIFT_DATA_DIR}.htconfig.php ];
  56. then
  57. cp ${OPENSHIFT_REPO_DIR}.htconfig.php ${OPENSHIFT_DATA_DIR}.htconfig.php
  58. echo ".htconfig.php copied."
  59. else
  60. echo "Looks like the .htconfig.php file is already there, we won't overwrite it."
  61. fi
  62. ####
  63. # symlink the .htconfig.php file.
  64. echo "Create sym link for .htconfig.php"
  65. ln -sf ${OPENSHIFT_DATA_DIR}.htconfig.php ${OPENSHIFT_REPO_DIR}.htconfig.php
  66. echo ".htconfig.php symlink created"
  67. ####
  68. # Copy .htaccess from the repo, rename it and place it in the data directory.
  69. # if it's there already, skip it.
  70. if [ ! -f ${OPENSHIFT_DATA_DIR}.htaccess ];
  71. then
  72. cp ${OPENSHIFT_REPO_DIR}.htaccess ${OPENSHIFT_DATA_DIR}.htaccess
  73. echo ".htaccess copied."
  74. else
  75. echo "Looks like the .htaccess file is already there, we won't overwrite it."
  76. fi
  77. ####
  78. # symlink the .htaccess file.
  79. echo "Create sym link for .htaccess"
  80. ln -sf ${OPENSHIFT_DATA_DIR}.htaccess ${OPENSHIFT_REPO_DIR}.htaccess
  81. echo ".htaccess symlink created"
  82. ####
  83. echo "Check for the poller at .openshift/cron/minutely/poller , if not created - create it"
  84. if [ ! -f ${OPENSHIFT_REPO_DIR}.openshift/cron/minutely/poller ]; then
  85. printf '%s\n' '#!/bin/bash' 'if [ ! -f $OPENSHIFT_DATA_DIR/last_run ]; then' ' touch $OPENSHIFT_DATA_DIR/last_run' 'fi' 'if [[ $(find $OPENSHIFT_DATA_DIR/last_run -mmin +9) ]]; then #run every 10 mins' ' rm -f $OPENSHIFT_DATA_DIR/last_run' ' touch $OPENSHIFT_DATA_DIR/last_run' ' # The command(s) that you want to run every 10 minutes' 'cd /var/lib/openshift/${OPENSHIFT_APP_UUID}/app-root/repo; /opt/rh/php54/root/usr/bin/php include/poller.php' 'fi' >${OPENSHIFT_REPO_DIR}.openshift/cron/minutely/poller
  86. echo "Done creating file .openshift/cron/minutely/poller"
  87. else
  88. echo "The poller already exists"
  89. fi
  90. ####
  91. # Set permissions on the poller script to make it executable.
  92. echo "Now chmod 777 -R poller"
  93. chmod -R 777 ${OPENSHIFT_REPO_DIR}.openshift/cron/minutely/poller
  94. echo "chmod done, permissions set to 777 on poller script."
  95. ####
  96. ### echo "Check for the hot deploy marker at .openshift/markers/hot_deploy , if not created - create it"
  97. ### if [ ! -f ${OPENSHIFT_REPO_DIR}.openshift/markers/hot_deploy ]; then
  98. ### touch ${OPENSHIFT_REPO_DIR}.openshift/markers/hot_deploy
  99. ### echo "Done creating file .openshift/markers/hot_deploy"
  100. ### else
  101. ### echo "The hot deploy marker already exists"
  102. ### fi
  103. ####
  104. # Hubzilla configuration - changes to default settings
  105. # to make Hubzilla on OpenShift a more pleasant experience
  106. echo "Changing default configuration to conserve space and autocreate a social private channel upon account registration"
  107. cd ${OPENSHIFT_REPO_DIR}
  108. util/config system auto_channel_create
  109. util/config system default_permissions_role social_private
  110. util/config system workflow_channel_next channel
  111. util/config system expire_delivery_reports 3
  112. util/config system feed_contacts 0
  113. util/config system diaspora_enabled 0
  114. util/config system disable_discover_tab 1
  115. util/config directory safemode 0
  116. util/config directory globaldir 1
  117. util/config directory pubforums 0
  118. # Hubzill addons
  119. echo "Try to add or update Hubzilla addons"
  120. cd ${OPENSHIFT_REPO_DIR}
  121. util/add_addon_repo https://github.com/redmatrix/hubzilla-addons.git HubzillaAddons
  122. # Hubzilla themes - unofficial repo
  123. echo "Try to add or update Hubzilla themes - unofficial repo"
  124. cd ${OPENSHIFT_REPO_DIR}
  125. util/add_theme_repo https://github.com/DeadSuperHero/hubzilla-themes.git DeadSuperHeroThemes insecure
  126. # Hubzilla ownMapp - unofficial repo
  127. echo "Try to add or update Hubzilla ownMapp - unofficial repo"
  128. cd ${OPENSHIFT_REPO_DIR}
  129. util/add_addon_repo https://gitlab.com/zot/ownmapp.git ownMapp insecure
  130. # Hubzilla Chess - unofficial repo
  131. echo "Try to add or update Hubzilla chess - unofficial repo"
  132. cd ${OPENSHIFT_REPO_DIR}
  133. util/add_addon_repo https://gitlab.com/zot/hubzilla-chess.git Chess insecure
  134. # Hubzilla Hubsites - unofficial repo
  135. echo "Try to add or update Hubzilla Hubsites - unofficial repo"
  136. cd ${OPENSHIFT_REPO_DIR}
  137. util/add_addon_repo https://gitlab.com/zot/hubsites.git Hubsites insecure