Convert single bracket ifs to double bracket. Disable access to app during upgrade.
This commit is contained in:
58
install.sh
58
install.sh
@@ -21,7 +21,7 @@ CONFIG_DEFAULT_COLUMN=""
|
||||
|
||||
function privilege_check() {
|
||||
# test for superuser rights
|
||||
if [[ $EUID -ne 0 ]]; then
|
||||
if [[ "$EUID" != 0 ]]; then
|
||||
echo "This script must be run with superuser privileges. Try sudo $0"
|
||||
exit 1
|
||||
fi
|
||||
@@ -36,11 +36,11 @@ function get_new_password() {
|
||||
echo ""
|
||||
read -p "Re-type new password: " -s -r rnewpw
|
||||
echo ""
|
||||
if [ "$newpassword" = "" -o "$rnewpw" = "" ]
|
||||
if [[ "$newpassword" == "" || "$rnewpw" == "" ]]
|
||||
then
|
||||
echo "Password cannot be blank. Please try again."
|
||||
echo ""
|
||||
elif [ "$newpassword" != "$rnewpw" ]
|
||||
elif [[ "$newpassword" != "$rnewpw" ]]
|
||||
then
|
||||
echo "Passwords do not match. Please try again."
|
||||
echo ""
|
||||
@@ -63,7 +63,7 @@ function install_required_packages() {
|
||||
gpattern=""
|
||||
for pkg_option in $(echo $prereq)
|
||||
do
|
||||
if [ "$pkg_option" != "or" ]
|
||||
if [[ "$pkg_option" != "or" ]]
|
||||
then
|
||||
gpattern+=" -e $pkg_option"
|
||||
preferred_pkg=$pkg_option
|
||||
@@ -76,7 +76,7 @@ function install_required_packages() {
|
||||
echo "$APP_NAME requires $prereq, but it doesn't seem to be installed. "
|
||||
echo -n "Install $preferred_pkg now? [Y/n]: "
|
||||
read reqinstall
|
||||
if [ "$reqinstall" = "N" -o "$reqinstall" = "n" ]
|
||||
if [[ "$reqinstall" == "N" || "$reqinstall" == "n" ]]
|
||||
then
|
||||
echo "$APP_NAME requires $prereq, but you have elected not to install it."
|
||||
echo "Installation cannot continue."
|
||||
@@ -172,20 +172,20 @@ echo ""
|
||||
echo -n "Enter name of $APP_NAME installation directory [$INSTALL_LOC] :"
|
||||
read install_loc_in
|
||||
echo ""
|
||||
if [ "$doc_root_in" = "" ]
|
||||
if [[ "$doc_root_in" == "" ]]
|
||||
then
|
||||
doc_root_in=$DOC_ROOT
|
||||
fi
|
||||
if [ "$install_loc_in" = "" ]
|
||||
if [[ "$install_loc_in" == "" ]]
|
||||
then
|
||||
install_loc_in=$INSTALL_LOC
|
||||
fi
|
||||
install_path="$doc_root_in/$install_loc_in"
|
||||
if [ -d "$install_path" ]
|
||||
if [[ -d "$install_path" ]]
|
||||
then
|
||||
echo "The installation path you chose already exists."
|
||||
# Install path exists.
|
||||
if [ -e "$install_path/db.php" ]
|
||||
if [[ -e "$install_path/db.php" ]]
|
||||
then
|
||||
# A db.php file was found in the install path
|
||||
if grep -q -e "$APP_NAME" $install_path/db.php
|
||||
@@ -195,12 +195,17 @@ then
|
||||
echo "and restart the install using a new installation location."
|
||||
echo -n "[U]pgrade or [C]ancel? [U] :"
|
||||
read upgrade_choice
|
||||
if [[ $upgrade_choice == "C" || $upgrade_choice == "c" ]] # Cancel chosen
|
||||
if [[ "$upgrade_choice" == "C" || "$upgrade_choice" == "c" ]] # Cancel chosen
|
||||
then
|
||||
echo "Cancelling installation"
|
||||
abort_exit
|
||||
else
|
||||
# proceed with upgrade
|
||||
|
||||
# take app offline during upgrade
|
||||
a2disconf $install_loc_in
|
||||
systemctl reload apache2
|
||||
|
||||
datestamp=$(date +%Y-%m-%d_%H:%M:%S)
|
||||
backupdir=backups/$datestamp
|
||||
mkdir -p $backupdir
|
||||
@@ -246,12 +251,12 @@ then
|
||||
echo "Installing distribution . . ."
|
||||
cp -R distfiles/* $install_path
|
||||
# set symlink for jquery-ui
|
||||
if [ ! -L "$install_path/jquery-ui" ]
|
||||
if [[ ! -L "$install_path/jquery-ui" ]]
|
||||
then
|
||||
ln -s $install_path/jquery-ui* $install_path/jquery-ui
|
||||
fi
|
||||
# set symlink for index.php
|
||||
if [ ! -L "$install_path/index.php" ]
|
||||
if [[ ! -L "$install_path/index.php" ]]
|
||||
then
|
||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||
fi
|
||||
@@ -283,11 +288,11 @@ then
|
||||
echo "Would you like to use this location for a fresh installation or quit and"
|
||||
echo "investigate further? It's probably safest to quit and investigate."
|
||||
proceed=""
|
||||
while [[ $proceed != "P" && $proceed != "p" && $proceed != "Q" && $proceed != "q" ]]
|
||||
while [[ "$proceed" != "P" && "$proceed" != "p" && "$proceed" != "Q" && "$proceed" != "q" ]]
|
||||
do
|
||||
read proceed -p "[P]roceed with new install or [Q]uit? : "
|
||||
done
|
||||
if [[ $proceed == "Q" || $proceed == "q" ]]
|
||||
if [[ "$proceed" == "Q" || "$proceed" == "q" ]]
|
||||
then
|
||||
abort_exit
|
||||
fi
|
||||
@@ -302,7 +307,7 @@ else
|
||||
echo "This can be changed later in the application itself."
|
||||
echo -n "Installation name [$APP_NAME]: "
|
||||
read new_inst_name
|
||||
if [ "$new_inst_name" = "" ]
|
||||
if [[ "$new_inst_name" == "" ]]
|
||||
then
|
||||
new_inst_name="$APP_NAME"
|
||||
fi
|
||||
@@ -319,7 +324,7 @@ else
|
||||
echo "distinctive name."
|
||||
echo -n "database name [$DEFAULT_DB_NAME]: "
|
||||
read new_db_name
|
||||
if [ "$new_db_name" = "" ]
|
||||
if [[ "$new_db_name" == "" ]]
|
||||
then
|
||||
new_db_name=$DEFAULT_DB_NAME
|
||||
fi
|
||||
@@ -332,7 +337,7 @@ else
|
||||
echo "This probably means the database already exists."
|
||||
echo -n "Try again with a different database name? [Y/N]: "
|
||||
read dbcreatetry
|
||||
if [ "$dbcreatetry" != "Y" -o "$dbcreatetry" != "y" ]
|
||||
if [[ "$dbcreatetry" != "Y" || "$dbcreatetry" != "y" ]]
|
||||
then
|
||||
abort_exit
|
||||
fi
|
||||
@@ -352,7 +357,7 @@ else
|
||||
# Set the installation name
|
||||
export MYSQL_PWD="$db_pass"
|
||||
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_VALUE_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\""
|
||||
if [ "$CONFIG_DEFAULT_COLUMN" != "" ]
|
||||
if [[ "$CONFIG_DEFAULT_COLUMN" != "" ]]
|
||||
then
|
||||
mysql -u"$db_user" $new_db_name -e "update $CONFIG_TABLE set $CONFIG_DEFAULT_COLUMN=\"$new_inst_name\" where $CONFIG_NAME_COLUMN=\"log_name\""
|
||||
fi
|
||||
@@ -361,7 +366,7 @@ else
|
||||
mkdir $install_path
|
||||
|
||||
# Create db.php if it doesn't exist
|
||||
if [ ! -f "$install_path/db.php" ]
|
||||
if [[ ! -f "$install_path/db.php" ]]
|
||||
then
|
||||
cp db.php.template $install_path/db.php
|
||||
sed -i "s/DBNAME/$new_db_name/g" $install_path/db.php
|
||||
@@ -373,11 +378,11 @@ else
|
||||
# copy distribution to install location
|
||||
echo "Installing distribution . . ."
|
||||
cp -R distfiles/* $install_path
|
||||
if [ ! -L "$install_path/jquery-ui" ]
|
||||
if [[ ! -L "$install_path/jquery-ui" ]]
|
||||
then
|
||||
ln -s $install_path/jquery-ui* $install_path/jquery-ui
|
||||
fi
|
||||
if [ ! -L "$install_path/index.php" ]
|
||||
if [[ ! -L "$install_path/index.php" ]]
|
||||
then
|
||||
ln -s $install_path/$LANDING_PAGE $install_path/index.php
|
||||
fi
|
||||
@@ -400,7 +405,12 @@ echo ""
|
||||
echo ""
|
||||
echo "$APP_NAME has been $operation."
|
||||
base_url=$install_loc_in
|
||||
if [ "$operation" = "installed" ]
|
||||
if [[ "$operation" == "upgraded" ]]
|
||||
then
|
||||
a2enconf $base_url
|
||||
systemctl reload apache2
|
||||
fi
|
||||
if [[ "$operation" == "installed" ]]
|
||||
then
|
||||
echo "# $APP_NAME default Apache configuration" > $APACHE_CONF_DIR/$base_url.conf
|
||||
echo "" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
@@ -413,10 +423,10 @@ then
|
||||
echo "</Directory>" >> $APACHE_CONF_DIR/$base_url.conf
|
||||
echo -n "The apache2 $base_url configuration must be enabled. Would you like to do that now? [Y/n] :"
|
||||
read enconf
|
||||
if [ "$enconf" = "" -o "$enconf" = "Y" -o "$enconf" = "y" ]
|
||||
if [[ "$enconf" == "" || "$enconf" == "Y" || "$enconf" == "y" ]]
|
||||
then
|
||||
a2enconf $base_url.conf >/dev/null
|
||||
service apache2 reload
|
||||
systemctl reload apache2
|
||||
echo "You can now point a web browser to $base_url on your web server "
|
||||
echo "to set up and configure $APP_NAME."
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user