Advertisement
Guest User

Untitled

a guest
May 11th, 2017
555
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.34 KB | None | 0 0
  1. === modified file 'debian/changelog'
  2. --- debian/changelog 2009-10-08 04:27:50 +0000
  3. +++ debian/changelog 2009-10-08 05:15:19 +0000
  4. @@ -14,6 +14,8 @@
  5. - Drop any patches that weren't actually being applied.
  6. * Set default theme to Mythbuntu rather than Mythbuntu-9.10 since upstream
  7. accepted it without a version number applied.
  8. + * debian/mythtv-database.{postinst,config}:
  9. + - Use the debian system maintainer account to set things up if possible.
  10.  
  11. -- Mario Limonciello <superm1@ubuntu.com> Wed, 07 Oct 2009 23:24:05 -0500
  12.  
  13.  
  14. === modified file 'debian/mythtv-database.config'
  15. --- debian/mythtv-database.config 2009-01-02 19:36:01 +0000
  16. +++ debian/mythtv-database.config 2009-10-08 05:15:19 +0000
  17. @@ -11,54 +11,63 @@
  18. db_set mythtv/mysql_host "`sed -n -e 's/^\(str *\)\?DBHostName=\(.*\)$/\2/gp;' $CONFIG`"
  19. fi
  20.  
  21. -db_input low mythtv/mysql_host || true
  22. -db_get mythtv/mysql_host
  23. -HOST="$RET"
  24. -
  25. -if test -z "$HOST"; then
  26. - HOST=localhost
  27. - db_set mythtv/mysql_host "$HOST"
  28. -fi
  29. -
  30. -db_input low mythtv/mysql_admin_user || true
  31. -db_get mythtv/mysql_admin_user
  32. -USER="$RET"
  33. -db_subst mythtv/mysql_admin_password user "$USER"
  34. -
  35. -#Try to get it from mysql config
  36. -#rather than ask twice.
  37. -db_get mysql-server/root_password || RET="" && true
  38. -PASSWORD="$RET"
  39. -if ! test -z "$PASSWORD"; then
  40. - db_set mythtv/mysql_admin_password $PASSWORD
  41. -
  42. -#We couldn't get it from mysql's debconf, so we'll use our own
  43. -elif which mysql >/dev/null; then
  44. - #if localhost and no running mysql process, our later check
  45. - #would be failing
  46. - if [ "$HOST" = "localhost" ] && ! pgrep mysqld\$ >/dev/null; then
  47. - db_input high mythtv/mysql_admin_password || true
  48. - #mysql should be running and installed, try 5 times to do it
  49. +if which mysql >/dev/null; then
  50. + if echo "show databases;" | mysql --defaults-file=/etc/mysql/debian.cnf >/dev/null 2>&1; then
  51. + db_set mythtv/mysql_admin_user "debian-sys-maint"
  52. + db_set mythtv/mysql_admin_password ""
  53. else
  54. - i=1
  55. - while ! echo "show databases;" | mysql --host="$HOST" --user="$USER" --password="$PASSWORD" >/dev/null 2>&1; do
  56. - if [ $i -ge 5 ]; then
  57. - echo "Failed to connect to database (incorrect admin password)" >&2
  58. - break
  59. - fi
  60. - db_input high mythtv/mysql_admin_password || true
  61. - db_go
  62. - db_get mythtv/mysql_admin_password
  63. - PASSWORD="$RET"
  64. - i=$(($i+1))
  65. - done
  66. + db_input low mythtv/mysql_host || true
  67. + db_get mythtv/mysql_host
  68. + HOST="$RET"
  69. +
  70. + if test -z "$HOST"; then
  71. + HOST=localhost
  72. + db_set mythtv/mysql_host "$HOST"
  73. + fi
  74. +
  75. + db_input low mythtv/mysql_admin_user || true
  76. + db_get mythtv/mysql_admin_user
  77. + USER="$RET"
  78. + db_subst mythtv/mysql_admin_password user "$USER"
  79. +
  80. + #Try to get it from mysql config
  81. + #rather than ask twice.
  82. + db_get mysql-server/root_password || RET="" && true
  83. + PASSWORD="$RET"
  84. + if ! test -z "$PASSWORD"; then
  85. + db_set mythtv/mysql_admin_password $PASSWORD
  86. +
  87. + ##We couldn't get it from mysql's debconf, so we'll use our own##
  88. +
  89. + #if localhost and no running mysql process, our later check
  90. + #would be failing
  91. + elif [ "$HOST" = "localhost" ] && ! pgrep mysqld\$ >/dev/null; then
  92. + db_set mythtv/mysql_admin_user "debian-sys-maint"
  93. + db_set mythtv/mysql_admin_password ""
  94. + #mysql should be running and installed, try 5 times to do it
  95. + else
  96. + i=1
  97. + while ! echo "show databases;" | mysql --host="$HOST" --user="$USER" --password="$PASSWORD" >/dev/null 2>&1; do
  98. + if [ $i -ge 5 ]; then
  99. + echo "Failed to connect to database (incorrect admin password)" >&2
  100. + break
  101. + fi
  102. + db_input high mythtv/mysql_admin_password || true
  103. + db_go
  104. + db_get mythtv/mysql_admin_password
  105. + PASSWORD="$RET"
  106. + i=$(($i+1))
  107. + done
  108. + fi
  109. fi
  110. #mysql binary isn't installed yet, but that shouldn't cause the config
  111. #to be failing because this might be called during the preinst
  112. else
  113. - db_input high mythtv/mysql_admin_password || true
  114. + db_set mythtv/mysql_admin_user "debian-sys-maint"
  115. + db_set mythtv/mysql_admin_password ""
  116. fi
  117.  
  118. +
  119. #Ask the user about expandability
  120. db_input high mythtv/public_bind || true
  121. db_go || true
  122.  
  123. === modified file 'debian/mythtv-database.postinst'
  124. --- debian/mythtv-database.postinst 2009-10-08 04:27:50 +0000
  125. +++ debian/mythtv-database.postinst 2009-10-08 05:15:19 +0000
  126. @@ -1,5 +1,4 @@
  127. #!/bin/sh -e
  128. -
  129. MYSQL="/usr/share/mythtv/sql/mythtv*.sql"
  130. MYSQLCONFIG="/etc/mysql/conf.d/mythtv.cnf"
  131. FSTAB="/etc/fstab"
  132. @@ -22,17 +21,17 @@
  133.  
  134. #Preload tables and default values
  135. cat $MYSQL | sed -e "s/Terra/Mythbuntu/g; s/OLDHOSTNAME/$LOCALHOSTNAME/g; s/127.0.0.1/$NEWIP/g; s/Slowly','0/Slowly','$EXT3/g; s/blueosd/BlackCurves-OSD/g" |\
  136. - mysql -h $hostname -u $admin_username $admin_password $database
  137. + mysql $SECURITY_INFO $database
  138.  
  139. #Set up local IP and hostname
  140. if ! echo "UPDATE settings SET data = '$NEWIP' WHERE settings.value = 'BackendServerIP' AND settings.hostname = '$LOCALHOSTNAME';" | \
  141. - mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
  142. + mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
  143. fail_database
  144. fi
  145.  
  146. #Set up master IP and hostname
  147. if ! echo "UPDATE settings SET data = '$NEWIP' WHERE settings.value = 'MasterServerIP';" | \
  148. - mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
  149. + mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
  150. fail_database
  151. fi
  152. }
  153. @@ -49,25 +48,32 @@
  154.  
  155. #ask the root password a few times if it's still not working
  156. ask_root_pw() {
  157. + db_input high mythtv/mysql_host || true
  158. + db_input high mythtv/mysql_admin_user || true
  159. db_input high mythtv/mysql_admin_password || true
  160. db_go
  161. + db_get mythtv/mysql_host
  162. + hostname="$RET"
  163. + db_get mythtv/mysql_admin_user
  164. + admin_username="$RET"
  165. db_get mythtv/mysql_admin_password
  166. admin_password="$RET"
  167. if [ "$admin_password" != "" ]; then
  168. admin_password="-p$admin_password"
  169. fi
  170. + SECURITY_INFO="--host=\"$hostname\" --user=\"$admin_username\" $admin_password"
  171. }
  172.  
  173. update_database() {
  174. #Set up privs for mythtv@localhost
  175. if ! echo "GRANT ALL PRIVILEGES ON $database.* TO $mythtv_username@localhost IDENTIFIED BY '$mythtv_password';" | \
  176. - mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
  177. + mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
  178. fail_database
  179. fi
  180.  
  181. #Set up privs for mythtv@network
  182. if ! echo "GRANT ALL PRIVILEGES ON $database.* TO $mythtv_username@'%' IDENTIFIED BY '$mythtv_password';" | \
  183. - mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
  184. + mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
  185. fail_database
  186. fi
  187. }
  188. @@ -76,15 +82,6 @@
  189. configure)
  190. . /usr/share/debconf/confmodule
  191.  
  192. - db_get mythtv/mysql_host
  193. - hostname="$RET"
  194. -
  195. - db_get mythtv/mysql_admin_user
  196. - admin_username="$RET"
  197. -
  198. - db_get mythtv/mysql_admin_password
  199. - admin_password="$RET"
  200. -
  201. db_get mythtv/mysql_mythtv_dbname
  202. database="$RET"
  203.  
  204. @@ -94,10 +91,24 @@
  205. db_get mythtv/mysql_mythtv_password
  206. mythtv_password="$RET"
  207.  
  208. - if [ "$admin_password" != "" ]; then
  209. - admin_password="-p$admin_password"
  210. + db_get mythtv/mysql_admin_user
  211. + admin_username="$RET"
  212. +
  213. + if [ "$admin_username" = "debian-sys-maint" ]; then
  214. + SECURITY_INFO="--defaults-file=/etc/mysql/debian.cnf"
  215. + else
  216. + db_get mythtv/mysql_host
  217. + hostname="$RET"
  218. +
  219. + db_get mythtv/mysql_admin_password
  220. + admin_password="$RET"
  221. +
  222. + if [ "$admin_password" != "" ]; then
  223. + admin_password="-p$admin_password"
  224. + fi
  225. + SECURITY_INFO="--host=\"$hostname\" --user=\"$admin_username\" $admin_password"
  226. fi
  227. -
  228. +
  229. #If we are running locally, make sure to start mysql first
  230. #It's okay if it fails, we'll fall back cleanly later
  231. if [ "$hostname" = "localhost" ]; then
  232. @@ -120,10 +131,11 @@
  233. fi
  234.  
  235. #Check for existing database
  236. - if ! echo "SELECT NULL;" | mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
  237. + if ! echo "SELECT NULL;" | mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
  238. #No existing database, create a database
  239. i=1
  240. - while ! echo "CREATE DATABASE $database;" | mysql --host="$hostname" --user="$admin_username" $admin_password >/dev/null 2>&1; do
  241. + while ! echo "CREATE DATABASE $database;" | mysql $SECURITY_INFO ; do
  242. +#>/dev/null 2>&1; do
  243. if [ $i -ge 5 ]; then
  244. fail_database
  245. fi
  246. @@ -133,7 +145,7 @@
  247. fi
  248.  
  249. #Preload tables
  250. - if ! echo "SELECT value FROM settings LIMIT 1, 1;" | mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
  251. + if ! echo "SELECT value FROM settings LIMIT 1, 1;" | mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
  252. prepare_database
  253. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement