diff --git a/README.md b/README.md index b48093e..d8a294f 100644 --- a/README.md +++ b/README.md @@ -165,7 +165,16 @@ To use it, run: sudo bash /factory/purge.sh SLUG ``` -To ensure +## Open a shell -- 'shell.sh' + +Sometimes manual changes to a given WissKI instance are required. +For this purpose, you can use: + +```bash +sudo bash /factory/shell.sh SLUG +``` + +This will open a shell in the provided WissKI instance. ## License diff --git a/distillery/lib/00_init.sh b/distillery/lib/00_init.sh index dbb31dd..72c9c88 100644 --- a/distillery/lib/00_init.sh +++ b/distillery/lib/00_init.sh @@ -30,32 +30,29 @@ shopt -s expand_aliases # Setup some basic input/output functions function log_info() { + if [ -n "$DISABLE_LOG" ]; then + return; + fi echo -e "\033[1m$1\033[0m" } function log_ok() { + if [ -n "$DISABLE_LOG" ]; then + return; + fi echo -e "\033[0;32m$1\033[0m" } function log_warn() { + if [ -n "$DISABLE_LOG" ]; then + return; + fi echo -e "\033[1;33m$1\033[0m" } function log_error() { + if [ -n "$DISABLE_LOG" ]; then + return; + fi echo -e "\033[0;31m$1\033[0m" } - -if [ -n "$DISABLE_LOG" ]; then - function log_info() { - true - } - function log_ok() { - true - } - function log_warn() { - true - } - function log_error() { - true - } -fi \ No newline at end of file diff --git a/distillery/lib/30_slug.sh b/distillery/lib/30_slug.sh index 15871ad..66831da 100644 --- a/distillery/lib/30_slug.sh +++ b/distillery/lib/30_slug.sh @@ -20,12 +20,14 @@ function require_slug_argument() { fi log_info " => Deriving configuration for '$SLUG'. " - echo "Domain Name: $INSTANCE_DOMAIN" - echo "Base Directory: $INSTANCE_BASE_DIR" - echo "MySQL User: $MYSQL_USER" - echo "MySQL Database: $MYSQL_DATABASE" - echo "GraphDB User: $GRAPHDB_USER" - echo "GraphDB Repository: $GRAPHDB_REPO" + if [ ! -n "DISABLE_LOG" ]; then + echo "Domain Name: $INSTANCE_DOMAIN" + echo "Base Directory: $INSTANCE_BASE_DIR" + echo "MySQL User: $MYSQL_USER" + echo "MySQL Database: $MYSQL_DATABASE" + echo "GraphDB User: $GRAPHDB_USER" + echo "GraphDB Repository: $GRAPHDB_REPO" + fi } # Read the slug argument. diff --git a/distillery/shell.sh b/distillery/shell.sh new file mode 100644 index 0000000..0c7e91c --- /dev/null +++ b/distillery/shell.sh @@ -0,0 +1,26 @@ +# To install a new system: +set -e + +# read the lib/shared.sh and read the slug argument. +DISABLE_LOG=1 +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +cd "$DIR" +source "$DIR/lib/lib.sh" +require_slug_argument +DISABLE_LOG=0 + +# if the site doesn't exist, I can't open a shell. +if ! sql_bookkeep_exists "$SLUG"; then + log_error "=> Site '$SLUG' does not exist in bookeeping table. " + echo "I can't open a shell there. " + exit 1 +fi; + +# Read everything from the database +read -r INSTANCE_BASE_DIR MYSQL_DATABASE MYSQL_USER GRAPHDB_REPO GRAPHDB_USER <<< "$(sql_bookkeep_load "${SLUG}" "filesystem_base,sql_database,sql_user,graphdb_repository,graphdb_user" | tail -n +2)" + +# cd into the right directory +cd "$INSTANCE_BASE_DIR" + +# and open a www-data shell +docker-compose exec runtime /bin/bash -c "cd /var/www/data/project; sudo -u www-data /bin/bash"