<commit_before># Salt formula for installing piwik
#
# This state requires some database setup. Either copy the database from an
# existing instance, or use the install wizard at:
# http://mon.opendataservices.coop/piwik/

include:
  - apache
  - php


# Download Piwik from the git repository but pick a tag for a stable release
https://github.com/piwik/piwik.git:
  git.latest:
    - rev: 3.0.1
    - target: /var/www/html/piwik/
    - submodules: True
# Upstream piwik routinely rewrites history in their git repo, so we'll set
# this permanently
    - force_fetch: True


# PHP deps

{% if grains['lsb_distrib_release']=='14.04' %}
  {% set phpver='5' %}
{% else %}
  {% set phpver='7.0' %}
{% endif %}

php{{ phpver }}-cli:
  pkg.installed

php{{ phpver }}-mysql:
  pkg.installed:
    - watch_in:
      - service: apache2

php{{ phpver }}-gd:
  pkg.installed:
    - watch_in:
      - service: apache2


# Install composer (PHP package manager),
# see http://docs.saltstack.com/en/latest/ref/states/all/salt.states.composer.html

curl:
  pkg.installed

get-composer:
  cmd.run:
    - name: 'curl -s -S https://getcomposer.org/installer | php'
    - unless: test -f /usr/local/bin/composer
    - cwd: /root/
    - require:
      - pkg: php{{ phpver }}-cli
      - pkg: curl

install-composer:
  cmd.wait:
    - name: mv /root/composer.phar /usr/local/bin/composer
    - cwd: /root/
    - watch:
      - cmd: get-composer

# Install piwik's dependencies
/var/www/html/piwik/:
  composer.installed:
    - no_dev: true
    - require:
      - cmd: install-composer

/var/www/html/piwik/tmp:
  file.directory:
    - user: www-data
    - group: www-data
    # Uncommented because the git state often fails for me due to
    # https://github.com/saltstack/salt/issues/22514
    #- require:
    #  - git: https://github.com/piwik/piwik.git

/var/www/html/piwik/config:
  file.directory:
    - user: www-data
    - group: www-data
    - recurse:
      - user
      - group

mysql-server:
  pkg.installed

salt-deps:
  pkg.installed:
    - pkgs:
      - python-mysqldb

piwik:
  mysql_user.present:<commit_msg>Install php geoip module for piwik<commit_after># Salt formula for installing piwik
#
# This state requires some database setup. Either copy the database from an
# existing instance, or use the install wizard at:
# http://mon.opendataservices.coop/piwik/

include:
  - apache
  - php


# Download Piwik from the git repository but pick a tag for a stable release
https://github.com/piwik/piwik.git:
  git.latest:
    - rev: 3.0.1
    - target: /var/www/html/piwik/
    - submodules: True
# Upstream piwik routinely rewrites history in their git repo, so we'll set
# this permanently
    - force_fetch: True


# PHP deps

{% if grains['lsb_distrib_release']=='14.04' %}
  {% set phpver='5' %}
{% else %}
  {% set phpver='7.0' %}
{% endif %}

php{{ phpver }}-cli:
  pkg.installed

php{{ phpver }}-mysql:
  pkg.installed:
    - watch_in:
      - service: apache2

php{{ phpver }}-gd:
  pkg.installed:
    - watch_in:
      - service: apache2


# Install composer (PHP package manager),
# see http://docs.saltstack.com/en/latest/ref/states/all/salt.states.composer.html

curl:
  pkg.installed

get-composer:
  cmd.run:
    - name: 'curl -s -S https://getcomposer.org/installer | php'
    - unless: test -f /usr/local/bin/composer
    - cwd: /root/
    - require:
      - pkg: php{{ phpver }}-cli
      - pkg: curl

install-composer:
  cmd.wait:
    - name: mv /root/composer.phar /usr/local/bin/composer
    - cwd: /root/
    - watch:
      - cmd: get-composer

# Install piwik's dependencies
/var/www/html/piwik/:
  composer.installed:
    - no_dev: true
    - require:
      - cmd: install-composer

/var/www/html/piwik/tmp:
  file.directory:
    - user: www-data
    - group: www-data
    # Uncommented because the git state often fails for me due to
    # https://github.com/saltstack/salt/issues/22514
    #- require:
    #  - git: https://github.com/piwik/piwik.git

/var/www/html/piwik/config:
  file.directory:
    - user: www-data
    - group: www-data
    - recurse:
      - user
      - group

mysql-server:
  pkg.installed

salt-deps:
  pkg.installed:
    - pkgs:
      - python-mysqldb

geoip-deps:
  pkg.installed:
    - pkgs:
      - php{{ phpver }}-geoip
      - php{{ phpver }}-dev
      - libgeoip-dev

piwik:
  mysql_user.present:
{'fraction_non_alphanumeric': 0.13615455381784727, 'fraction_numerical': 0.0078196872125115, 'mean_word_length': 2.4736421725239617, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 8, 'lorem ipsum': 0, 'www.': 16, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '454129', 'n_tokens_mistral': 1688, 'n_tokens_neox': 1556, 'n_words': 384}