: move phpbb to app dir

This commit is contained in:
VC
2025-04-04 20:38:30 +02:00
parent 1dafa87b40
commit ce3646dcf9
16 changed files with 313 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
server {
{% include './templates/header.conf.j2' %}
root /srv/http/forum.nintendojo.fr/;
root /var/www/forum.nintendojo.fr/;
index index.html index.htm index.php;
client_max_body_size 10M;

View File

@@ -0,0 +1,7 @@
---
name: DojoPeertube
host: p.nintendojo.fr
example: https://p.nintendojo.fr/videos/embed/19bc46e8-7640-4417-86a1-03aa2b439508
extract: "!//p.nintendojo.fr/videos/embed/(?'id'[0-9a-fA-F]{8}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{4}\\b-[0-9a-fA-F]{12})!"
iframe:
src: "https://p.nintendojo.fr/videos/embed/{@id}"

View File

@@ -0,0 +1,18 @@
---
name: "Mastodon"
host: m.nintendojo.fr
example: https://mastodon.social/@HackerNewsBot/100181134752056592
extract: "!//(?'host'[-.\\w]+)/@(?'name'\\w+)/(?'id'\\d+)!"
oembed:
endpoint: https://m.nintendojo.fr/api/oembed
scheme: https://m.nintendojo.fr/@{@name}/{@id}
scrape:
- extract: "!\"url\":\"https://(?'host'[-.\\w]+)/@(?'name'\\w+)/(?'id'\\d+)\"!"
- match: "!^(?'origin'https://[^/]+)/@\\w+@[-.\\w]+/(?'id'\\d+)!"
- url: "{@origin}/api/v1/statuses/{@id}"
iframe:
data-s9e-livepreview-ignore-attrs: "style"
onload: "let c=new MessageChannel;c.port1.onmessage=e=>this.style.height=e.data+'px';this.contentWindow.postMessage('s9e:init','*',[c.port2])"
width: "550"
height: "300"
src: https://s9e.github.io/iframe/2/mastodon.min.html#<xsl:value-of select="@name"/><xsl:if test="@host and@host!='mastodon.social'">@<xsl:value-of select="@host"/></xsl:if>/<xsl:value-of select="@id"/>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB

10
roles/phpbb/tasks/db.yml Normal file
View File

@@ -0,0 +1,10 @@
---
- name: Create phpbb db user
community.mysql.mysql_user:
login_unix_socket: "/var/run/mysqld/mysqld.sock"
login_user: root
login_password: "{{ mariadb_root_pass }}"
name: "{{ phpbb_maria_user }}"
password: "{{ phpbb_maria_password }}"
priv: "{{ phpbb_maria_database }}.*:ALL"

View File

@@ -0,0 +1,27 @@
---
- name: Init db
ansible.builtin.include_tasks: db.yml
- name: Install phpbb
ansible.builtin.include_tasks: phpbb.yml
- name: Install phpbbs styles
ansible.builtin.include_tasks: phpbb_styles.yml
loop: "{{ phpbb_styles }}"
- name: Install phpbbs languages
ansible.builtin.include_tasks: phpbb_languages.yml
loop: "{{ phpbb_languages }}"
- name: Install phpbbs extensions
ansible.builtin.include_tasks: phpbb_exts.yml
loop: "{{ phpbb_exts }}"
loop_control:
loop_var: ext
- name: Custom part
ansible.builtin.include_tasks: phpbb_customs.yml
- name: Migrate db
ansible.builtin.include_tasks: migrate_db.yml

View File

@@ -0,0 +1,14 @@
---
- name: Migrate db
become: true
become_user: www-data
ansible.builtin.command:
cmd: "/usr/bin/php bin/phpbbcli.php db:migrate"
chdir: "{{ phpbb_app_home }}"
changed_when: false
- name: Remove install directory
ansible.builtin.file:
dest: "{{ phpbb_app_home }}/install"
state: absent

View File

@@ -0,0 +1,77 @@
---
- name: Remove phpbb previous version
ansible.builtin.file:
state: absent
dest: "{{ phpbb_app_home }}"
## Handle app data
- name: Create app home
ansible.builtin.file:
state: directory
dest: "{{ phpbb_app_home }}"
owner: root
group: www-data
mode: "0o750"
- name: Install phpbb application
ansible.builtin.unarchive:
remote_src: true
src: "{{ phpbb_url }}"
dest: "{{ phpbb_app_home }}"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']
exclude: "{{ phpbb_userdata_app_dirs | map('regex_replace', '^^', 'phpBB' ~ phpbb_major_version ~ '/') }}"
- name: Check writable dirs
ansible.builtin.file:
state: directory
dest: "{{ phpbb_app_home }}/{{ item }}"
owner: www-data
group: www-data
mode: "a-rwx,u+rwX,g+rX"
recurse: true
loop: "{{ phpbb_writable_app_dirs }}"
## Handle user data
- name: Create data home
ansible.builtin.file:
state: directory
path: "{{ phpbb_data_home }}"
owner: www-data
group: www-data
mode: "a-rwx,u+rwX,g+rX"
- name: Get data dir
ansible.builtin.stat:
path: "{{ phpbb_data_home }}/{{ phpbb_userdata_app_dirs[0] }}"
register: _phpbb_userdata_dir_stat
- name: Install phpbb data dir
ansible.builtin.unarchive:
remote_src: true
src: "{{ phpbb_url }}"
dest: "{{ phpbb_data_home }}"
owner: www-data
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']
include: "{{ phpbb_userdata_app_dirs | map('regex_replace', '^^', 'phpBB' ~ phpbb_major_version ~ '/') }}"
when: not _phpbb_userdata_dir_stat.stat.exists
- name: Link phpbb userdata dirs
ansible.builtin.file:
state: link
src: "{{ phpbb_data_home }}/{{ item }}"
dest: "{{ phpbb_app_home }}/{{ item }}"
loop: "{{ phpbb_userdata_app_dirs }}"
- name: Put phpbb config file
ansible.builtin.template:
src: config.php.j2
dest: "{{ phpbb_app_home }}/config.php"
owner: root
group: www-data
mode: "0o640"

View File

@@ -0,0 +1,27 @@
---
- name: Put logo file
ansible.builtin.copy:
src: files/ndfr_casual.png
dest: "{{ phpbb_app_home }}/styles/prosilver/theme/images/ndfr_casual.png"
owner: root
group: www-data
mode: "0o640"
- name: Replace logo
ansible.builtin.lineinfile:
path: "{{ phpbb_app_home }}/styles/prosilver/theme/colours.css"
search_string: "background-image: url(\"./images/site_logo.svg\");"
line: " background-image: url(\"./images/ndfr_casual.png\");"
- name: Stretch logo (width)
ansible.builtin.lineinfile:
path: "{{ phpbb_app_home }}/styles/prosilver/theme/common.css"
search_string: "width: 149px;"
line: " width: 200px;"
- name: Stretch logo (height)
ansible.builtin.lineinfile:
path: "{{ phpbb_app_home }}/styles/prosilver/theme/common.css"
search_string: "height: 52px;"
line: " height: 80px;"

View File

@@ -0,0 +1,29 @@
---
- name: Create phpbb ext path
ansible.builtin.file:
state: directory
dest: "{{ phpbb_app_home }}/ext/{{ ext.path }}"
owner: root
group: www-data
mode: "0o750"
- name: Extract phpbb ext
ansible.builtin.unarchive:
remote_src: true
src: "{{ ext.url | replace('%VERSION%', ext.version) }}"
dest: "{{ phpbb_app_home }}/ext/{{ ext.path }}"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']
- name: Put extra files
ansible.builtin.copy:
src: "{{ item.src }}"
dest: "{{ phpbb_app_home }}/ext/{{ ext.path }}/{{ item.dest }}"
owner: root
group: www-data
mode: "0o640"
loop: "{{ ext.extra_files }}"
when: ext.extra_files is defined

View File

@@ -0,0 +1,11 @@
---
- name: Extract phpbb language
ansible.builtin.unarchive:
remote_src: true
src: "{{ item.url | replace('%VERSION%', item.version) }}"
dest: "{{ phpbb_app_home }}"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']

View File

@@ -0,0 +1,11 @@
---
- name: Extract style
ansible.builtin.unarchive:
remote_src: true
src: "{{ item.url | replace('%VERSION%', item.version) }}"
dest: "{{ phpbb_app_home }}/styles/"
owner: root
group: www-data
mode: "a-rwx,u+rwX,g+rX"
extra_opts: ['--strip-components=1']

View File

@@ -0,0 +1,19 @@
<?php
// phpBB 3.0.x auto-generated configuration file
// Do not change anything in this file!
$dbms = 'mysqli';
$dbhost = 'localhost';
$dbport = '';
$dbname = '{{ phpbb_maria_database }}';
$dbuser = '{{ phpbb_maria_user }}';
$dbpasswd = '{{ phpbb_maria_password }}';
$table_prefix = 'phpbb_';
$acm_type = 'file';
$load_extensions = '';
libxml_disable_entity_loader(false);
@define('PHPBB_INSTALLED', true);
// @define('DEBUG', true);
// @define('DEBUG_EXTRA', true);
?>

45
roles/phpbb/vars/main.yml Normal file
View File

@@ -0,0 +1,45 @@
---
phpbb_version: "3.3.15"
phpbb_minor_version: "{{ phpbb_version | regex_replace('^([0-9])\\.([0-9]*).*', '\\1.\\2') }}"
phpbb_major_version: "{{ phpbb_version | regex_replace('^([0-9])\\..*', '\\1') }}"
phpbb_url: "https://download.phpbb.com/pub/release/{{ phpbb_minor_version }}/{{ phpbb_version }}/phpBB-{{ phpbb_version }}.tar.bz2"
phpbb_access_url: "{{ web_hostname | selectattr('type', 'defined') | selectattr('type', '==', 'phpbb') | map(attribute='host') | first }}"
# Access path
phpbb_app_home: "/var/www/{{ phpbb_access_url }}"
phpbb_data_home: "/srv/www-data/{{ phpbb_access_url }}"
phpbb_writable_app_dirs:
- cache
- store
phpbb_userdata_app_dirs:
- files
- images
phpbb_styles:
- name: black
version: 3.3.12
url: "https://github.com/cabot/black/archive/refs/tags/v%VERSION%.tar.gz"
phpbb_languages:
- name: fr
version: 4.15.0
url: "https://github.com/qiaeru/phpbb-language-fr/archive/refs/tags/v%VERSION%.tar.gz"
phpbb_exts:
- name: externallink
path: martin/externallinkinnewwindow
version: 1.2.0
url: "https://github.com/Mar-tin-G/ExternalLinkInNewWindow/archive/refs/tags/%VERSION%.tar.gz"
- name: mediaembed
path: phpbb/mediaembed
version: 2.0.2
url: "https://github.com/phpbb-extensions/mediaembed/archive/refs/tags/%VERSION%.tar.gz"
extra_files:
- src: files/mastodon.yml
dest: collection/sites/mastodon.yml
- src: files/dojopeertube.yml
dest: collection/sites/dojopeertube.yml