You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
#!/bin/bash
. lib/common
set -e
## If no admin-password set, then don't try to pre-initialize database admin_password=$(options-get admin-password 2>/dev/null) || exit 0 admin_email=$(options-get admin-email 2>/dev/null ) || true
CONTROL="$SERVICE_DATASTORE/.control" ## Was it already properly propagated to database ? control=$(H "${admin_password}" "${admin_email}") if [ -e "$CONTROL" ]; then if [ "$control" == "$(cat "$CONTROL")" ]; then exit 0 else err "Changing admin password in compose file not yet supported" exit 1 fi fi
if ! [ -d "$MATOMO_CODE/vendor" ]; then
# XXXvlab: can't get real config here if ! read-0 publish_dir_ts _ _ < <(get_service_relation "$SERVICE_NAME" "publish-dir"); then err "Couldn't find relation ${DARKCYAN}publish-dir${NORMAL}." exit 1 fi publish_dir_relation_dir=$(get_relation_data_dir "$SERVICE_NAME" "$publish_dir_ts" "publish-dir") || { err "Failed to find relation file" exit 1 } publish_dir_relation_config=$(cat "$publish_dir_relation_dir/data") || exit 2 domain=$(e "$publish_dir_relation_config" | shyaml get-value domain) || { err "Couldn't get domain information in ${DARKCYAN}publish-dir${NORMAL} relation's data." exit 1 } url=$(e "$publish_dir_relation_config" | shyaml get-value url) || { err "Couldn't get url information in ${DARKCYAN}publish-dir${NORMAL} relation's data." exit 1 } ## ## Get domain in option of relation "publish-dir" ## container_id=$( for container_id in $(get_running_containers_for_service "$MASTER_BASE_SERVICE_NAME"); do e "$container_id" break done ) docker exec -i "$container_id" bash <<EOF type -p "composer" || { cd /tmp curl -sS https://getcomposer.org/installer | php || { echo "Error occured while attempting to install compose." >&2 exit 1 } mv -v /tmp/composer.phar /usr/local/bin/composer || exit 1 }
cd /var/www/$domain && composer install
EOF
fi
## ## Required wizard ##
if [ "$(crudini --get "$MATOMO_CONFIG_FILE" General installation_in_progress)" == 1 ]; then curl "$url/index.php?action=tablesCreation" >/dev/null || { err "Table creation failed." exit 1 } orig_uid_gid=$(stat --format=%u:%g "$MATOMO_CONFIG_FILE") uid_gid=$(stat --format=%u:%g "$SERVICE_DATASTORE/var/tmp/matomo/index.php") chown "$uid_gid" "$MATOMO_CONFIG_FILE" curl "$url/index.php?action=setupSuperUser" \ --data-urlencode login="admin" \ --data-urlencode password="$admin_password" \ --data-urlencode password_bis="$admin_password" \ --data-urlencode email="${admin_email:-admin@localhost.localnet}" \ --data-urlencode subscribe_newsletter_piwikorg="0" \ --data-urlencode subscribe_newsletter_piwikpro="0" || { err "Setting admin account failed." exit 1 } chown "$orig_uid_gid" "$MATOMO_CONFIG_FILE" crudini --set "$MATOMO_CONFIG_FILE" General installation_in_progress 0
#curl "$url/index.php?action=firstWebsiteSetup" \ # --data-urlencode siteName="$SITE_NAME" \ # --data-urlencode url="$url" \ # --data-urlencode timezone="$(cat /etc/timezone)" \ # --data-urlencode ecommerce="0" || { # err "First Web Site Setup failed." # exit 1 #}
fi
exit 0
|