Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.63 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. set -o errexit
  4.  
  5. mkdir -p /usr/lib/python2.7/site-packages/openstack_dashboard/local/enabled
  6.  
  7. FORCE_GENERATE="${FORCE_GENERATE}"
  8.  
  9. if [[ ${KOLLA_INSTALL_TYPE} == "binary" ]]; then
  10. SITE_PACKAGES="/usr/lib/python2.7/site-packages"
  11. elif [[ ${KOLLA_INSTALL_TYPE} == "source" ]]; then
  12. SITE_PACKAGES="/var/lib/kolla/venv/lib/python2.7/site-packages"
  13. fi
  14.  
  15. if [[ ${KOLLA_INSTALL_TYPE} == "source" ]] && [[ ! -f ${SITE_PACKAGES}/openstack_dashboard/local/local_settings.py ]]; then
  16. ln -s /etc/openstack-dashboard/local_settings \
  17. ${SITE_PACKAGES}/openstack_dashboard/local/local_settings.py
  18. fi
  19.  
  20. if [[ -f /etc/openstack-dashboard/custom_local_settings ]] && [[ ! -f ${SITE_PACKAGES}/openstack_dashboard/local/custom_local_settings.py ]]; then
  21. ln -s /etc/openstack-dashboard/custom_local_settings \
  22. ${SITE_PACKAGES}/openstack_dashboard/local/custom_local_settings.py
  23. fi
  24.  
  25. # Bootstrap and exit if KOLLA_BOOTSTRAP variable is set. This catches all cases
  26. # of the KOLLA_BOOTSTRAP variable being set, including empty.
  27. if [[ "${!KOLLA_BOOTSTRAP[@]}" ]]; then
  28. MANAGE_PY="/usr/bin/python /usr/bin/manage.py"
  29. if [[ -f "/var/lib/kolla/venv/bin/python" ]]; then
  30. MANAGE_PY="/var/lib/kolla/venv/bin/python /var/lib/kolla/venv/bin/manage.py"
  31. fi
  32. $MANAGE_PY migrate --noinput
  33. exit 0
  34. fi
  35.  
  36. function config_dashboard {
  37. ENABLE=$1
  38. SRC=$2
  39. DEST=$3
  40. if [[ ! -f ${SRC} ]]; then
  41. echo "WARNING: ${SRC} is required"
  42. elif [[ "${ENABLE}" == "yes" ]] && [[ ! -f "${DEST}" ]]; then
  43. cp -a "${SRC}" "${DEST}"
  44. FORCE_GENERATE="yes"
  45. elif [[ "${ENABLE}" != "yes" ]] && [[ -f "${DEST}" ]]; then
  46. # remove pyc pyo files too
  47. rm -f "${DEST}" "${DEST}c" "${DEST}o"
  48. FORCE_GENERATE="yes"
  49. fi
  50. }
  51.  
  52. function config_cloudkitty_dashboard {
  53. for file in ${SITE_PACKAGES}/cloudkittydashboard/enabled/_*[^__].py; do
  54. config_dashboard "${ENABLE_CLOUDKITTY}" \
  55. "${SITE_PACKAGES}/cloudkittydashboard/enabled/${file##*/}" \
  56. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  57. done
  58. }
  59.  
  60. function config_designate_dashboard {
  61. for file in ${SITE_PACKAGES}/designatedashboard/enabled/_*[^__].py; do
  62. config_dashboard "${ENABLE_DESIGNATE}" \
  63. "${SITE_PACKAGES}/designatedashboard/enabled/${file##*/}" \
  64. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  65. done
  66. }
  67.  
  68. function config_fwaas_dashboard {
  69. for file in ${SITE_PACKAGES}/neutron_fwaas_dashboard/enabled/_*[^__].py; do
  70. config_dashboard "${ENABLE_FWAAS}" \
  71. "${SITE_PACKAGES}/neutron_fwaas_dashboard/enabled/${file##*/}" \
  72. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  73. done
  74. }
  75.  
  76. function config_freezer_ui {
  77. for file in ${SITE_PACKAGES}/disaster_recovery/enabled/_*[^__].py; do
  78. config_dashboard "${ENABLE_FREEZER}" \
  79. "${SITE_PACKAGES}/disaster_recovery/enabled/${file##*/}" \
  80. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  81. done
  82. }
  83.  
  84. function config_heat_dashboard {
  85. for file in ${SITE_PACKAGES}/heat_dashboard/enabled/_*[^__].py; do
  86. config_dashboard "${ENABLE_HEAT}" \
  87. "${SITE_PACKAGES}/heat_dashboard/enabled/${file##*/}" \
  88. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  89. done
  90. }
  91.  
  92. function config_ironic_dashboard {
  93. for file in ${SITE_PACKAGES}/ironic_ui/enabled/_*[^__].py; do
  94. config_dashboard "${ENABLE_IRONIC}" \
  95. "${SITE_PACKAGES}/ironic_ui/enabled/${file##*/}" \
  96. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  97. done
  98. }
  99.  
  100. function config_karbor_dashboard {
  101. for file in ${SITE_PACKAGES}/karbor_dashboard/enabled/_*[^__].py; do
  102. config_dashboard "${ENABLE_KARBOR}" \
  103. "${SITE_PACKAGES}/karbor_dashboard/enabled/${file##*/}" \
  104. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  105. done
  106. }
  107.  
  108. function config_magnum_dashboard {
  109. for file in ${SITE_PACKAGES}/magnum_ui/enabled/_*[^__].py; do
  110. config_dashboard "${ENABLE_MAGNUM}" \
  111. "${SITE_PACKAGES}/magnum_ui/enabled/${file##*/}" \
  112. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  113. done
  114. }
  115.  
  116. function config_manila_ui {
  117. for file in ${SITE_PACKAGES}/manila_ui/local/enabled/_*[^__].py; do
  118. config_dashboard "${ENABLE_MANILA}" \
  119. "${SITE_PACKAGES}/manila_ui/local/enabled/${file##*/}" \
  120. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  121. done
  122. }
  123.  
  124. function config_murano_dashboard {
  125. for file in ${SITE_PACKAGES}/muranodashboard/local/enabled/_*[^__].py; do
  126. config_dashboard "${ENABLE_MURANO}" \
  127. "${SITE_PACKAGES}/muranodashboard/local/enabled/${file##*/}" \
  128. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  129. done
  130. config_dashboard "${ENABLE_MURANO}"\
  131. "${SITE_PACKAGES}/muranodashboard/conf/murano_policy.json" \
  132. "/etc/openstack-dashboard/murano_policy.json"
  133.  
  134. config_dashboard "${ENABLE_MURANO}"\
  135. "${SITE_PACKAGES}/muranodashboard/local/local_settings.d/_50_murano.py" \
  136. "${SITE_PACKAGES}/openstack_dashboard/local/local_settings.d/_50_murano.py"
  137. }
  138.  
  139. function config_mistral_dashboard {
  140. config_dashboard "${ENABLE_MISTRAL}" \
  141. "${SITE_PACKAGES}/mistraldashboard/enabled/_50_mistral.py" \
  142. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/_50_mistral.py"
  143. }
  144.  
  145. function config_neutron_lbaas {
  146. config_dashboard "${ENABLE_NEUTRON_LBAAS}" \
  147. "${SITE_PACKAGES}/neutron_lbaas_dashboard/enabled/_1481_project_ng_loadbalancersv2_panel.py" \
  148. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/_1481_project_ng_loadbalancersv2_panel.py"
  149. }
  150.  
  151. function config_octavia_dashboard {
  152. config_dashboard "${ENABLE_OCTAVIA}" \
  153. "${SITE_PACKAGES}/octavia_dashboard/enabled/_1482_project_load_balancer_panel.py" \
  154. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/_1482_project_load_balancer_panel.py"
  155. }
  156.  
  157. function config_sahara_dashboard {
  158. for file in ${SITE_PACKAGES}/sahara_dashboard/enabled/_*[^__].py; do
  159. config_dashboard "${ENABLE_SAHARA}" \
  160. "${SITE_PACKAGES}/sahara_dashboard/enabled/${file##*/}" \
  161. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  162. done
  163. }
  164.  
  165. function config_searchlight_ui {
  166. for file in ${SITE_PACKAGES}/searchlight_ui/enabled/_*[^__].py; do
  167. config_dashboard "${ENABLE_SEARCHLIGHT}" \
  168. "${SITE_PACKAGES}/searchlight_ui/enabled/${file##*/}" \
  169. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  170. done
  171.  
  172. config_dashboard "${ENABLE_SEARCHLIGHT}" \
  173. "${SITE_PACKAGES}/searchlight_ui/local_settings.d/_1001_search_settings.py" \
  174. "${SITE_PACKAGES}/openstack_dashboard/local/local_settings.d/_1001_search_settings.py"
  175.  
  176. config_dashboard "${ENABLE_SEARCHLIGHT}" \
  177. "${SITE_PACKAGES}/searchlight_ui/conf/searchlight_policy.json" \
  178. "/etc/openstack-dashboard/searchlight_policy.json"
  179. }
  180.  
  181. function config_senlin_dashboard {
  182. for file in ${SITE_PACKAGES}/senlin_dashboard/enabled/_*[^__].py; do
  183. config_dashboard "${ENABLE_SENLIN}" \
  184. "${SITE_PACKAGES}/senlin_dashboard/enabled/${file##*/}" \
  185. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  186. done
  187.  
  188. config_dashboard "${ENABLE_SENLIN}" \
  189. "${SITE_PACKAGES}/senlin_dashboard/conf/senlin_policy.json" \
  190. "/etc/openstack-dashboard/senlin_policy.json"
  191. }
  192.  
  193. function config_solum_dashboard {
  194. for file in ${SITE_PACKAGES}/solumdashboard/local/enabled/_*[^__].py; do
  195. config_dashboard "${ENABLE_SOLUM}" \
  196. "${SITE_PACKAGES}/solumdashboard/local/enabled/${file##*/}" \
  197. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  198. done
  199. }
  200.  
  201. function config_tacker_dashboard {
  202. for file in ${SITE_PACKAGES}/tacker_horizon/enabled/_*[^__].py; do
  203. config_dashboard "${ENABLE_TACKER}" \
  204. "${SITE_PACKAGES}/tacker_horizon/enabled/${file##*/}" \
  205. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  206. done
  207. }
  208.  
  209. function config_trove_dashboard {
  210. for file in ${SITE_PACKAGES}/trove_dashboard/enabled/_*[^__].py; do
  211. config_dashboard "${ENABLE_TROVE}" \
  212. "${SITE_PACKAGES}/trove_dashboard/enabled/${file##*/}" \
  213. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  214. done
  215. }
  216.  
  217. function config_vitrage_dashboard {
  218. for file in ${SITE_PACKAGES}/vitrage_dashboard/enabled/_*[^__].py; do
  219. config_dashboard "${ENABLE_VITRAGE}" \
  220. "${SITE_PACKAGES}/vitrage_dashboard/enabled/${file##*/}" \
  221. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  222. done
  223. }
  224.  
  225. function config_watcher_dashboard {
  226. for file in ${SITE_PACKAGES}/watcher_dashboard/local/enabled/_*[^__].py; do
  227. config_dashboard "${ENABLE_WATCHER}" \
  228. "${SITE_PACKAGES}/watcher_dashboard/local/enabled/${file##*/}" \
  229. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  230. done
  231.  
  232. config_dashboard "${ENABLE_WATCHER}" \
  233. "${SITE_PACKAGES}/watcher_dashboard/conf/watcher_policy.json" \
  234. "/etc/openstack-dashboard/watcher_policy.json"
  235. }
  236.  
  237. function config_zaqar_dashboard {
  238. for file in ${SITE_PACKAGES}/zaqar_ui/enabled/_*[^__].py; do
  239. config_dashboard "${ENABLE_ZAQAR}" \
  240. "${SITE_PACKAGES}/zaqar_ui/enabled/${file##*/}" \
  241. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  242. done
  243. }
  244.  
  245. function config_zun_dashboard {
  246. for file in ${SITE_PACKAGES}/zun_ui/enabled/_*[^__].py; do
  247. config_dashboard "${ENABLE_ZUN}" \
  248. "${SITE_PACKAGES}/zun_ui/enabled/${file##*/}" \
  249. "${SITE_PACKAGES}/openstack_dashboard/local/enabled/${file##*/}"
  250. done
  251. }
  252.  
  253. # NOTE(jeffrey4l, niedbalski): The local_settings and custom_local_settings files
  254. # affect django-compress behavior, so re-generate the compressed
  255. # javascript and css if any of those setting files changed
  256. function settings_changed {
  257. declare -A settings=( ['/etc/openstack-dashboard/local_settings']="/var/lib/kolla/.local_settings.md5sum.txt" ['/etc/openstack-dashboard/custom_local_settings']="/var/lib/kolla/.custom_local_settings.md5sum.txt")
  258. declare -x changed=1
  259. for path in "${!settings[@]}"; do
  260. if [[ ! -f ${settings[$path]} || $(md5sum -c --status ${settings[$path]};echo $?) != 0 || ${FORCE_GENERATE} == "yes" ]]; then
  261. changed=0
  262. md5sum ${path} > ${settings[$path]}
  263. fi
  264. done
  265. return ${changed}
  266. }
  267.  
  268. config_cloudkitty_dashboard
  269. config_designate_dashboard
  270. config_fwaas_dashboard
  271. config_freezer_ui
  272. config_heat_dashboard
  273. config_ironic_dashboard
  274. config_karbor_dashboard
  275. config_magnum_dashboard
  276. config_manila_ui
  277. config_mistral_dashboard
  278. config_murano_dashboard
  279. config_neutron_lbaas
  280. config_octavia_dashboard
  281. config_sahara_dashboard
  282. config_searchlight_ui
  283. config_senlin_dashboard
  284. config_solum_dashboard
  285. config_tacker_dashboard
  286. config_trove_dashboard
  287. config_vitrage_dashboard
  288. config_watcher_dashboard
  289. config_zaqar_dashboard
  290. config_zun_dashboard
  291.  
  292. # NOTE(pbourke): httpd will not clean up after itself in some cases which
  293. # results in the container not being able to restart. (bug #1489676, 1557036)
  294. if [[ "${KOLLA_BASE_DISTRO}" =~ debian|ubuntu ]]; then
  295. # Loading Apache2 ENV variables
  296. . /etc/apache2/envvars
  297. rm -rf /var/run/apache2/*
  298. else
  299. rm -rf /var/run/httpd/* /run/httpd/* /tmp/httpd*
  300. fi
  301.  
  302. if settings_changed; then
  303. if [[ "${KOLLA_INSTALL_TYPE}" == "binary" ]]; then
  304. /usr/bin/manage.py collectstatic --noinput --clear
  305. /usr/bin/manage.py compress --force
  306. elif [[ "${KOLLA_INSTALL_TYPE}" == "source" ]]; then
  307. /var/lib/kolla/venv/bin/python /var/lib/kolla/venv/bin/manage.py collectstatic --noinput --clear
  308. /var/lib/kolla/venv/bin/python /var/lib/kolla/venv/bin/manage.py compress --force
  309. fi
  310. fi
  311.  
  312. # NOTE(sbezverk) since Horizon is now storing logs in its own location, /var/log/horizon
  313. # needs to be created if it does not exist
  314. if [[ ! -d "/var/log/kolla/horizon" ]]; then
  315. mkdir -p /var/log/kolla/horizon
  316. fi
  317.  
  318. if [[ $(stat -c %a /var/log/kolla/horizon) != "755" ]]; then
  319. chmod 755 /var/log/kolla/horizon
  320. fi
  321.  
  322. if [[ -f ${SITE_PACKAGES}/openstack_dashboard/local/.secret_key_store ]] && [[ $(stat -c %U ${SITE_PACKAGES}/openstack_dashboard/local/.secret_key_store) != "horizon" ]]; then
  323. chown horizon ${SITE_PACKAGES}/openstack_dashboard/local/.secret_key_store
  324. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement