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