From 437f499fb427e611f38230d98a42a7d758de049d Mon Sep 17 00:00:00 2001 From: Tom Wiesing Date: Thu, 8 Sep 2022 12:08:16 +0200 Subject: [PATCH] Remove unuused files This commit completes the code porting to go, and removes any old data no longer in use. --- TODO.md | 10 +- distillery/call_update_php_hack.sh | 36 --- distillery/lib/00_init.sh | 58 ---- distillery/lib/10_config.sh | 262 ------------------ distillery/lib/20_sql.sh | 100 ------- distillery/lib/30_slug.sh | 99 ------- distillery/lib/40_templates.sh | 50 ---- distillery/lib/50_utils.sh | 24 -- distillery/lib/lib.sh | 22 -- .../templates/bookkeeping/create.sql | 34 --- .../templates/repository/graphdb-repo.ttl | 57 ---- .../templates/repository/graphdb-user.json | 9 - 12 files changed, 1 insertion(+), 760 deletions(-) delete mode 100755 distillery/call_update_php_hack.sh delete mode 100644 distillery/lib/00_init.sh delete mode 100644 distillery/lib/10_config.sh delete mode 100644 distillery/lib/20_sql.sh delete mode 100644 distillery/lib/30_slug.sh delete mode 100644 distillery/lib/40_templates.sh delete mode 100644 distillery/lib/50_utils.sh delete mode 100644 distillery/lib/lib.sh delete mode 100644 distillery/resources/templates/bookkeeping/create.sql delete mode 100644 distillery/resources/templates/repository/graphdb-repo.ttl delete mode 100644 distillery/resources/templates/repository/graphdb-user.json diff --git a/TODO.md b/TODO.md index 9120b1c..bf994c7 100644 --- a/TODO.md +++ b/TODO.md @@ -28,12 +28,4 @@ Work in progress. - restructure resource files - Documentation - single malt -- snapshots: export xml from pathbuilder - -## Migrating Individual Commands - -- [ ] monday_full.sh -- [ ] monday_short.sh - -## TO BE REMOVED -- [ ] call_update_php_hack.sh +- snapshots: export xml from pathbuilder \ No newline at end of file diff --git a/distillery/call_update_php_hack.sh b/distillery/call_update_php_hack.sh deleted file mode 100755 index cca3e2f..0000000 --- a/distillery/call_update_php_hack.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -set -e - -# read the lib/shared.sh and read the slug argument. -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd "$DIR" -source "$DIR/lib/lib.sh" -require_slug_argument - - -# 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 rebuild it. " - 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" - -log_info " => Enabling 'update.php' access" -docker-compose exec barrel bash /utils/settings_php_set.sh update_free_access true - -log_info " => Calling update.php" - -IP=`docker-compose exec barrel awk 'END{print $1}' /etc/hosts | tr -d '\r'` -URL="http://$IP:8080/update.php/selection" - -# TODO: This should really call update.php sensibly -curl -H "Host: $INSTANCE_DOMAIN" $URL - -log_info "=> Disabling update.php access" -docker-compose exec barrel bash /utils/settings_php_set.sh update_free_access false diff --git a/distillery/lib/00_init.sh b/distillery/lib/00_init.sh deleted file mode 100644 index 72c9c88..0000000 --- a/distillery/lib/00_init.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -set -e - -# This is a library file. -# It should be 'source'd only, if it is not we bail out here. -if [[ "$0" = "$BASH_SOURCE" ]]; then - echo "This file should not be executed directly, it should be 'source'd only. " - exit 1; -fi - -# Check that we are running on a linux system, to prevent accidentally running on Windows or Mac. -# Ideally we would want to explicitly limit to Debian / Ubuntu but at this point that's not needed. -OS="$(uname -s)" -case "${OS}" in - Linux*) :;; - *) echo "This script must be run under Linux. "; exit 1;; -esac - -# To prevent accidentally messing up permissions, we need to always run as root. -# Check that the uid is 0, and otherwise bail out. -if [[ $EUID -ne 0 ]]; then - echo "This script should be run as root, use 'sudo' if in doubt. " - exit 1; -fi - -# We enable shell aliases, to allow us to setup utility functions much more easily. -# To be safe that we don't have any other ones in the environment, we first unalias everything. -unalias -a -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" -} diff --git a/distillery/lib/10_config.sh b/distillery/lib/10_config.sh deleted file mode 100644 index 93600d7..0000000 --- a/distillery/lib/10_config.sh +++ /dev/null @@ -1,262 +0,0 @@ -#!/bin/bash -set -e - -# This is a library file. -# It should be 'source'd only, if it is not we bail out here. -if [[ "$0" = "$BASH_SOURCE" ]]; then - echo "This file should not be executed directly, it should be 'source'd only. " - exit 1; -fi - -# The Path to the configuration file. -CONFIG_FILE="$SCRIPT_DIR/.env" - -# Check that the configuration file exists. -# If it does not, throw an error -log_info " => Reading configuration file" -if ! [ -f "$CONFIG_FILE" ]; then - log_error "" - log_error "Missing configuration, provide a '.env' file" - exit 1 -fi - -# 'source' in the configuration file. -# Ideally we would want to make sure to prevent code-executation within the .env file -# But for the moment let's not. -source "$CONFIG_FILE" - -# Next, validate all the configuration settings. - -# is_valid_slug checks if it's argument is a valid 'slug'. -# A slug is any non-empty string of alphanumeric characters or '-'s. -# The first character of a slug may not be a dash. -function is_valid_slug() { - if [[ "$1" =~ ^[a-zA-Z0-9][-a-zA-Z0-9]*$ ]]; then - return 0; - else - return 1; - fi; -} - -# is_valid_abspath checks if it's argument is an absolute path. -function is_valid_abspath() { - if [[ "$1" =~ ^\/(.+)\/([^/]+)$ ]]; then - return 0; - else - return 1; - fi; -} - -# 'is_valid_domain' checks if a number is a valid domain. -# A domain consists of at least one slug, seperated by '.'s. -# Each token is a slug. -function is_valid_domain() { - if [[ "$1" =~ ^([a-zA-Z0-9][-a-zA-Z0-9]*\.)*[a-zA-Z0-9][-a-zA-Z0-9]*$ ]]; then - return 0; - else - return 1; - fi; -} - -# 'is_valid_domains' is like is_valid_domain, but comma seperated. -function is_valid_domains() { - if [[ ! -z "$1" ]]; then - return 0; - fi - IFS=',' read -ra domains <<< "$1" - for domain in $domains; do - if ! is_valid_domain "$domain"; then - return 1; - fi - done - return 0; -} - -# 'is_valid_number' checks if a value is a valid number. -function is_valid_number() { - if [[ "$1" =~ ^[1-9][0-9]*$ ]]; then - return 0; - else - return 1; - fi; -} - -# 'is_valid_email' checks if a value is a valid email address -function is_valid_email() { - if [[ "$1" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then - return 0; - else - return 1; - fi -} - -# 'is_valid_https_url' checks if a value is a valid url that starts with https -function is_valid_https_url() { - if [[ "$1" =~ ^https:// ]]; then - return 0; - else - return 1; - fi -} - -# 'is_valid_file' checks that the value passed is an existing file -function is_valid_file() { - if [[ -f "$1" ]]; then - return 0; - else - return 1; - fi -} - -# The 'DEPLOY_ROOT' variable must be an absolute path. -if ! is_valid_abspath "$DEPLOY_ROOT"; then - log_error "Variable 'DEPLOY_ROOT' is missing or not a valid path. "; - log_info "Please verify that it is set correctly in '.env'. "; - log_info "Please ensure that it does not end in '/'. "; - exit 1; -fi - -# The 'MYSQL_USER_PREFIX' variable must be a valid slug. -if ! is_valid_slug "$MYSQL_USER_PREFIX"; then - log_error "Variable 'MYSQL_USER_PREFIX' is missing or not a valid slug. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - -# The 'MYSQL_DATABASE_PREFIX' variable must be a valid slug. -if ! is_valid_slug "$MYSQL_DATABASE_PREFIX"; then - log_error "Variable 'MYSQL_DATABASE_PREFIX' is missing or not a valid slug. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - -# The 'DISTILLERY_BOOKKEEPING_DATABASE' variable must be a valid slug. -if ! is_valid_slug "$DISTILLERY_BOOKKEEPING_DATABASE"; then - log_error "Variable 'DISTILLERY_BOOKKEEPING_DATABASE' is missing or not a valid slug. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - -# The 'DISTILLERY_BOOKKEEPING_TABLE' variable must be a valid slug. -if ! is_valid_slug "$DISTILLERY_BOOKKEEPING_TABLE"; then - log_error "Variable 'DISTILLERY_BOOKKEEPING_TABLE' is missing or not a valid slug. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - - -# The 'GRAPHDB_USER_PREFIX' variable must be a valid slug. -if ! is_valid_slug "$GRAPHDB_USER_PREFIX"; then - log_error "Variable 'DATABASE_PREFIX' is missing or not a valid slug. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - -# The 'GRAPHDB_REPO_PREFIX' variable must be a valid slug. -if ! is_valid_slug "$GRAPHDB_REPO_PREFIX"; then - log_error "Variable 'GRAPHDB_REPO_PREFIX' is missing or not a valid slug. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - -# The 'DEFAULT_DOMAIN' variable must be a valid domain. -if ! is_valid_domain "$DEFAULT_DOMAIN"; then - log_error "Variable 'DEFAULT_DOMAIN' is missing or not a valid domain. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - -# The 'SELF_EXTRA_DOMAINS' variable must be a valid domain. -if ! is_valid_domains "$SELF_EXTRA_DOMAINS"; then - log_error "Variable 'SELF_EXTRA_DOMAINS' does not contain comma-separated domains. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - -# set SELF_DOMAIN_SPEC to full list of domains -SELF_DOMAIN_SPEC="$DEFAULT_DOMAIN" -if [ -n "$SELF_EXTRA_DOMAINS" ]; then - SELF_DOMAIN_SPEC="$DEFAULT_DOMAIN,$SELF_EXTRA_DOMAINS" -fi - - -# The 'CERTBOT_EMAIL' variable should either be empty or a valid email -if [ -n "$CERTBOT_EMAIL" ]; then - if ! is_valid_email "$CERTBOT_EMAIL"; then - log_error "Variable 'CERTBOT_EMAIL' is not a valid email address. "; - log_info "Please verify that it is set correctly in '.env' or remove it completly. "; - exit 1; - fi; -fi - -# The 'PASSWORD_LENGTH' variable must be a valid number. -if ! is_valid_number "$PASSWORD_LENGTH"; then - log_error "Variable 'PASSWORD_LENGTH' is missing or not a valid number. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - -# The 'MAX_BACKUP_AGE' variable must be a valid number. -if ! is_valid_number "$MAX_BACKUP_AGE"; then - log_error "Variable 'MAX_BACKUP_AGE' is missing or not a valid number. "; - log_info "Please verify that it is set correctly in '.env'. "; - exit 1; -fi - -# The 'SELF_REDIRECT' variable should either be empty or a valid redirect uri -if [ -n "$SELF_REDIRECT" ]; then - if ! is_valid_https_url "$SELF_REDIRECT"; then - log_error "Variable 'SELF_REDIRECT' is not a valid url. "; - log_info "It should start with https://" - log_info "Please verify that it is set correctly in '.env' or remove it completly. "; - exit 1; - fi; -else - SELF_REDIRECT="https://github.com/FAU-CDI/wisski-distillery" -fi - -# The 'GLOBAL_AUTHORIZED_KEYS_FILE' should point to a real file -if ! is_valid_file "$GLOBAL_AUTHORIZED_KEYS_FILE"; then - log_error "Variable 'GLOBAL_AUTHORIZED_KEYS_FILE' is not a valid file. "; - log_info "The variable is currently set to '$GLOBAL_AUTHORIZED_KEYS_FILE'. " - log_info "You might want to create this file to get rid of the error message. " - log_info "Please verify that it is set correctly in '.env'"; - exit 1; -fi; - -# GRAPHDB_ADMIN_PASSWORD should be the graphdb admin -if [ -z "$GRAPHDB_ADMIN_PASSWORD" ]; then - log_error "Variable 'GRAPHDB_ADMIN_PASSWORD' is not set. "; - log_info "You might want to create this file to get rid of the error message. " - log_info "Please verify that it is set correctly in '.env'"; - exit 1; -fi; - -# The 'SELF_OVERRIDES_FILE' should point to a real json file -if ! is_valid_file "$SELF_OVERRIDES_FILE"; then - log_error "Variable 'SELF_OVERRIDES_FILE' is not a valid file. "; - log_info "The variable is currently set to '$SELF_OVERRIDES_FILE'. " - log_info "You might want to create this file (with contents '{}') to get rid of the error message. " - log_info "Please verify that it is set correctly in '.env'"; - exit 1; -fi; - -# flags for graphdb authorization -GRAPHDB_AUTH_FLAGS="--user $(printf "admin:%s" "$GRAPHDB_ADMIN_PASSWORD")" - -# paths to composer things -DEPLOY_WEB_DIR="$DEPLOY_ROOT/core/web" -DEPLOY_SELF_DIR="$DEPLOY_ROOT/core/self" -DEPLOY_RESOLVER_DIR="$DEPLOY_ROOT/core/resolver" -DEPLOY_PREFIX_CONFIG="$DEPLOY_RESOLVER_DIR/prefix.cfg" -DEPLOY_TRIPLESTORE_DIR="$DEPLOY_ROOT/core/triplestore" -DEPLOY_SQL_DIR="$DEPLOY_ROOT/core/sql" -DEPLOY_SSH_DIR="$DEPLOY_ROOT/core/ssh" -DEPLOY_INSTANCES_DIR="$DEPLOY_ROOT/instances" - -DEPLOY_BACKUP_DIR="$DEPLOY_ROOT/backups" -DEPLOY_BACKUP_INPROGRESS_DIR="$DEPLOY_BACKUP_DIR/inprogress" -DEPLOY_BACKUP_FINAL_DIR="$DEPLOY_BACKUP_DIR/final" - - -log_ok "Read and validated configuration file. " \ No newline at end of file diff --git a/distillery/lib/20_sql.sh b/distillery/lib/20_sql.sh deleted file mode 100644 index 0c21ae6..0000000 --- a/distillery/lib/20_sql.sh +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/bash -set -e - -# This is a library file. -# It should be 'source'd only, if it is not we bail out here. -if [[ "$0" = "$BASH_SOURCE" ]]; then - echo "This file should not be executed directly, it should be 'source'd only. " - exit 1; -fi - -### -### General SQL functions -### - -# wait_for_sql waits for the sql database to be ready -function wait_for_sql() { - log_info "Waiting for database to start ..." - _wait_for_sql_internal - log_ok "Database responded to query " -} - -function _wait_for_sql_internal() { - timeout=30 - times=1 - until dockerized_mysql -e 'show databases;' > /dev/null 2>&1; do - ((times=times+1)) - if [ "$times" -gt $timeout ]; then - log_error "Database timed out after ${timeout} seconds(s). " - fi; - echo -n "." - sleep 1 - done -} - -# 'dockerized_mysql' runs an sql command in the sql docker container -function dockerized_mysql() { - pushd "$DEPLOY_SQL_DIR" > /dev/null - docker exec -i `docker-compose ps -q sql` mysql "$@" - retval=$? - popd > /dev/null - return $retval -} - -# 'dockerized_mysql_interactive' runs an sql command in the sql docker container interactively -function dockerized_mysql_interactive() { - pushd "$DEPLOY_SQL_DIR" > /dev/null - docker exec -ti `docker-compose ps -q sql` mysql "$@" - retval=$? - popd > /dev/null - return $retval -} - -# 'dockerized_mysqldump' runs a mysqldump command -function dockerized_mysqldump() { - pushd "$DEPLOY_SQL_DIR" > /dev/null - docker exec -i `docker-compose ps -q sql` mysqldump "$@" - retval=$? - popd > /dev/null - return $retval -} - -### -### Bookkeeping sql -### - - -# 'sql_bookkeep_exists' checks if a given site already exists -function sql_bookkeep_exists() { - COUNT=$(dockerized_mysql -D "$DISTILLERY_BOOKKEEPING_DATABASE" -e "SELECT COUNT(*) FROM \`$DISTILLERY_BOOKKEEPING_TABLE\` WHERE slug=\"$1\"; " | tail -n +2) - if [ "$COUNT" = "1" ]; then - return 0; - else - return 1; - fi; -} - -# 'sql_bookkeep_insert' inserts a new pair of values into the sql database -function sql_bookkeep_insert() { - dockerized_mysql -D "$DISTILLERY_BOOKKEEPING_DATABASE" -e "INSERT INTO \`$DISTILLERY_BOOKKEEPING_TABLE\`($1) VALUES ($2) ;" -} - -# 'sql_bookkeep_delete' removes a slug into the bookeeping table -function sql_bookeep_delete() { - dockerized_mysql -D "$DISTILLERY_BOOKKEEPING_DATABASE" -e "DELETE FROM \`$DISTILLERY_BOOKKEEPING_TABLE\` WHERE slug=\"$1\";" -} - -# 'sql_bookkeep_load' reads from the bookkeeping table -function sql_bookkeep_load() { - dockerized_mysql -D "$DISTILLERY_BOOKKEEPING_DATABASE" -e "SELECT $2 FROM \`$DISTILLERY_BOOKKEEPING_TABLE\` WHERE slug=\"$1\";" -} - -# 'sql_bookkeep_list' lists all slugs from the bookkeeping table -function sql_bookkeep_list() { - dockerized_mysql -D "$DISTILLERY_BOOKKEEPING_DATABASE" -e "SELECT slug FROM \`$DISTILLERY_BOOKKEEPING_TABLE\`; " | tail -n +2 -} - -# 'sql_bookkeep_list' lists all slugs from the bookkeeping table which should be automatically updated -function sql_bookkeep_list_updateable() { - dockerized_mysql -D "$DISTILLERY_BOOKKEEPING_DATABASE" -e "SELECT slug FROM \`$DISTILLERY_BOOKKEEPING_TABLE\` WHERE auto_blind_update_enabled=1; " | tail -n +2 -} \ No newline at end of file diff --git a/distillery/lib/30_slug.sh b/distillery/lib/30_slug.sh deleted file mode 100644 index 1679365..0000000 --- a/distillery/lib/30_slug.sh +++ /dev/null @@ -1,99 +0,0 @@ -#!/bin/bash -set -e - -# This is a library file. -# It should be 'source'd only, if it is not we bail out here. -if [[ "$0" = "$BASH_SOURCE" ]]; then - echo "This file should not be executed directly, it should be 'source'd only. " - exit 1; -fi - -# This file reads a single slug command line option. -# This is validated when 'require_slug_argument' is called. - -function require_slug_argument() { - # The 'SLUG' argument must be a valid slug. - if ! is_valid_slug "$SLUG"; then - log_error "Argument 'SLUG' is missing or not a valid slug. "; - log_info "Please provide it via the command line. "; - exit 1; - fi - - log_info " => Deriving configuration for '$SLUG'. " - 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. -# We also read it in for scripts where it is not required, and will only use it if that is the case. -SLUG="$1" - -# Compute the domain name for this instance. -# Also lowercase the domain name for consistency. -function compute_instance_domain() { - INSTANCE_DOMAIN="$1.$DEFAULT_DOMAIN" - INSTANCE_DOMAIN="$(echo "$INSTANCE_DOMAIN" | tr '[:upper:]' '[:lower:]')" - echo "$INSTANCE_DOMAIN" -} -INSTANCE_DOMAIN="$(compute_instance_domain "$SLUG")" - -# compute the url pointing to an instance -function compute_instance_url() { - if [ -n "$CERTBOT_EMAIL" ]; then - echo -n "https://" - else - echo "http://" - fi - compute_instance_domain "$@" -} - -# Next we need a username base. -# This will be used as a username across the system (linux), MySQL and GraphDB. -# For this we can only allow [0-9a-zA-Z-], hence we have to escape. -# In most cases, the only characters that require escaping are '.'s. -# Hence we replace '.' with '-'s. -# We replace the other two characters that require escaping (_ and -)s with --u and --s respectively. -# Because no two dots can ever follow each other in the INSTANCE_DOMAIN, this is guaranteed collision free. -# We also have to do the '-' replacement first, to prevent escaped other characters from being escaped twice. -USERNAME_BASE="$SLUG" -USERNAME_BASE="${USERNAME_BASE//-/--d}" -USERNAME_BASE="${USERNAME_BASE//_/--u}" -USERNAME_BASE="${USERNAME_BASE//./-}" - -# Generate the user and database names for the various systems -MYSQL_USER="${MYSQL_USER_PREFIX}${USERNAME_BASE}" -MYSQL_DATABASE="${MYSQL_DATABASE_PREFIX}${USERNAME_BASE}" -GRAPHDB_USER="${GRAPHDB_USER_PREFIX}${USERNAME_BASE}" -GRAPHDB_REPO="${GRAPHDB_REPO_PREFIX}${USERNAME_BASE}" - -# Compute the base directory for the files that will live on disk. -INSTANCE_BASE_DIR="$DEPLOY_INSTANCES_DIR/$INSTANCE_DOMAIN" -INSTANCE_DATA_DIR="$INSTANCE_BASE_DIR/data/" - -# compute the prefix file -function compute_instance_prefixfile() { - INSTANCE_BASE_DIR="$1" - INSTANCE_PREFIX_FILE="$INSTANCE_BASE_DIR/prefixes" - echo "$INSTANCE_PREFIX_FILE" -} -INSTANCE_PREFIX_FILE="$(compute_instance_prefixfile "$INSTANCE_BASE_DIR" )" - -# compute the prefix file -function compute_instance_noprefixfile() { - INSTANCE_BASE_DIR="$1" - INSTANCE_PREFIX_FILE="$INSTANCE_BASE_DIR/prefixes.skip" - echo "$INSTANCE_PREFIX_FILE" -} -INSTANCE_NOPREFIX_FILE="$(compute_instance_noprefixfile "$INSTANCE_BASE_DIR" )" - -if [ -n "$CERTBOT_EMAIL" ]; then - LETSENCRYPT_HOST="$INSTANCE_DOMAIN" - LETSENCRYPT_EMAIL="$CERTBOT_EMAIL" -fi; - diff --git a/distillery/lib/40_templates.sh b/distillery/lib/40_templates.sh deleted file mode 100644 index 3eb39a2..0000000 --- a/distillery/lib/40_templates.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -set -e -shopt -s dotglob - -# This is a library file. -# It should be 'source'd only, if it is not we bail out here. -if [[ "$0" = "$BASH_SOURCE" ]]; then - echo "This file should not be executed directly, it should be 'source'd only. " - exit 1; -fi - -RESOURCE_DIR="$SCRIPT_DIR/resources" -TEMPLATE_DIR="$RESOURCE_DIR/templates/" - -# load_template will load a template $1 from the template directory -# and replace ${$2} with $3, ${$4} with $5 etc. -# echoes out the replaced template -function load_template() { - # read the template then remove the argument - TEMPLATE=`cat "$TEMPLATE_DIR/$1"` - shift 1; - - # while we have a variable to substiute - while [ ! -z "$1" ] - do - # do the substitution - TEMPLATE="${TEMPLATE//\$\{$1\}/$2}" - shift 2 - done; - - # finally echo out the template - echo "$TEMPLATE" -} - -# install_resource_dir will copy over a resource directory -# to a destination path recursively. -function install_resource_dir() { - from="$RESOURCE_DIR/$1" - to=$2 - - # copythe template files - for filename in "$from"/*; do - dest="$to/`basename "${filename}"`" - echo "Writing \"$dest\"" - cp -rTv "$filename" "$dest" - done -} - -# path where common apache files will be installed. -WISSKI_COMMON_PATH="/etc/apache2/conf/wisski" \ No newline at end of file diff --git a/distillery/lib/50_utils.sh b/distillery/lib/50_utils.sh deleted file mode 100644 index 443235c..0000000 --- a/distillery/lib/50_utils.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -set -e - -# This is a library file. -# It should be 'source'd only, if it is not we bail out here. -if [[ "$0" = "$BASH_SOURCE" ]]; then - echo "This file should not be executed directly, it should be 'source'd only. " - exit 1; -fi - -# Set a few variables to point to the debian frontend -export DEBIAN_FRONTEND=noninteractive - -# This file just sets a few utility functions to be used by the code. -# randompw generates a random password as per the configuration file. -alias randompw="cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $PASSWORD_LENGTH | head -n 1" - -# update_stack fully updates a docker-compose stack in the given location. -function update_stack() { - cd "$1" - docker-compose pull - docker-compose build --pull - docker-compose up -d -} \ No newline at end of file diff --git a/distillery/lib/lib.sh b/distillery/lib/lib.sh deleted file mode 100644 index 9cd017a..0000000 --- a/distillery/lib/lib.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -set -e - -# This file will load all the library functions needed by the various scripts. -# It should be 'source'd only, if it is not we bail out here. -if [[ "$0" = "$BASH_SOURCE" ]]; then - echo "This file should not be executed directly, it should be 'source'd only. " - exit 1; -fi - -# Set variables for the script_dir and the lib_dir -SCRIPT_DIR="$(pwd)" -LIB_DIR="$SCRIPT_DIR/lib" - -# Next, we load a bunch of utility functions stored in lib/lib__.sh -# These contain functionality used in the various scripts. -source "$LIB_DIR/00_init.sh"; -source "$LIB_DIR/10_config.sh"; -source "$LIB_DIR/20_sql.sh"; -source "$LIB_DIR/30_slug.sh"; -source "$LIB_DIR/40_templates.sh"; -source "$LIB_DIR/50_utils.sh"; diff --git a/distillery/resources/templates/bookkeeping/create.sql b/distillery/resources/templates/bookkeeping/create.sql deleted file mode 100644 index 0956a0e..0000000 --- a/distillery/resources/templates/bookkeeping/create.sql +++ /dev/null @@ -1,34 +0,0 @@ --- create the database if it doesn't exist yet -CREATE DATABASE IF NOT EXISTS `${DATABASE}`; - --- use the database we just created -USE `${DATABASE}`; - --- create the bookkeeping table -CREATE TABLE IF NOT EXISTS `${TABLE}`( - -- automatically created fields - pk INT NOT NULL PRIMARY KEY AUTO_INCREMENT, - created DATETIME DEFAULT CURRENT_TIMESTAMP, - - -- slug of the website - slug TEXT NOT NULL UNIQUE, - - -- email address of owner, NULL if abndoned - owner_email VARCHAR(320), - - -- automatically call blind_update.sh for this repo - auto_blind_update_enabled BIT NOT NULL DEFAULT 1, - - -- local file path - filesystem_base TEXT NOT NULL, - - -- sql access credentials - sql_database TEXT NOT NULL, - sql_user TEXT NOT NULL, - sql_password TEXT NOT NULL, - - -- graphdb credentials - graphdb_repository TEXT NOT NULL, - graphdb_user TEXT NOT NULL, - graphdb_password TEXT NOT NULL -); \ No newline at end of file diff --git a/distillery/resources/templates/repository/graphdb-repo.ttl b/distillery/resources/templates/repository/graphdb-repo.ttl deleted file mode 100644 index 88c96ae..0000000 --- a/distillery/resources/templates/repository/graphdb-repo.ttl +++ /dev/null @@ -1,57 +0,0 @@ -# This file is used to initialize a new GraphDB repository. -# In this file the variables ${GRAPHDB_REPO} and ${INSTANCE_DOMAIN} will be replaced. -# All other variables will be left untouched. - -@prefix rdfs: . -@prefix rep: . -@prefix sr: . -@prefix sail: . -@prefix owlim: . - -[] a rep:Repository ; - rep:repositoryID "${GRAPHDB_REPO}" ; - rdfs:label "${INSTANCE_DOMAIN}" ; - rep:repositoryImpl [ - rep:repositoryType "graphdb:SailRepository" ; - sr:sailImpl [ - sail:sailType "graphdb:Sail" ; - - owlim:owlim-license "" ; - - owlim:base-URL "http://${INSTANCE_DOMAIN}/" ; - owlim:defaultNS "" ; - owlim:entity-index-size "10000000" ; - owlim:entity-id-size "32" ; - owlim:imports "" ; - owlim:repository-type "file-repository" ; - owlim:ruleset "empty" ; - owlim:storage-folder "storage" ; - - owlim:enable-context-index "false" ; - owlim:cache-memory "80m" ; - owlim:tuple-index-memory "80m" ; - - owlim:enablePredicateList "false" ; - owlim:predicate-memory "0%" ; - - owlim:fts-memory "0%" ; - owlim:ftsIndexPolicy "never" ; - owlim:ftsLiteralsOnly "true" ; - - owlim:in-memory-literal-properties "false" ; - owlim:enable-literal-index "true" ; - owlim:index-compression-ratio "-1" ; - - owlim:check-for-inconsistencies "false" ; - owlim:disable-sameAs "false" ; - owlim:enable-optimization "true" ; - owlim:transaction-mode "safe" ; - owlim:transaction-isolation "true" ; - owlim:query-timeout "0" ; - owlim:query-limit-results "0" ; - owlim:throw-QueryEvaluationException-on-timeout "false" ; - owlim:useShutdownHooks "true" ; - owlim:read-only "false" ; - owlim:nonInterpretablePredicates "http://www.w3.org/2000/01/rdf-schema#label;http://www.w3.org/1999/02/22-rdf-syntax-ns#type;http://www.ontotext.com/owlim/ces#gazetteerConfig;http://www.ontotext.com/owlim/ces#metadataConfig" ; - ] - ]. \ No newline at end of file diff --git a/distillery/resources/templates/repository/graphdb-user.json b/distillery/resources/templates/repository/graphdb-user.json deleted file mode 100644 index e0fd8f5..0000000 --- a/distillery/resources/templates/repository/graphdb-user.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "username": "${GRAPHDB_USER}", - "grantedAuthorities": [ - "ROLE_USER", - "READ_REPO_${GRAPHDB_REPO}", - "WRITE_REPO_${GRAPHDB_REPO}" - ], - "password": "${GRAPHDB_PASSWORD}" -}