69 lines
1.4 KiB
Bash
Executable File
69 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
FORCE=FALSE
|
|
|
|
usage() {
|
|
echo "Usage: $0 [-f] [environment]"
|
|
exit 1
|
|
}
|
|
|
|
while getopts ":f" option
|
|
do
|
|
case $option in
|
|
f)
|
|
FORCE=TRUE
|
|
;;
|
|
\?|:)
|
|
usage
|
|
;;
|
|
esac
|
|
done
|
|
|
|
shift $(($OPTIND - 1))
|
|
|
|
ENV=$1
|
|
|
|
if [ "$ENV" == "production" ]; then
|
|
echo ""
|
|
echo " ( ( ) ( ( ) ) "
|
|
echo " )\ ))\ ) ( /( )\ ) ( * ))\ ) ( /( ( /( "
|
|
echo "(()/(()/( )\()|()/( ( )\ ) /(()/( )\()) )\())"
|
|
echo " /(_))(_)|(_)\ /(_)) )\ (((_) ( )(_))(_)|(_)\ ((_)\ "
|
|
echo "(_))(_)) ((_|_))_ _ ((_))\___(_(_()|_)) ((_) _((_)"
|
|
echo "| _ \ _ \ / _ \| \| | | ((/ __|_ _|_ _| / _ \| \| |"
|
|
echo "| _/ /| (_) | |) | |_| || (__ | | | | | (_) | . |"
|
|
echo "|_| |_|_\ \___/|___/ \___/ \___| |_| |___| \___/|_|\_|"
|
|
echo ""
|
|
|
|
if [ "$FORCE" != "TRUE" ]; then
|
|
read -p "Are you sure? (Default: no) [yes|no]: " ANSWER
|
|
|
|
if [ "$ANSWER" != "yes" ]; then
|
|
echo "Aborting"
|
|
exit;
|
|
fi
|
|
fi
|
|
fi
|
|
if [ -z "$ENV" ]; then
|
|
ENV="test"
|
|
fi
|
|
|
|
DIR="$(dirname "${BASH_SOURCE[0]}")"
|
|
INI_FILE="$DIR/config.$ENV.ini"
|
|
|
|
if [ ! -f "$INI_FILE" ]; then
|
|
echo "Config file doesn't exists: $INI_FILE"
|
|
exit 2
|
|
fi
|
|
|
|
echo "[INFO] Config file: $INI_FILE"
|
|
echo "[INFO] Applying changes"
|
|
|
|
# Import changes
|
|
|
|
for file in $DIR/install/changes/*.sql; do
|
|
echo "[INFO] -> $file"
|
|
mysql --defaults-file="$INI_FILE" < $file
|
|
done
|
|
|