forked from 0k/0k-charms
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.
95 lines
2.7 KiB
95 lines
2.7 KiB
# -*- mode: shell-script -*-
|
|
|
|
MATOMO_DIR="/opt/apps/matomo"
|
|
MATOMO_CODE="$SERVICE_CONFIGSTORE$MATOMO_DIR"
|
|
MATOMO_RELEASE=4.16.0
|
|
MATOMO_URL=https://github.com/matomo-org/matomo/archive/"${MATOMO_RELEASE}".tar.gz
|
|
#MATOMO_URL=https://docker.0k.io/downloads/matomo-"${MATOMO_RELEASE}".tar.gz
|
|
MATOMO_CONFIG_FILE="${MATOMO_CODE}"/config/config.ini.php
|
|
|
|
|
|
matomo:init() {
|
|
current_version=""
|
|
if [ -d "${MATOMO_CODE}" ]; then
|
|
current_version=$(cat "${MATOMO_CODE}"/.version) || {
|
|
err "Couldn't find ${MATOMO_CODE}/.version file."
|
|
echo " Your config dir is in a broken state." >&2
|
|
return 1
|
|
}
|
|
else
|
|
mkdir -p "${MATOMO_CODE}" &&
|
|
cd "${MATOMO_CODE}" &&
|
|
git init . &&
|
|
git config user.email "root@localhost" &&
|
|
git config user.name "Root" || {
|
|
err "Couldn't create directory ${MATOMO_CODE}, or init it with git."
|
|
return 1
|
|
}
|
|
fi
|
|
if [ "$current_version" != "$MATOMO_RELEASE" ]; then
|
|
cd "${MATOMO_CODE}" || return 1
|
|
[ -d "$MATOMO_CODE"/.git ] || {
|
|
err "Can't find the '.git' directory in ${MATOMO_CODE}."
|
|
return 1
|
|
}
|
|
|
|
rm -rf "$MATOMO_CODE"/* "$MATOMO_CODE"/{.version,.inited-*} || return 1
|
|
|
|
curl -L "$MATOMO_URL" | tar xzv || {
|
|
#if [ -f "$MATOMO_URL" ]; then
|
|
# git checkout HEAD
|
|
#else
|
|
# rmdir "$MATOMO_URL"
|
|
#fi
|
|
err "Couldn't download $MATOMO_URL."
|
|
return 1
|
|
}
|
|
mv matomo-*/* matomo-*/{.bowerrc,.lfsconfig} . && rmdir matomo-*
|
|
echo "$MATOMO_RELEASE" > .version
|
|
git add -A . &&
|
|
git commit -m "Release $MATOMO_RELEASE"
|
|
fi
|
|
}
|
|
|
|
|
|
matomo:config() {
|
|
[ -f "$MATOMO_CONFIG_FILE" ] || {
|
|
cat <<EOF > "$MATOMO_CONFIG_FILE"
|
|
; <?php exit; ?> DO NOT REMOVE THIS LINE
|
|
; file automatically generated or modified by Matomo; you can manually override the default values in global.ini.php by redefining them in this file.
|
|
EOF
|
|
}
|
|
crudini --get "$MATOMO_CONFIG_FILE" General salt >dev/null || {
|
|
salt=$(dd if=/dev/urandom bs=1 count=16 2>/dev/null | hexdump -v -e '/1 "%02x"')
|
|
crudini --set "$MATOMO_CONFIG_FILE" General salt \"$salt\"
|
|
crudini --set "$MATOMO_CONFIG_FILE" General installation_in_progress 1
|
|
}
|
|
|
|
}
|
|
|
|
|
|
matomo:curl() {
|
|
local url="$1"
|
|
curl "$url"
|
|
|
|
}
|
|
|
|
|
|
# matomo:wizard() {
|
|
|
|
# PAGES=(
|
|
# "systemCheck"
|
|
# "databaseSetup"
|
|
# "tablesCreation"
|
|
# "setupSuperUser"
|
|
# "setupSuperUser"
|
|
# "firstWebsiteSetup"
|
|
# "firstWebsiteSetup"
|
|
# "trackingCode"
|
|
# "finished"
|
|
# )
|
|
|
|
# matomo:curl
|
|
|
|
|
|
# }
|