#!/bin/bash

#=====================================================================#
# 																	  #
# Shell script to fix the rights after a ModX Revo Instance Update	  #
# Published under Creative Commons License							  #
# 																	  #
# Author: Claudine WEBER											  #
# Email: claudine.weber@gmail.com									  #
# Website: www.claudine-weber.lu									  #
# 																	  #
# Created: 15.11.2011												  #
# 																	  #
# Modified: 														  #
# Version: 1.0														  #
# 																	  #
#=====================================================================#

# Variable declarations. These variables have a global scope as we don't use functions
CORE_DIR=core
CONF_DIR=config
CONF_FILE=config.inc.php

# Text output colors
txtred=$(tput setaf 1) #red
txtgrn=$(tput setaf 2) #green
txtylw=$(tput setaf 3) #yellow
txtblu=$(tput setaf 4) #blue
txtrst=$(tput sgr0) #reset to default

echo "${txtblu}"
echo -e "#####################################################################"
echo -e "#                                                                   #"
echo -e "# Shell script to fix the rights after a ModX Revo Instance Update  #"
echo -e "# Published under Creative Commons License                          #"
echo -e "#                                                                   #"
echo -e "# Author: Claudine WEBER                                            #"
echo -e "# Email: claudine.weber@gmail.com                                   #"
echo -e "# Website: www.claudine-weber.lu                                    #"
echo -e "#                                                                   #"
echo -e "# Created: 15.11.2011                                               #"
echo -e "#                                                                   #"
echo -e "# Modified:                                                         #"
echo -e "# Version: 1.0                                                      #"
echo -e "#                                                                   #"
echo -e "#####################################################################"
echo "${txtrst}"


#=============MOVING REQUIRED FILES AND FOLDERS INTO PLACE=============#
# Moving the configuration file into place
echo -e "Changing the rights of \"$CONF_FILE\" in \"$CORE_DIR/$CONF_DIR/\" ... "
if [ -e $CORE_DIR/$CONF_DIR/$CONF_FILE ]
	then
		chmod 644 $CORE_DIR/$CONF_DIR/$CONF_FILE
		echo -e "${txtylw}The rights for the file \"$CONF_FILE\" have been successfully updated!\n${txtrst}"
	else
		echo -e "${txtred}Ups ... I couldn't find the file \"$CONF_FILE\" in \"$CORE_DIR/$CONF_DIR\"!\n${txtrst}"
fi


#============================FINAL MESSAGE=============================#
echo -e "${txtgrn}"
echo -e "#####################################################################"
echo -e "#   Thank you for using MUS - my ModX Revo Rights Update Script!    #"
echo -e "#                                                                   #"
echo -e "# All files and folders are up to date.                             #"
echo -e "# Your installation is secure.                                      #"
echo -e "#                                                                   #"
echo -e "# For further questions, please contact me using the form on my     #"
echo -e "# website: www.claudine-weber.lu or by sending an email to          #"
echo -e "# info@claudine-weber.lu                                            #"
echo -e "#                                                                   #"
echo -e "#####################################################################"
echo -e "${txtrst}"

