From 47f7ad2e984771a0c2602f7899d200e04907a9dc Mon Sep 17 00:00:00 2001
From: Duncan Sommerville <duncan.sommerville@gmail.com>
Date: Wed, 25 Mar 2015 12:03:01 -0400
Subject: [PATCH] Fix to upgrade path

---
 airtime_mvc/application/controllers/UpgradeController.php | 2 --
 airtime_mvc/application/upgrade/Upgrades.php              | 2 +-
 install                                                   | 7 +++++++
 uninstall                                                 | 8 ++++----
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/airtime_mvc/application/controllers/UpgradeController.php b/airtime_mvc/application/controllers/UpgradeController.php
index b52630da4..3e0f2fba4 100644
--- a/airtime_mvc/application/controllers/UpgradeController.php
+++ b/airtime_mvc/application/controllers/UpgradeController.php
@@ -1,7 +1,5 @@
 <?php
 
-require_once("Upgrades.php");
-
 class UpgradeController extends Zend_Controller_Action
 {
     public function indexAction()
diff --git a/airtime_mvc/application/upgrade/Upgrades.php b/airtime_mvc/application/upgrade/Upgrades.php
index 9ee2be523..9bee585fa 100644
--- a/airtime_mvc/application/upgrade/Upgrades.php
+++ b/airtime_mvc/application/upgrade/Upgrades.php
@@ -30,7 +30,7 @@ class UpgradeManager
         array_push($upgraders, new AirtimeUpgrader253());
         array_push($upgraders, new AirtimeUpgrader254());
         */
-        return $upgradeManager->runUpgrades(array(new AirtimeUpgrader252()), (__DIR__ . "/controllers"));
+        return $upgradeManager->runUpgrades(array(new AirtimeUpgrader252()), (dirname(__DIR__) . "/controllers"));
     }
 
     /**
diff --git a/install b/install
index 3646645aa..8a627bb38 100755
--- a/install
+++ b/install
@@ -386,8 +386,10 @@ if [ "$apache" = "t" ]; then
 
     if [ "$apacheversion" != "1" ]; then
         airtimeconfigfile="airtime.conf"
+        oldconfigfile="airtime-vhost.conf"
     else
         airtimeconfigfile="airtime"
+        oldconfigfile="airtime-vhost"
     fi
 
     # If we're upgrading (installing over an existing Airtime install) and we've been told to
@@ -403,6 +405,11 @@ if [ "$apache" = "t" ]; then
             sed -e "s@WEB_ROOT@${web_root}@g" ${SCRIPT_DIR}/installer/apache/airtime-vhost > /etc/apache2/sites-available/${airtimeconfigfile}
         fi
         loudCmd "a2dissite 000-default"
+        # If Airtime was previously installed with apt, the vhost file name is different,
+        # so we need to specifically disable it.
+        if [ -f "/etc/apache2/sites-available/${oldconfigfile}" ]; then
+            loudCmd "a2dissite airtime-vhost"
+        fi
         loudCmd "a2ensite airtime"
     else
         verbose "\nApache config for Airtime already exists, skipping"
diff --git a/uninstall b/uninstall
index 9bf77ae2c..c7f8f44c5 100755
--- a/uninstall
+++ b/uninstall
@@ -71,16 +71,16 @@ echo "pip airtime-media-monitor"
 echo -e "\nIf your web root is not listed, you will need to manually remove it."
 
 echo -e "\nThis will *permanently* remove Airtime and all related files from your computer. \
-Any files in Airtime directories and subdirectories will be deleted. Are you sure you want to proceed? (Y/n): \c"
+Any files in Airtime directories and subdirectories will be deleted. Are you sure you want to proceed? [y/N]: \c"
 read IN
 if [[ ! ( "$IN" = "y" || "$IN" = "Y" ) ]]; then
     exit 0
 fi
 
 if [ -n "${STOR_DIR}" ]; then
-    echo -e "\nAre you sure you want to remove your music storage directory ${STOR_DIR} and all of its subdirectories? (Y/n): \c"
+    echo -e "\nDo you want to remove your music storage directory ${STOR_DIR} and all of its subdirectories? [y/N]: \c"
     read IN
-    if [[ "$IN" = "y" || "$IN" = "Y" ]]; then
+    if [[ ( "$IN" = "y" || "$IN" = "Y" ) ]]; then
         rm -rf ${STOR_DIR}
     fi
 else
@@ -94,7 +94,7 @@ for i in ${FILES[*]}; do
     rm -rf $i
 done
 
-echo -e "\nDo you want to drop your current Airtime database? (Y/n): \c"
+echo -e "\nDo you want to drop your current Airtime database? [y/N]: \c"
 read IN
 if [[ "$IN" = "y" || "$IN" = "Y" ]]; then
     echo -e "\nDropping Airtime database..."