DB import script fixes
gitea/salix/dev This commit looks good
Details
gitea/salix/dev This commit looks good
Details
This commit is contained in:
parent
2c29ee2090
commit
0b560e1749
|
@ -1,5 +1,26 @@
|
|||
#!/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
|
||||
|
@ -14,6 +35,7 @@ if [ "$ENV" == "production" ]; then
|
|||
echo "|_| |_|_\ \___/|___/ \___/ \___| |_| |___| \___/|_|\_|"
|
||||
echo ""
|
||||
|
||||
if [ "$FORCE" != "TRUE" ]; then
|
||||
read -p "Are you sure? (Default: no) [yes|no]: " ANSWER
|
||||
|
||||
if [ "$ANSWER" != "yes" ]; then
|
||||
|
@ -21,6 +43,7 @@ if [ "$ENV" == "production" ]; then
|
|||
exit;
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
if [ -z "$ENV" ]; then
|
||||
ENV="test"
|
||||
fi
|
||||
|
@ -28,15 +51,16 @@ fi
|
|||
INI_FILE="config.$ENV.ini"
|
||||
|
||||
if [ ! -f "$INI_FILE" ]; then
|
||||
echo "File $INI_FILE doesn't exists"
|
||||
exit 1
|
||||
echo "Config file doesn't exists: $INI_FILE"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
echo "[INFO] Config file: $INI_FILE"
|
||||
echo "[INFO] Importing changes."
|
||||
echo "[INFO] Applying changes"
|
||||
|
||||
# Import changes
|
||||
for file in install/changes/*.sql; do
|
||||
echo "[INFO] -> Applying $file"
|
||||
echo "[INFO] -> $file"
|
||||
mysql --defaults-file="$INI_FILE" < $file
|
||||
done
|
||||
|
||||
|
|
Loading…
Reference in New Issue