123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. #!/bin/bash
  2. . <(ffoom init)
  3. FFOO_INI_PATH="__FFOO_INI_PATH__"
  4. ffoo import core
  5. ffoo import ini
  6. ffoo import proj_ol
  7. ffoo import testing
  8. ffoo import sw
  9. ffoo import yummy
  10. ENVIRON_SCRIPT="$HOME/.eemk-env"
  11. FFOO_VERBOSE=true
  12. # tmp needs to be shared to children
  13. if test -d "$TMP_DIR";
  14. then # we must be child
  15. THIS_IS_CHILD=true
  16. else # we are top parent; need some setup
  17. THIS_IS_CHILD=false
  18. export TMP_DIR="$(mktemp -d)"
  19. fi
  20. [ "$(whoami)" == "root" ] || die "you need to be root"
  21. yum_install_if_needed wget
  22. case "$1" in
  23. ## ------ ##
  24. ## COMMON ##
  25. ## ------ ##
  26. abrtbz)
  27. think "Updating abrt to internal version"
  28. save_repo_for abrtbz
  29. yum_update "abrt"
  30. ;;
  31. sl0)
  32. think "Turning off SELinux"
  33. setenforce 0
  34. sed -i~ -e 's/^SELINUX=.*/SELINUX=permissive/' /etc/selinux/config
  35. ;;
  36. ## ------- ##
  37. ## OPENLMI ##
  38. ## ------- ##
  39. ## setup - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ##
  40. olbrc)
  41. LMI_CIMOM_PORT=5989
  42. mkdir -p "$(dirname $ENVIRON_SCRIPT)"
  43. think "Adding ol environment script $ENVIRON_SCRIPT to .bashrc"
  44. {
  45. # warning: only echo if not login shell or rsync will freak out
  46. echo "shopt -q login_shell && echo setting up ol environment variables"
  47. echo "export LMI_ACCOUNT_USER='account_test_user'"
  48. echo "export LMI_ACCOUNT_GROUP='account_test_group'"
  49. echo "export LMI_CIMOM_URL='https://${HOSTNAME}:$LMI_CIMOM_PORT'"
  50. echo "export LMI_CIMOM_USERNAME='pegasus'"
  51. echo "export LMI_CIMOM_PASSWORD='blank'"
  52. echo "export LMI_CIMOM_BROKER='tog-pegasus'"
  53. echo "export LMI_RUN_DANGEROUS='1'"
  54. echo "export LMI_IND_LISTENER_PORT='15000'"
  55. echo "export PYTHONPATH='$PYTHONPATH:$PWD/openlmi-providers/src/python'"
  56. } > $ENVIRON_SCRIPT
  57. append_if_missing \
  58. "test -f $ENVIRON_SCRIPT && . $ENVIRON_SCRIPT" \
  59. /root/.bashrc
  60. ;;
  61. olconfig)
  62. $0 sl0
  63. think "Bypassing SSL verification"
  64. echo "127.0.0.1 $(hostname)" >> /etc/hosts
  65. service tog-pegasus start # to generate server.pem
  66. service tog-pegasus stop
  67. cp "/etc/Pegasus/server.pem" \
  68. "/etc/pki/ca-trust/source/anchors/remote-server.pem"
  69. update-ca-trust
  70. think "Setting pegasus password"
  71. echo "pegasus:blank" | chpasswd
  72. $0 olbrc
  73. ;;
  74. ## runtime - - - - - - - - - - - - - - - - - - - - - - - - - - - - ##
  75. olenv)
  76. . $ENVIRON_SCRIPT
  77. ;;
  78. olcs)
  79. think "Starting a simple cimserver ($(comment_cimserver))"
  80. start_cimserver
  81. ;;
  82. olrun*)
  83. $0 olcs
  84. $0 olenv
  85. iniread -p mk.run.what.$2 mk-ol.ini \
  86. | while read path;
  87. do
  88. pushd "$(dirname $path)";
  89. nosetests --nocapture -v "$(basename $path)"
  90. popd
  91. done
  92. stop_cimserver
  93. ;;
  94. olmk*)
  95. # let's build *anything*
  96. case $2 in
  97. p|openlmi-providers)
  98. withjm=0
  99. rtag_word=$(guess_rtag_word)
  100. rtag_num=$(guess_rtag_num)
  101. test "$rtag_word" == "fc" \
  102. -a 0$rtag_num -ge 22 \
  103. && withjm=1
  104. (
  105. mkdir -p openlmi-providers/build
  106. cd openlmi-providers/build
  107. cmake .. -DCMAKE_INSTALL_PREFIX=/usr \
  108. -DWITH-FAN=0 \
  109. -DWITH-POWER=0 \
  110. -DWITH-SSSD=0 \
  111. -DWITH-JOBMANAGER=$withjm
  112. make
  113. make doc
  114. make install
  115. make register-Service
  116. )
  117. ;;
  118. t|openlmi-tools)
  119. (
  120. cd openlmi-tools
  121. make clean
  122. make setup
  123. python setup.py install
  124. )
  125. ;;
  126. *)
  127. die "don't know how to build: $2"
  128. ;;
  129. esac
  130. ;;
  131. olyum)
  132. save_repo_for openlmi-scripts
  133. think "Installing OpenLMI software"
  134. iniread -s mk.requires.sut mk-ol.ini | any_install
  135. think "Installing testing tools"
  136. iniread -s mk.requires.test mk-ol.ini | any_install
  137. ;;
  138. OL)
  139. $0 olyum
  140. $0 olconfig
  141. ;;
  142. OLB)
  143. think "Installing build dependencies"
  144. iniread -s mk.requires.build mk-ol.ini | any_install
  145. ;;
  146. ## --------- ##
  147. ## BEAKERLIB ##
  148. ## --------- ##
  149. bkrund)
  150. TERM=xterm reset
  151. pushd "proj/$2"
  152. make run > 1
  153. popd
  154. ;;
  155. bkrun)
  156. pushd "proj/$2"
  157. make run
  158. popd
  159. ;;
  160. ## rpmwork - - - - - - - - - - - - - - - - - - - - - - - - - - - - ##
  161. rpmso)
  162. path=rpms/old/`arch`
  163. think "Deploying old RPMs from $path"
  164. guess_pkgnames $path | yum_preerase
  165. yum_install $path/*
  166. guess_pkgnames $path | installed_versions
  167. ;;
  168. rpmsn)
  169. path=rpms/new/`arch`
  170. think "Deploying new RPMs from $path"
  171. guess_pkgnames $path | yum_preerase
  172. yum_install $path/*
  173. guess_pkgnames $path | installed_versions
  174. ;;
  175. RH)
  176. save_repo_for beakerlib
  177. save_repo_for rhpkg
  178. save_repo_for beakerlib-redhat
  179. think "Installing system under test"
  180. iniread -s mk.requires.sut mk-bk.ini | any_install
  181. think "Installing testing tools"
  182. iniread -s mk.requires.test mk-bk.ini | any_install
  183. ;;
  184. *)
  185. usage_is "TARGET"
  186. esac
  187. if ! $THIS_IS_CHILD;
  188. then
  189. collect_artifacts artifacts
  190. rm -rf $TMP_DIR
  191. fi