This repository contains different infrastructure components, CI/CD pipelines, automation tools among other resources that are used in different projects here at NaN Labs.
MIT License
44
stars
16
forks
source link
Check if it's possible to pipe output directly to sqlcmd (checked -i -, however... #29
set -e
INITDB_FOLDER="/opt/mssql-scripts"
TMP_DIR="/tmp"
function sqlcmd() {
file=${1?"Sql file must be provided as a parameter"}
/opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P "${SA_PASSWORD}" -i "${file}"
echo "$file imported successfully"
}
function initialize_app_database() {
# Restore the application database using .sql files
shopt -s globstar nullglob
for file in "$INITDB_FOLDER"/*.sql; do
sqlcmd "$file"
done
# Restore the application database using .sql.gz files
shopt -s globstar nullglob
for file in "$INITDB_FOLDER"/*.sql.gz; do
echo "Uncompressing $file to $TMP_DIR"
filename=$(basename "$file")
uncompressed_file="$TMP_DIR/${filename//.gz/}"
# TODO Check if it's possible to pipe output directly to sqlcmd (checked -i -, however it didn´t seem to be supported ). as an alternative mkfifo can be reviewed as well
gunzip --keep --stdout "$file" > "$uncompressed_file"
sqlcmd "$uncompressed_file"
done
# Restore the application database using .sh files
shopt -s globstar nullglob
for file in "$INITDB_FOLDER"/*.sh; do
echo "Importing $file"
if [ -x "$file" ]; then
"$file"
https://github.com/nanlabs/infra-reference/blob/f129254bb893310107de4529419c8e57e85b2b66/examples/docker/mssql/entrypoint.sh#L27
┆Issue is synchronized with this Clickup task by Unito