2023-08-02 20:59:59 +00:00
|
|
|
#! /bin/sh
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
# Create flat file
|
|
|
|
echo "Hello" > /data/test.txt
|
|
|
|
|
|
|
|
# Create Sqlite database
|
|
|
|
touch /data/test_database.db
|
|
|
|
sqlite3 /data/test_database.db <<-EOF
|
|
|
|
CREATE TABLE test_table (
|
2023-08-02 22:05:04 +00:00
|
|
|
id INTEGER PRIMARY KEY,
|
|
|
|
data TEXT NOT NULL
|
2023-08-02 20:59:59 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO test_table(data)
|
|
|
|
VALUES ("Test row");
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Create MySql database
|
|
|
|
until mysql --host "$MYSQL_HOST" --user "$MYSQL_USER" --password="$MYSQL_PWD" --execute "SHOW DATABASES;"; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
mysql --host "$MYSQL_HOST" --user "$MYSQL_USER" --password="$MYSQL_PWD" main <<EOF
|
|
|
|
CREATE TABLE test_table (
|
2023-08-02 22:05:04 +00:00
|
|
|
id INTEGER AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
data TEXT NOT NULL
|
2023-08-02 20:59:59 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO test_table(data)
|
|
|
|
VALUES ("Test row");
|
|
|
|
EOF
|
2023-08-02 22:05:04 +00:00
|
|
|
|
|
|
|
# Create Postgres database
|
|
|
|
export PGPASSWORD="$PGSQL_PASS"
|
|
|
|
until psql --host "$PGSQL_HOST" --username "$PGSQL_USER" --command "SELECT datname FROM pg_database;"; do
|
|
|
|
sleep 1
|
|
|
|
done
|
|
|
|
psql -v ON_ERROR_STOP=1 --host "$PGSQL_HOST" --username "$PGSQL_USER" main <<EOF
|
|
|
|
CREATE TABLE test_table (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
data TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO test_table(data)
|
|
|
|
VALUES ('Test row');
|
|
|
|
EOF
|