Skip to content
Snippets Groups Projects
Commit 03afaed3 authored by jabertwo's avatar jabertwo
Browse files

erste services auf testserver installieren

parent 314865ba
No related branches found
No related tags found
No related merge requests found
---
- include_tasks: ../functions/get_secret.yml
with_items:
- { path: /srv/shared/noreply_email_pass, length: -1 }
- { path: "{{ basedir }}/mysql_root_pass", length: 24 }
- { path: "{{ basedir }}/mysql_user_pass", length: 12 }
- name: "create folder struct for {{ servicename }}"
file:
path: "{{ item }}"
state: "directory"
owner: www-data
group: www-data
with_items:
- "{{ basedir }}/"
- "{{ basedir }}/config"
- "{{ basedir }}/data/"
- "{{ basedir }}/db/"
- "{{ basedir }}/data/wp-content/"
- "{{ basedir }}/data/wp-content/plugins"
- "{{ basedir }}/data/wp-content/plugins/wz-status/"
- name: create config file
template:
src: "{{ item }}"
dest: "{{ basedir }}/{{ item }}"
with_items:
- Dockerfile
- docker-compose.yml
- config/uploads.ini
- data/wp-content/plugins/wz-status/wz-status.php
register: config
- name: "stop {{ servicename }} docker"
community.docker.docker_compose_v2:
project_src: "{{ basedir }}"
state: absent
when: config.changed
- name: "start {{ servicename }} docker"
community.docker.docker_compose_v2:
project_src: "{{ basedir }}"
state: present
FROM wordpress:6.4.2-apache
# install the PHP extensions we need
RUN set -x \
&& apt-get update \
&& apt-get install -y libldap2-dev \
&& rm -rf /var/lib/apt/lists/* \
&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu/ \
&& docker-php-ext-install ldap \
&& apt-get purge -y --auto-remove libldap2-dev
file_uploads = On
memory_limit = 64M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 600
<?php
/*
Plugin Name: WZ Status
Plugin URI: http://www.warpzone.ms
Description: This plugin adds a custom widget.
Version: 1.0
Author: Christian <void> Elberfeld
Author URI: http://www.warpzone.ms
License: GPL2
Original Source: https://github.com/wpexplorer/my-widget-plugin
*/
// The widget class
class WZ_Status_Widget extends WP_Widget {
// Main constructor
public function __construct() {
parent::__construct(
'wz_status_widget',
__( 'WZ Status Widget', 'text_domain' ),
array(
'customize_selective_refresh' => true,
)
);
}
// The widget form (for the backend )
public function form( $instance ) {
// Set widget defaults
$defaults = array(
'title' => '',
'api_url' => '',
);
// Parse current settings with defaults
extract( wp_parse_args( ( array ) $instance, $defaults ) ); ?>
<?php // Widget Title ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Widget Title', 'text_domain' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
</p>
<?php // Api Url ?>
<p>
<label for="<?php echo esc_attr( $this->get_field_id( 'api_url' ) ); ?>"><?php _e( 'Api Url:', 'api_url' ); ?></label>
<input class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'api_url' ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( 'api_url' ) ); ?>" type="text" value="<?php echo esc_attr( $text ); ?>" />
</p>
<?php }
// Update widget settings
public function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = isset( $new_instance['title'] ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
$instance['api_url'] = isset( $new_instance['api_url'] ) ? wp_strip_all_tags( $new_instance['api_url'] ) : '';
return $instance;
}
// Display the widget
public function widget( $args, $instance ) {
extract( $args );
// Check the widget options
$title = isset( $instance['title'] ) ? apply_filters( 'widget_title', $instance['title'] ) : '';
$api_url = isset( $instance['api_url'] ) ? $instance['api_url'] : '';
$zone_status = "UNBEKANNT";
$zone_status_text = "Unbekannt";
$zone_status_color = "#000000";
// WordPress core before_widget hook (always include )
echo $before_widget;
// Display the widget
echo '<div class="widget-text wp_widget_plugin_box">';
// Display widget title if defined
if ( $title ) {
echo $before_title . $title . $after_title;
}
// Zone Status abrufen
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.warpzone.ms/statuswidget",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 3,
CURLOPT_TIMEOUT => 5,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET"
));
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
$zone_status = $err;
} else {
$responseObj = json_decode($response,true);
$zone_status = $responseObj['zone_door_status'];
if ($zone_status == "OPEN") {
$zone_status_text = "Offen";
$zone_status_color = "#00cc00";
}
if ($zone_status == "CLOSED") {
$zone_status_text = "Geschlossen";
$zone_status_color = "#cc0000";
}
}
// Anzeige Status im Widget
echo "<span style='font-weight: bold; color:" . $zone_status_color . ";'>" . $zone_status_text . "</span>";
// Status mit in die Menueleiste fuer Mobilgeraete
echo "<script type='text/javascript'>jQuery(document).ready(function() { jQuery('#mainnav-toggle').text('MENU | Status: " . $zone_status_text . "'); });</script>";
echo '</div>';
// WordPress core after_widget hook (always include )
echo $after_widget;
}
}
// Register the widget
function my_register_wz_status_widget() {
register_widget( 'WZ_Status_Widget' );
}
add_action( 'widgets_init', 'my_register_wz_status_widget' );
version: "3"
services:
db:
image: mariadb:11.2.2
restart: always
volumes:
- /srv/wordpress/db/:/var/lib/mysql
environment:
MYSQL_ROOT_PASSWORD: "{{ mysql_root_pass }}"
MYSQL_PASSWORD: "{{ mysql_user_pass }}"
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
networks:
- default
app:
# values set in configuration: noreply_email_user - noreply_email_pass - smtp_host - smtp_port
build: .
restart: always
volumes:
- /srv/wordpress/config/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
- /srv/wordpress/data:/var/www/html
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: "{{ mysql_user_pass }}"
labels:
- traefik.enable=true
- traefik.http.routers.{{ servicename }}.rule=Host(`{{ domain }}`)
- traefik.http.routers.{{ servicename }}.entrypoints=websecure
- traefik.http.services.{{ servicename }}.loadbalancer.server.port=80
networks:
- default
- web
networks:
web:
external: true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment