Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- === modified file 'debian/changelog'
- --- debian/changelog 2009-10-08 04:27:50 +0000
- +++ debian/changelog 2009-10-08 05:15:19 +0000
- @@ -14,6 +14,8 @@
- - Drop any patches that weren't actually being applied.
- * Set default theme to Mythbuntu rather than Mythbuntu-9.10 since upstream
- accepted it without a version number applied.
- + * debian/mythtv-database.{postinst,config}:
- + - Use the debian system maintainer account to set things up if possible.
- -- Mario Limonciello <superm1@ubuntu.com> Wed, 07 Oct 2009 23:24:05 -0500
- === modified file 'debian/mythtv-database.config'
- --- debian/mythtv-database.config 2009-01-02 19:36:01 +0000
- +++ debian/mythtv-database.config 2009-10-08 05:15:19 +0000
- @@ -11,54 +11,63 @@
- db_set mythtv/mysql_host "`sed -n -e 's/^\(str *\)\?DBHostName=\(.*\)$/\2/gp;' $CONFIG`"
- fi
- -db_input low mythtv/mysql_host || true
- -db_get mythtv/mysql_host
- -HOST="$RET"
- -
- -if test -z "$HOST"; then
- - HOST=localhost
- - db_set mythtv/mysql_host "$HOST"
- -fi
- -
- -db_input low mythtv/mysql_admin_user || true
- -db_get mythtv/mysql_admin_user
- -USER="$RET"
- -db_subst mythtv/mysql_admin_password user "$USER"
- -
- -#Try to get it from mysql config
- -#rather than ask twice.
- -db_get mysql-server/root_password || RET="" && true
- -PASSWORD="$RET"
- -if ! test -z "$PASSWORD"; then
- - db_set mythtv/mysql_admin_password $PASSWORD
- -
- -#We couldn't get it from mysql's debconf, so we'll use our own
- -elif which mysql >/dev/null; then
- - #if localhost and no running mysql process, our later check
- - #would be failing
- - if [ "$HOST" = "localhost" ] && ! pgrep mysqld\$ >/dev/null; then
- - db_input high mythtv/mysql_admin_password || true
- - #mysql should be running and installed, try 5 times to do it
- +if which mysql >/dev/null; then
- + if echo "show databases;" | mysql --defaults-file=/etc/mysql/debian.cnf >/dev/null 2>&1; then
- + db_set mythtv/mysql_admin_user "debian-sys-maint"
- + db_set mythtv/mysql_admin_password ""
- else
- - i=1
- - while ! echo "show databases;" | mysql --host="$HOST" --user="$USER" --password="$PASSWORD" >/dev/null 2>&1; do
- - if [ $i -ge 5 ]; then
- - echo "Failed to connect to database (incorrect admin password)" >&2
- - break
- - fi
- - db_input high mythtv/mysql_admin_password || true
- - db_go
- - db_get mythtv/mysql_admin_password
- - PASSWORD="$RET"
- - i=$(($i+1))
- - done
- + db_input low mythtv/mysql_host || true
- + db_get mythtv/mysql_host
- + HOST="$RET"
- +
- + if test -z "$HOST"; then
- + HOST=localhost
- + db_set mythtv/mysql_host "$HOST"
- + fi
- +
- + db_input low mythtv/mysql_admin_user || true
- + db_get mythtv/mysql_admin_user
- + USER="$RET"
- + db_subst mythtv/mysql_admin_password user "$USER"
- +
- + #Try to get it from mysql config
- + #rather than ask twice.
- + db_get mysql-server/root_password || RET="" && true
- + PASSWORD="$RET"
- + if ! test -z "$PASSWORD"; then
- + db_set mythtv/mysql_admin_password $PASSWORD
- +
- + ##We couldn't get it from mysql's debconf, so we'll use our own##
- +
- + #if localhost and no running mysql process, our later check
- + #would be failing
- + elif [ "$HOST" = "localhost" ] && ! pgrep mysqld\$ >/dev/null; then
- + db_set mythtv/mysql_admin_user "debian-sys-maint"
- + db_set mythtv/mysql_admin_password ""
- + #mysql should be running and installed, try 5 times to do it
- + else
- + i=1
- + while ! echo "show databases;" | mysql --host="$HOST" --user="$USER" --password="$PASSWORD" >/dev/null 2>&1; do
- + if [ $i -ge 5 ]; then
- + echo "Failed to connect to database (incorrect admin password)" >&2
- + break
- + fi
- + db_input high mythtv/mysql_admin_password || true
- + db_go
- + db_get mythtv/mysql_admin_password
- + PASSWORD="$RET"
- + i=$(($i+1))
- + done
- + fi
- fi
- #mysql binary isn't installed yet, but that shouldn't cause the config
- #to be failing because this might be called during the preinst
- else
- - db_input high mythtv/mysql_admin_password || true
- + db_set mythtv/mysql_admin_user "debian-sys-maint"
- + db_set mythtv/mysql_admin_password ""
- fi
- +
- #Ask the user about expandability
- db_input high mythtv/public_bind || true
- db_go || true
- === modified file 'debian/mythtv-database.postinst'
- --- debian/mythtv-database.postinst 2009-10-08 04:27:50 +0000
- +++ debian/mythtv-database.postinst 2009-10-08 05:15:19 +0000
- @@ -1,5 +1,4 @@
- #!/bin/sh -e
- -
- MYSQL="/usr/share/mythtv/sql/mythtv*.sql"
- MYSQLCONFIG="/etc/mysql/conf.d/mythtv.cnf"
- FSTAB="/etc/fstab"
- @@ -22,17 +21,17 @@
- #Preload tables and default values
- 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" |\
- - mysql -h $hostname -u $admin_username $admin_password $database
- + mysql $SECURITY_INFO $database
- #Set up local IP and hostname
- if ! echo "UPDATE settings SET data = '$NEWIP' WHERE settings.value = 'BackendServerIP' AND settings.hostname = '$LOCALHOSTNAME';" | \
- - mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
- + mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
- fail_database
- fi
- #Set up master IP and hostname
- if ! echo "UPDATE settings SET data = '$NEWIP' WHERE settings.value = 'MasterServerIP';" | \
- - mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
- + mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
- fail_database
- fi
- }
- @@ -49,25 +48,32 @@
- #ask the root password a few times if it's still not working
- ask_root_pw() {
- + db_input high mythtv/mysql_host || true
- + db_input high mythtv/mysql_admin_user || true
- db_input high mythtv/mysql_admin_password || true
- db_go
- + db_get mythtv/mysql_host
- + hostname="$RET"
- + db_get mythtv/mysql_admin_user
- + admin_username="$RET"
- db_get mythtv/mysql_admin_password
- admin_password="$RET"
- if [ "$admin_password" != "" ]; then
- admin_password="-p$admin_password"
- fi
- + SECURITY_INFO="--host=\"$hostname\" --user=\"$admin_username\" $admin_password"
- }
- update_database() {
- #Set up privs for mythtv@localhost
- if ! echo "GRANT ALL PRIVILEGES ON $database.* TO $mythtv_username@localhost IDENTIFIED BY '$mythtv_password';" | \
- - mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
- + mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
- fail_database
- fi
- #Set up privs for mythtv@network
- if ! echo "GRANT ALL PRIVILEGES ON $database.* TO $mythtv_username@'%' IDENTIFIED BY '$mythtv_password';" | \
- - mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
- + mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
- fail_database
- fi
- }
- @@ -76,15 +82,6 @@
- configure)
- . /usr/share/debconf/confmodule
- - db_get mythtv/mysql_host
- - hostname="$RET"
- -
- - db_get mythtv/mysql_admin_user
- - admin_username="$RET"
- -
- - db_get mythtv/mysql_admin_password
- - admin_password="$RET"
- -
- db_get mythtv/mysql_mythtv_dbname
- database="$RET"
- @@ -94,10 +91,24 @@
- db_get mythtv/mysql_mythtv_password
- mythtv_password="$RET"
- - if [ "$admin_password" != "" ]; then
- - admin_password="-p$admin_password"
- + db_get mythtv/mysql_admin_user
- + admin_username="$RET"
- +
- + if [ "$admin_username" = "debian-sys-maint" ]; then
- + SECURITY_INFO="--defaults-file=/etc/mysql/debian.cnf"
- + else
- + db_get mythtv/mysql_host
- + hostname="$RET"
- +
- + db_get mythtv/mysql_admin_password
- + admin_password="$RET"
- +
- + if [ "$admin_password" != "" ]; then
- + admin_password="-p$admin_password"
- + fi
- + SECURITY_INFO="--host=\"$hostname\" --user=\"$admin_username\" $admin_password"
- fi
- -
- +
- #If we are running locally, make sure to start mysql first
- #It's okay if it fails, we'll fall back cleanly later
- if [ "$hostname" = "localhost" ]; then
- @@ -120,10 +131,11 @@
- fi
- #Check for existing database
- - if ! echo "SELECT NULL;" | mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
- + if ! echo "SELECT NULL;" | mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
- #No existing database, create a database
- i=1
- - while ! echo "CREATE DATABASE $database;" | mysql --host="$hostname" --user="$admin_username" $admin_password >/dev/null 2>&1; do
- + while ! echo "CREATE DATABASE $database;" | mysql $SECURITY_INFO ; do
- +#>/dev/null 2>&1; do
- if [ $i -ge 5 ]; then
- fail_database
- fi
- @@ -133,7 +145,7 @@
- fi
- #Preload tables
- - if ! echo "SELECT value FROM settings LIMIT 1, 1;" | mysql --host="$hostname" --user="$admin_username" $admin_password "$database" >/dev/null 2>&1; then
- + if ! echo "SELECT value FROM settings LIMIT 1, 1;" | mysql $SECURITY_INFO "$database" >/dev/null 2>&1; then
- prepare_database
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement