Add shell.sh

This commit is contained in:
Tom Wiesing 2020-07-07 12:13:28 +02:00
parent e63c393216
commit 85a717274c
No known key found for this signature in database
GPG key ID: DC1F29F2BC78AB15
4 changed files with 56 additions and 22 deletions

26
distillery/shell.sh Normal file
View file

@ -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"