From 3f0038eed2c87b3036a7211e1f627c910bd6cc82 Mon Sep 17 00:00:00 2001 From: David Trattnig <david.trattnig@o94.at> Date: Mon, 27 Apr 2020 18:17:54 +0200 Subject: [PATCH] Generalized lock. --- install.sh | 53 +++++++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/install.sh b/install.sh index 2da2c758..dc805f5d 100755 --- a/install.sh +++ b/install.sh @@ -32,7 +32,7 @@ python3.7 $(which pip3) install -r requirements.txt if [ $mode == "dev" ]; then # Set LOCK file location - LOCKFILE_DB=configuration/.engine.install-mariadb.lock + LOCKFILE_DB=configuration/.engine.install-db.lock echo "Create local Logs Folder ..." mkdir -p logs @@ -46,7 +46,7 @@ fi if [ $mode == "prod" ]; then # Set LOCK file location - LOCKFILE_DB=/etc/aura/.engine.install-mariadb.lock + LOCKFILE_DB=/etc/aura/.engine.install-db.lock if getent passwd 'engineuser' > /dev/null 2>&1; then echo "User 'engineuser' exists already."; @@ -77,29 +77,34 @@ fi # Setup Database +# Check if databases are already set-up +if test -f "$LOCKFILE_DB"; then + echo "Aura Engine Databases are already existing! Skipping..." +else + echo "Setting up database ..." + echo + echo "Which database system do you want to use? (Press '1' or '2')" + echo " [1] MariaDB" + echo " [2] Other / Manually" + echo + + while true; do + read -rsn1 input + if [ "$input" = "1" ]; then + echo "Creating DB for MariaDB ..." + bash script/init-db-mariadb.sh + break + fi + if [ "$input" = "2" ]; then + echo "Manual database setup selected." + break + fi + done -echo "Setting up database ..." -echo -echo "Which database system do you want to use? (Press '1' or '2')" -echo " [1] MariaDB" -echo " [2] Other / Manually" -echo - -while true; do -read -rsn1 input -if [ "$input" = "1" ]; then - echo "Creating DB for MariaDB ..." - bash script/init-db-mariadb.sh - break -fi -if [ "$input" = "2" ]; then - echo "Manual database setup selected." - break + # Create lockfile to avoid accidential re-creation of the database + touch $LOCKFILE_DB fi -done - # Create lockfile to avoid accidential re-creation of the database - touch $LOCKFILE_DB - echo -echo "+++ Installation of AURA Engine finished! +++" \ No newline at end of file +echo "+++ Installation of AURA Engine finished! +++" +echo \ No newline at end of file -- GitLab