werk21 blog https://blog.werk21.de/en en Update in-place replacement clamav on Ubuntu https://blog.werk21.de/en/2023/02/20/update-place-replacement-clamav-ubuntu <span>Update in-place replacement clamav on Ubuntu</span> <span><span lang="" about="/en/user/15" typeof="schema:Person" property="schema:name" datatype="">kelly</span></span> <span><time datetime="2023-02-20T20:43:38+01:00" title="Monday, February 20, 2023 - 20:43">Mon, 02/20/2023 - 20:43</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p><strong>For the current clamav vulnerabilites CVE-2023-20032 and CVE-2023-20052 are no updates for Ubuntu available at this time. We use the LTS Downloads 1.0.1 from clamav for a temporaray in-place replacement on Ubuntu.</strong></p> <p>We extracted from https://www.clamav.net/downloads the binaries and libs and placed them on the right place for ubuntu. Tested on Ubuntu 16.04 and 18.04. Please feedback your experience.</p> <h2>To install:</h2> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #666666; font-style: italic;"># Only if used with amavis </span>service postfix stop service amavis stop &nbsp; <span style="color: #666666; font-style: italic;"># Stop running services. </span>service clamav<span style="color: #339933;">-</span>freshclam stop service clamav<span style="color: #339933;">-</span>daemon stop &nbsp; <span style="color: #666666; font-style: italic;"># Remove old libraries. </span>rm <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>x86_64<span style="color: #339933;">-</span>linux<span style="color: #339933;">-</span>gnu<span style="color: #339933;">/</span>libclamav<span style="color: #339933;">.</span>so<span style="color: #339933;">.*</span> rm <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>x86_64<span style="color: #339933;">-</span>linux<span style="color: #339933;">-</span>gnu<span style="color: #339933;">/</span>libfreshclam<span style="color: #339933;">.</span>so<span style="color: #339933;">.*</span> &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Download and extract LTS package. </span><a href="http://www.php.net/mkdir"><span style="color: #990000;">mkdir</span></a> clamav<span style="color: #339933;">-</span>1<span style="color: #339933;">.</span>0<span style="color: #339933;">.</span>1 cd clamav<span style="color: #339933;">-</span>1<span style="color: #339933;">.</span>0<span style="color: #339933;">.</span>1 wget https<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//www.clamav.net/downloads/production/clamav-1.0.1.linux.x86_64.deb</span> ar x clamav<span style="color: #339933;">-</span>1<span style="color: #339933;">.</span>0<span style="color: #339933;">.</span>1<span style="color: #339933;">.</span>linux<span style="color: #339933;">.</span>x86_64<span style="color: #339933;">.</span>deb tar <span style="color: #339933;">-</span>xzf data<span style="color: #339933;">.</span>tar<span style="color: #339933;">.</span>gz &nbsp; <span style="color: #666666; font-style: italic;"># Copy needed files to filesystem. </span>cp <span style="color: #339933;">-</span>a usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>bin usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>lib usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>sbin <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span> &nbsp; <span style="color: #666666; font-style: italic;"># Run ldconfig and symlink original config. </span>ldconfig ln <span style="color: #339933;">-</span>s <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>clamav<span style="color: #339933;">/</span>clamd<span style="color: #339933;">.</span>conf <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span> ln <span style="color: #339933;">-</span>s <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>clamav<span style="color: #339933;">/</span>freshclam<span style="color: #339933;">.</span>conf <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span> &nbsp; <span style="color: #666666; font-style: italic;"># Testing and starting freshclam. </span>freshclam <span style="color: #339933;">--</span>version <span style="color: #666666; font-style: italic;"># ClamAV 1.0.1/26818/Mon Feb 20 09:21:31 2023 </span>freshclam service clamav<span style="color: #339933;">-</span>freshclam start tail <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span><a href="http://www.php.net/log"><span style="color: #990000;">log</span></a><span style="color: #339933;">/</span><a href="http://www.php.net/syslog"><span style="color: #990000;">syslog</span></a> &nbsp; <span style="color: #666666; font-style: italic;"># Starting clamav-daemon. </span>service clamav<span style="color: #339933;">-</span>daemon start <span style="color: #666666; font-style: italic;"># Waiting for clamd.ctl </span>watch ls <span style="color: #339933;">-</span>l <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span>run<span style="color: #339933;">/</span>clamav<span style="color: #339933;">/</span>clamd<span style="color: #339933;">.</span>ctl tail <span style="color: #339933;">-</span><span style="color: #cc66cc;">50</span> <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span><a href="http://www.php.net/log"><span style="color: #990000;">log</span></a><span style="color: #339933;">/</span><a href="http://www.php.net/syslog"><span style="color: #990000;">syslog</span></a> &nbsp; &nbsp; <span style="color: #666666; font-style: italic;"># Only if used with amavis </span>service amavis start tail <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span><a href="http://www.php.net/log"><span style="color: #990000;">log</span></a><span style="color: #339933;">/</span><a href="http://www.php.net/syslog"><span style="color: #990000;">syslog</span></a> &nbsp; <span style="color: #666666; font-style: italic;"># Only if used with amavis </span>service postfix start tail <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span><a href="http://www.php.net/log"><span style="color: #990000;">log</span></a><span style="color: #339933;">/</span><a href="http://www.php.net/mail"><span style="color: #990000;">mail</span></a><span style="color: #339933;">.</span>err tail <span style="color: #339933;">/</span><span style="color: #000000; font-weight: bold;">var</span><span style="color: #339933;">/</span><a href="http://www.php.net/log"><span style="color: #990000;">log</span></a><span style="color: #339933;">/</span><a href="http://www.php.net/mail"><span style="color: #990000;">mail</span></a><span style="color: #339933;">.</span><a href="http://www.php.net/log"><span style="color: #990000;">log</span></a></pre></div> <p>If you want to test you can send an email (or connect via telnet on port 25) and use Eicar string:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">X5O<span style="color: #339933;">!</span>P<span style="color: #339933;">%@</span>AP<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">4</span>\PZX54<span style="color: #009900;">&#40;</span>P^<span style="color: #009900;">&#41;</span>7CC<span style="color: #009900;">&#41;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#125;</span><span style="color: #000088;">$EICAR</span><span style="color: #339933;">-</span>STANDARD<span style="color: #339933;">-</span>ANTIVIRUS<span style="color: #339933;">-</span>TEST<span style="color: #339933;">-</span><a href="http://www.php.net/file"><span style="color: #990000;">FILE</span></a><span style="color: #339933;">!</span><span style="color: #000088;">$H</span><span style="color: #339933;">+</span>H<span style="color: #339933;">*</span></pre></div> <h2>Reinstall Orginal packages:</h2> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">service clamav<span style="color: #339933;">-</span>freshclam stop service clamav<span style="color: #339933;">-</span>daemon stop &nbsp; rm <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>clamd<span style="color: #339933;">.</span>conf rm <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>local<span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>freshclam<span style="color: #339933;">.</span>conf rm <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>libclam<span style="color: #339933;">*</span> rm <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>libfreshclam<span style="color: #339933;">*</span> rm <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>lib<span style="color: #339933;">/</span>pkgconfig<span style="color: #339933;">/</span>libclamav<span style="color: #339933;">.</span>pc &nbsp; aptitude reinstall clamav clamav<span style="color: #339933;">-</span>base clamav<span style="color: #339933;">-</span>daemon clamav<span style="color: #339933;">-</span>freshclam clamdscan libclamav7 libclamav9 libclamunrar7</pre></div> <p> </p></div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/server" class="label label-default" hreflang="de">Server</a> </div> Mon, 20 Feb 2023 19:43:38 +0000 kelly 153 at https://blog.werk21.de Drupal 9: Simplenews, Swiftmailer and Attachments (via hook_mail_alter) https://blog.werk21.de/en/2022/08/30/drupal-9-simplenews-swiftmailer-and-attachments-hookmailalter <span>Drupal 9: Simplenews, Swiftmailer and Attachments (via hook_mail_alter)</span> <span><span lang="" about="/en/user/15" typeof="schema:Person" property="schema:name" datatype="">kelly</span></span> <span><time datetime="2022-08-30T21:16:32+02:00" title="Tuesday, August 30, 2022 - 21:16">Tue, 08/30/2022 - 21:16</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>In Drupal 8/9 simplenews can add attachments only from file-field (and I am not sure if this works correctly because simplenews is <a href="https://git.drupalcode.org/project/simplenews/-/blob/3.x/src/Mail/MailEntity.php#L404">adding the whole file-entity</a> to the attachments-array and swiftmailer awaits <a href="https://git.drupalcode.org/project/swiftmailer/-/blob/8.x-2.x/src/Plugin/Mail/SwiftMailer.php#L397">a special array</a>).</p> <p>To handle your own attachments e.g. in referenced media-entities you can use hook_mail_alter().</p> <p>In this example the attached files come from the media-entities stored in "field_upload_media":</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/** * Implements hook_mail_alter(). */</span> <span style="color: #000000; font-weight: bold;">function</span> MYMODULE_mail_alter<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Add Attachments from field_upload_media to simplenews.</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><a href="http://www.php.net/isset"><span style="color: #990000;">isset</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$message</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'params'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'simplenews_mail'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Get simplenews-mail-object.</span> <span style="color: #000088;">$mail</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'params'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'simplenews_mail'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Get newsletter-node from mail-object.</span> <span style="color: #000088;">$node</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$mail</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getIssue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Get all referenced media entities from field_upload_media.</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$items</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'field_upload_media'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">referencedEntities</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #000088;">$attachments</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$items</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Get file entity from field_media_file.</span> <span style="color: #000088;">$file</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$item</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'field_media_file'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">entity</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Get mime-type.</span> <span style="color: #000088;">$filemime</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getMimeType</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Get file-uri and realpath.</span> <span style="color: #000088;">$uri</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$file</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getFileUri</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000088;">$filepath</span> <span style="color: #339933;">=</span> \Drupal<span style="color: #339933;">::</span><span style="color: #004000;">service</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'file_system'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><a href="http://www.php.net/realpath"><span style="color: #990000;">realpath</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$uri</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> &nbsp; <span style="color: #666666; font-style: italic;">// Build array for swiftailer and add to message.</span> <span style="color: #000088;">$attachments</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span> <span style="color: #0000ff;">'filepath'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$filepath</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'filename'</span> <span style="color: #339933;">=&gt;</span> <a href="http://www.php.net/basename"><span style="color: #990000;">basename</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filepath</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'filemime'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$filemime</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #000088;">$message</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'params'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'attachments'</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$attachments</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span></pre></div> <p> </p></div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/drupal-8-9" class="label label-default" hreflang="de">Drupal 8/9</a> </div> Tue, 30 Aug 2022 19:16:32 +0000 kelly 152 at https://blog.werk21.de Build xen-hypervisor 4.16 and xen-tools on Ubuntu 22.04 / 20.04 / 18.04 for PVH from source https://blog.werk21.de/en/2022/06/10/build-xen-hypervisor-416-and-xen-tools-ubuntu-2204-2004-1804-pvh-source <span>Build xen-hypervisor 4.16 and xen-tools on Ubuntu 22.04 / 20.04 / 18.04 for PVH from source</span> <span><span lang="" about="/en/user/15" typeof="schema:Person" property="schema:name" datatype="">kelly</span></span> <span><time datetime="2022-06-10T15:05:36+02:00" title="Friday, June 10, 2022 - 15:05">Fri, 06/10/2022 - 15:05</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>To get latest version to protect your system or use zstd-compressed Kernels you can build your xen-hypervisor from source.</p> <p>This howto based on this <a href="https://wiki.xenproject.org/wiki/Compiling_Xen_From_Source">official howto</a>.</p> <p>Updated for Ubuntu 22.04: Boot with pygrub and xen-tools (2022-08-18)</p> <p>Updates for Ubuntu 22.04: Added build dependencies (2022-06-10)</p> <p>Updated to xen 4.16: Added ninja-build to build environment (2021-12-16)</p> <p>Updates to xen 4.15: Added libzstd1-dev / libzstd-dev for zstd-compressed Kernels.</p> <h2>Xen-Hypervisor</h2> <h3>Install requirements for build</h3> <h4>For Ubuntu 22.04:</h4> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install build<span style="color: #339933;">-</span>essential apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install bcc bin86 gawk bridge<span style="color: #339933;">-</span>utils iproute2 libcurl4 libcurl4<span style="color: #339933;">-</span>openssl<span style="color: #339933;">-</span>dev bzip2 kmod transfig tgif pkg<span style="color: #339933;">-</span>config apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install texinfo texlive<span style="color: #339933;">-</span>latex<span style="color: #339933;">-</span>base texlive<span style="color: #339933;">-</span>latex<span style="color: #339933;">-</span>recommended texlive<span style="color: #339933;">-</span>fonts<span style="color: #339933;">-</span>extra texlive<span style="color: #339933;">-</span>fonts<span style="color: #339933;">-</span>recommended libpci<span style="color: #339933;">-</span>dev mercurial apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install make gcc libc6<span style="color: #339933;">-</span>dev zlib1g<span style="color: #339933;">-</span>dev python<span style="color: #339933;">-</span>all python<span style="color: #339933;">-</span>all<span style="color: #339933;">-</span>dev python3<span style="color: #339933;">-</span>twisted libncurses5<span style="color: #339933;">-</span>dev patch libvncserver<span style="color: #339933;">-</span>dev libsdl1<span style="color: #339933;">.</span>2<span style="color: #339933;">-</span>dev libjpeg<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install python3<span style="color: #339933;">-</span>dev libglib2<span style="color: #339933;">.</span>0<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libnl<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>cli<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>genl<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>route<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>idiag<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>xfrm<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install iasl libbz2<span style="color: #339933;">-</span>dev e2fslibs<span style="color: #339933;">-</span>dev git<span style="color: #339933;">-</span>core uuid<span style="color: #339933;">-</span>dev ocaml ocaml<span style="color: #339933;">-</span>findlib ocamlbuild libx11<span style="color: #339933;">-</span>dev bison flex xz<span style="color: #339933;">-</span>utils libyajl<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install <a href="http://www.php.net/gettext"><span style="color: #990000;">gettext</span></a> libpixman<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span>dev libaio<span style="color: #339933;">-</span>dev markdown pandoc iasl cmake figlet   apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libssh2<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span>dev libssh<span style="color: #339933;">-</span>dev libsnappy<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libc6<span style="color: #339933;">-</span>dev<span style="color: #339933;">-</span>i386 apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install lzma lzma<span style="color: #339933;">-</span>dev liblzma<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libsystemd<span style="color: #339933;">-</span>dev   apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libzstd<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install ninja<span style="color: #339933;">-</span>build</pre></div> <h4>For Ubuntu 20.04</h4> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install build<span style="color: #339933;">-</span>essential apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install bcc bin86 gawk bridge<span style="color: #339933;">-</span>utils iproute2 libcurl4 libcurl4<span style="color: #339933;">-</span>openssl<span style="color: #339933;">-</span>dev bzip2 kmod transfig tgif pkg<span style="color: #339933;">-</span>config apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install texinfo texlive<span style="color: #339933;">-</span>latex<span style="color: #339933;">-</span>base texlive<span style="color: #339933;">-</span>latex<span style="color: #339933;">-</span>recommended texlive<span style="color: #339933;">-</span>fonts<span style="color: #339933;">-</span>extra texlive<span style="color: #339933;">-</span>fonts<span style="color: #339933;">-</span>recommended libpci<span style="color: #339933;">-</span>dev mercurial apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install make gcc libc6<span style="color: #339933;">-</span>dev zlib1g<span style="color: #339933;">-</span>dev python python<span style="color: #339933;">-</span>dev python3<span style="color: #339933;">-</span>twisted libncurses5<span style="color: #339933;">-</span>dev patch libvncserver<span style="color: #339933;">-</span>dev libsdl<span style="color: #339933;">-</span>dev libjpeg<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install python3<span style="color: #339933;">-</span>dev libglib2<span style="color: #339933;">.</span>0<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libnl<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>cli<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>genl<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>route<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>idiag<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>xfrm<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install iasl libbz2<span style="color: #339933;">-</span>dev e2fslibs<span style="color: #339933;">-</span>dev git<span style="color: #339933;">-</span>core uuid<span style="color: #339933;">-</span>dev ocaml ocaml<span style="color: #339933;">-</span>findlib ocamlbuild libx11<span style="color: #339933;">-</span>dev bison flex xz<span style="color: #339933;">-</span>utils libyajl<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install <a href="http://www.php.net/gettext"><span style="color: #990000;">gettext</span></a> libpixman<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span>dev libaio<span style="color: #339933;">-</span>dev markdown pandoc iasl cmake figlet   apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libc6<span style="color: #339933;">-</span>dev<span style="color: #339933;">-</span>i386 apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install lzma lzma<span style="color: #339933;">-</span>dev liblzma<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libsystemd<span style="color: #339933;">-</span>dev   apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libzstd<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install ninja<span style="color: #339933;">-</span>build</pre></div> <h4>For Ubuntu 18.04:</h4> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install build<span style="color: #339933;">-</span>essential apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install bcc bin86 gawk bridge<span style="color: #339933;">-</span>utils iproute2 libcurl4 libcurl4<span style="color: #339933;">-</span>openssl<span style="color: #339933;">-</span>dev bzip2 module<span style="color: #339933;">-</span>init<span style="color: #339933;">-</span>tools transfig tgif apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install texinfo texlive<span style="color: #339933;">-</span>latex<span style="color: #339933;">-</span>base texlive<span style="color: #339933;">-</span>latex<span style="color: #339933;">-</span>recommended texlive<span style="color: #339933;">-</span>fonts<span style="color: #339933;">-</span>extra texlive<span style="color: #339933;">-</span>fonts<span style="color: #339933;">-</span>recommended pciutils<span style="color: #339933;">-</span>dev mercurial apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install make gcc libc6<span style="color: #339933;">-</span>dev zlib1g<span style="color: #339933;">-</span>dev python python<span style="color: #339933;">-</span>dev python<span style="color: #339933;">-</span>twisted libncurses5<span style="color: #339933;">-</span>dev patch libvncserver<span style="color: #339933;">-</span>dev libsdl<span style="color: #339933;">-</span>dev libjpeg<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install python3<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libnl<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>cli<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>genl<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>route<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>idiag<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev libnl<span style="color: #339933;">-</span>xfrm<span style="color: #339933;">-</span><span style="color: #cc66cc;">3</span><span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install iasl libbz2<span style="color: #339933;">-</span>dev e2fslibs<span style="color: #339933;">-</span>dev git<span style="color: #339933;">-</span>core uuid<span style="color: #339933;">-</span>dev ocaml ocaml<span style="color: #339933;">-</span>findlib libx11<span style="color: #339933;">-</span>dev bison flex xz<span style="color: #339933;">-</span>utils libyajl<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install <a href="http://www.php.net/gettext"><span style="color: #990000;">gettext</span></a> libpixman<span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">-</span>dev libaio<span style="color: #339933;">-</span>dev markdown pandoc iasl cmake figlet   apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libc6<span style="color: #339933;">-</span>dev<span style="color: #339933;">-</span>i386 apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install lzma lzma<span style="color: #339933;">-</span>dev liblzma<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libsystemd<span style="color: #339933;">-</span>dev   apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install libzstd1<span style="color: #339933;">-</span>dev apt<span style="color: #339933;">-</span>get <span style="color: #339933;">-</span>qq install ninja<span style="color: #339933;">-</span>build</pre></div> <h3>Download and prepare and make</h3> <p>We use the latest stable for 4.16</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">git clone git<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//xenbits.xen.org/xen.git</span> cd xen git checkout origin<span style="color: #339933;">/</span>stable<span style="color: #339933;">-</span><span style="color:#800080;">4.16</span></pre></div> <h4>Configure and make</h4> <p>Ubuntu uses systemd:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #339933;">./</span>configure <span style="color: #339933;">--</span>enable<span style="color: #339933;">-</span>systemd</pre></div> <p>For first make use:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">make dist</pre></div> <p>For new make use <em>make world</em> (same like <em>make clean &amp;&amp; make dist</em>).</p> <p>Get a coffee now.</p> <h3>Install</h3> <p>The install-files are in /dist/install. And you will find an install-script in dist/install.sh. <strong>Dont use this script! It will breaks your /var/run-folder</strong>.</p> <p>You can copy the files via <em>cp -a</em> or <em>rsync </em>in your system. Or you may use <em>make debball </em>and install the package from file (I didnt try)<em>.</em></p> <h3>Post-Install</h3> <p>After copying the files you will do some changes in your system:</p> <h4>Reload dynamic libraries:</h4> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #339933;">/</span>sbin<span style="color: #339933;">/</span>ldconfig</pre></div> <h4>Grub-Settings:</h4> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><a href="http://www.php.net/mkdir"><span style="color: #990000;">mkdir</span></a> <span style="color: #339933;">-</span>p <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span><span style="color: #b1b100;">default</span><span style="color: #339933;">/</span>grub<span style="color: #339933;">.</span>d</pre></div> <p>Create /etc/default/grub.d/xen.cfg:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">vi <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span><span style="color: #b1b100;">default</span><span style="color: #339933;">/</span>grub<span style="color: #339933;">.</span>d<span style="color: #339933;">/</span>xen<span style="color: #339933;">.</span>cfg</pre></div> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">GRUB_DISABLE_OS_PROBER<span style="color: #339933;">=</span><span style="color: #009900; font-weight: bold;">true</span> GRUB_CMDLINE_XEN_DEFAULT<span style="color: #339933;">=</span><span style="color: #0000ff;">"dom0_mem=2560M,max:2560M"</span> GRUB_DEFAULT<span style="color: #339933;">=</span><span style="color: #0000ff;">"Ubuntu GNU/Linux, mit Xen-Hypervisor"</span></pre></div> <p>Be careful! The last settings depends on your system-language! For english use: "Ubuntu GNU/Linux, with Xen hypervisor" - Ubuntu 18.04 does not use the german translation!</p> <p>You have to update grub:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">update<span style="color: #339933;">-</span>grub</pre></div> <h4>Enable systemd-files:</h4> <p>In the current version is a bug and xendomains.service and /etc/init.d/xendomains are created both. To use systemd you have to remove /etc/init.d/xendomains</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">rm <span style="color: #339933;">/</span>etc<span style="color: #339933;">/</span>init<span style="color: #339933;">.</span>d<span style="color: #339933;">/</span>xendomains</pre></div> <h4> </h4> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">systemctl enable xen<span style="color: #339933;">-</span>qemu<span style="color: #339933;">-</span>dom0<span style="color: #339933;">-</span>disk<span style="color: #339933;">-</span>backend<span style="color: #339933;">.</span>service systemctl enable xen<span style="color: #339933;">-</span>init<span style="color: #339933;">-</span>dom0<span style="color: #339933;">.</span>service systemctl enable xenconsoled<span style="color: #339933;">.</span>service systemctl enable xenstored<span style="color: #339933;">.</span>service systemctl enable xendomains<span style="color: #339933;">.</span>service</pre></div> <p>Optional you can enable xen-watchdog.service</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">systemctl enable xen<span style="color: #339933;">-</span>watchdog<span style="color: #339933;">.</span>service</pre></div> <h4>Configure xen</h4> <p>Configure xen for your needs.</p> <h2>xen-tools</h2> <p>For creating new VMs you can use xen-tools. Unfortunately you cannot use the ubuntu-package because it requires xen-hypervisor. So we build from source.</p> <h3>Install requirements for build</h3> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">apt install lvm2 debootstrap libconfig<span style="color: #339933;">-</span>inifiles<span style="color: #339933;">-</span>perl libdata<span style="color: #339933;">-</span>validate<span style="color: #339933;">-</span>domain<span style="color: #339933;">-</span>perl libdata<span style="color: #339933;">-</span>validate<span style="color: #339933;">-</span>ip<span style="color: #339933;">-</span>perl libdata<span style="color: #339933;">-</span>validate<span style="color: #339933;">-</span>uri<span style="color: #339933;">-</span>perl libfile<span style="color: #339933;">-</span>slurp<span style="color: #339933;">-</span>perl libfile<span style="color: #339933;">-</span>which<span style="color: #339933;">-</span>perl libsort<span style="color: #339933;">-</span>versions<span style="color: #339933;">-</span>perl libterm<span style="color: #339933;">-</span>ui<span style="color: #339933;">-</span>perl libtext<span style="color: #339933;">-</span>template<span style="color: #339933;">-</span>perl openssh<span style="color: #339933;">-</span>client perl debian<span style="color: #339933;">-</span>archive<span style="color: #339933;">-</span>keyring rinse libtest<span style="color: #339933;">-</span>notabs<span style="color: #339933;">-</span>perl</pre></div> <h3>Download and prepare and make</h3> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">git clone https<span style="color: #339933;">:</span><span style="color: #666666; font-style: italic;">//github.com/xen-tools/xen-tools.git</span> cd xen<span style="color: #339933;">-</span>tools make install</pre></div> <p>If you want only the install-files (e.g. for build you own package), you can edit the Makefile and manually set the variable <em>DESTDIR</em> before <em>make install</em>.</p> <h3>Adaptions for Ubuntu newer versions incl. 22.02</h3> <p>For newer versions the symlink to artful is missing. Just create symlinks and add the distri to distributions.conf</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">cd usr<span style="color: #339933;">/</span>share<span style="color: #339933;">/</span>xen<span style="color: #339933;">-</span>tools<span style="color: #339933;">/</span> ln <span style="color: #339933;">-</span>s artful<span style="color: #339933;">.</span>d bionic<span style="color: #339933;">.</span>d ln <span style="color: #339933;">-</span>s artful<span style="color: #339933;">.</span>d focal<span style="color: #339933;">.</span>d ln <span style="color: #339933;">-</span>s artful<span style="color: #339933;">.</span>d jammy<span style="color: #339933;">.</span>d</pre></div> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">"bionic = ubuntu pygrub"</span> <span style="color: #339933;">&gt;&gt;</span> etc<span style="color: #339933;">/</span>xen<span style="color: #339933;">-</span>tools<span style="color: #339933;">/</span>distributions<span style="color: #339933;">.</span>conf <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">"focal = ubuntu pygrub"</span> <span style="color: #339933;">&gt;&gt;</span> etc<span style="color: #339933;">/</span>xen<span style="color: #339933;">-</span>tools<span style="color: #339933;">/</span>distributions<span style="color: #339933;">.</span>conf <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">"jammy = ubuntu pygrub"</span> <span style="color: #339933;">&gt;&gt;</span> etc<span style="color: #339933;">/</span>xen<span style="color: #339933;">-</span>tools<span style="color: #339933;">/</span>distributions<span style="color: #339933;">.</span>conf</pre></div> <h3>Ubuntu 22.04 and Grub</h3> <p>Ubuntu 22.04 contains no Grub-1 anymore. So we just add a /boot/grub/menu.lst manually so pygrub can boot.</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">cat <span style="color: #339933;">&lt;&lt;</span> EO2 <span style="color: #339933;">&gt;</span> usr<span style="color: #339933;">/</span>share<span style="color: #339933;">/</span>xen<span style="color: #339933;">-</span>tools<span style="color: #339933;">/</span>artful<span style="color: #339933;">.</span>d<span style="color: #339933;">/</span><span style="color: #cc66cc;">99</span><span style="color: #339933;">-</span>pseudogrub   <span style="color: #666666; font-style: italic;">#!/bin/sh </span><span style="color: #666666; font-style: italic;"># </span><span style="color: #666666; font-style: italic;"># This script enable boot via pygrub without grub-1. </span><span style="color: #666666; font-style: italic;"># </span>   prefix<span style="color: #339933;">=</span>$<span style="color:#800080;">1</span>   <span style="color: #666666; font-style: italic;"># </span><span style="color: #666666; font-style: italic;"># Source our common functions </span><span style="color: #666666; font-style: italic;"># </span><span style="color: #b1b100;">if</span> <span style="color: #009900;">[</span> <span style="color: #339933;">-</span>e <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>share<span style="color: #339933;">/</span>xen<span style="color: #339933;">-</span>tools<span style="color: #339933;">/</span>common<span style="color: #339933;">.</span>sh <span style="color: #009900;">]</span><span style="color: #339933;">;</span> then <span style="color: #339933;">.</span> <span style="color: #339933;">/</span>usr<span style="color: #339933;">/</span>share<span style="color: #339933;">/</span>xen<span style="color: #339933;">-</span>tools<span style="color: #339933;">/</span>common<span style="color: #339933;">.</span>sh <span style="color: #b1b100;">else</span> <span style="color: #339933;">.</span> <span style="color: #339933;">./</span>hooks<span style="color: #339933;">/</span>common<span style="color: #339933;">.</span>sh fi   <span style="color: #666666; font-style: italic;"># </span><span style="color: #666666; font-style: italic;"># Log our start </span><span style="color: #666666; font-style: italic;"># </span>logMessage Script $<span style="color:#800080;">0</span> starting   <a href="http://www.php.net/mkdir"><span style="color: #990000;">mkdir</span></a> <span style="color: #339933;">-</span>p $<span style="color: #009900;">{</span>prefix<span style="color: #009900;">}</span><span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>grub cat <span style="color: #339933;">&lt;&lt;</span> EOF <span style="color: #339933;">&gt;</span> $<span style="color: #009900;">{</span>prefix<span style="color: #009900;">}</span><span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>grub<span style="color: #339933;">/</span>menu<span style="color: #339933;">.</span>lst   <span style="color: #b1b100;">default</span> <span style="color: #cc66cc;">0</span> timeout <span style="color: #cc66cc;">2</span>   title Ubuntu <span style="color:#800080;">22.04</span> LTS root <span style="color: #009900;">(</span>hd0<span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">)</span> kernel <span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>vmlinuz root<span style="color: #339933;">=/</span>dev<span style="color: #339933;">/</span>xvda2 ro elevator<span style="color: #339933;">=</span>noop initrd <span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>initrd<span style="color: #339933;">.</span>img   title Ubuntu <span style="color:#800080;">22.04</span> LTS <span style="color: #009900;">(</span>Single<span style="color: #339933;">-</span>User<span style="color: #009900;">)</span> root <span style="color: #009900;">(</span>hd0<span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">)</span> kernel <span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>vmlinuz root<span style="color: #339933;">=/</span>dev<span style="color: #339933;">/</span>xvda2 ro single elevator<span style="color: #339933;">=</span>noop initrd <span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>initrd<span style="color: #339933;">.</span>img   title Ubuntu <span style="color:#800080;">22.04</span> LTS <span style="color: #009900;">(</span>Old<span style="color: #009900;">)</span> root <span style="color: #009900;">(</span>hd0<span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">)</span> kernel <span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>vmlinuz<span style="color: #339933;">.</span>old root<span style="color: #339933;">=/</span>dev<span style="color: #339933;">/</span>xvda2 ro elevator<span style="color: #339933;">=</span>noop initrd <span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>initrd<span style="color: #339933;">.</span>img<span style="color: #339933;">.</span>old   title Ubuntu <span style="color:#800080;">22.04</span> LTS <span style="color: #009900;">(</span>Old<span style="color: #339933;">,</span> Single<span style="color: #339933;">-</span>User<span style="color: #009900;">)</span> root <span style="color: #009900;">(</span>hd0<span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">)</span> kernel <span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>vmlinuz<span style="color: #339933;">.</span>old root<span style="color: #339933;">=/</span>dev<span style="color: #339933;">/</span>xvda2 ro single elevator<span style="color: #339933;">=</span>noop initrd <span style="color: #339933;">/</span>boot<span style="color: #339933;">/</span>initrd<span style="color: #339933;">.</span>img<span style="color: #339933;">.</span>old   EOF   <span style="color: #666666; font-style: italic;"># </span><span style="color: #666666; font-style: italic;"># Log our finish </span><span style="color: #666666; font-style: italic;"># </span>logMessage Script $<span style="color:#800080;">0</span> finished   EO2   <a href="http://www.php.net/chmod"><span style="color: #990000;">chmod</span></a> <span style="color: #339933;">+</span>x usr<span style="color: #339933;">/</span>share<span style="color: #339933;">/</span>xen<span style="color: #339933;">-</span>tools<span style="color: #339933;">/</span>artful<span style="color: #339933;">.</span>d<span style="color: #339933;">/</span><span style="color: #cc66cc;">99</span><span style="color: #339933;">-</span>pseudogrub </pre></div> <p> </p> <p> </p> <p> </p> <h3>Configure xen-tools</h3> <p>Configure xen-tools for your needs.</p> <p> </p> <h2>Reboot</h2> <p>After reboot you have your Ubuntu on xen-hypervisor.</p> <p>Test:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">xentop</pre></div> <h2>Settings for PVH</h2> <p>For PVH you have to use Linux 4.11 or newer (e.g. HWE-Kernel) in guest:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">apt install linux<span style="color: #339933;">-</span>virtual<span style="color: #339933;">-</span>hwe<span style="color: #339933;">-</span><span style="color:#800080;">16.04</span> linux<span style="color: #339933;">-</span>tools<span style="color: #339933;">-</span>virtual<span style="color: #339933;">-</span>hwe<span style="color: #339933;">-</span><span style="color:#800080;">16.04</span></pre></div> <p>Then you can use:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">bootloader <span style="color: #339933;">=</span> <span style="color: #0000ff;">'/usr/local/bin/pygrub'</span> type<span style="color: #339933;">=</span><span style="color: #0000ff;">"pvh"</span></pre></div> <p>If you have an old kernel in your guest-system, you have to boot from dom0-kernel with this settings:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">type<span style="color: #339933;">=</span><span style="color: #0000ff;">"pvh"</span> kernel<span style="color: #339933;">=</span><span style="color: #0000ff;">'/vmlinuz'</span> ramdisk<span style="color: #339933;">=</span><span style="color: #0000ff;">"/initrd.img"</span></pre></div> <p> </p> </div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/server" class="label label-default" hreflang="de">Server</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/de/tags/xen" class="label label-default" hreflang="de">xen</a> <a href="/de/tags/ubuntu" class="label label-default" hreflang="de">ubuntu</a> <a href="/en/tags/meltdown" class="label label-default" hreflang="en">Meltdown</a> </div> Fri, 10 Jun 2022 13:05:36 +0000 kelly 135 at https://blog.werk21.de How to "fix" 403 access denied exceptions for Drupal 8 Views translation routes https://blog.werk21.de/en/2018/12/06/how-fix-403-access-denied-exceptions-drupal-8-views-translation-routes <span>How to &quot;fix&quot; 403 access denied exceptions for Drupal 8 Views translation routes</span> <span><span lang="" about="/en/user/8" typeof="schema:Person" property="schema:name" datatype="">patrick</span></span> <span><time datetime="2018-12-06T08:50:41+01:00" title="Thursday, December 6, 2018 - 08:50">Thu, 12/06/2018 - 08:50</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>Today I worked on a project where the customer had asked us to add a missing translation for the label of an exposed filter of a view. The view configuration was originally imported upon installation of a contributed module, that uses that view. I thought that this would be an easy task quickly done: We have configuration translation enabled on that system so all views have a "Translate" operation that you can use to translate the view. Not in this case, of course ;).<br /><br /> I was logged in as the magic super user 1 with the magic administrator role assigned to it, but I still got a 403 access denied exception each time I tried to translate this particular view. Other views that we had created manually or that were provided by other contribued modules worked fine. But not this one. What the ****?<br /><br /> After searching the core issue queue for a while to no avail, I ended up to comment out the "throw AccessDeniedException" in the AccessAwareRouter, just out of curiosity. After all this was a dev system, so what could possibly go wrong? And then I instantly realized what the problem was. The list of translations was displayed and I saw that the "original translation" was "language undefined" or "und". Looking at the configuration object more closely confirmed, that the language was "und". In hindsight, it was kind of logical that I couldn't translate that one, right?<br /><br /> Of course I didn't make the foolish attempt to create an English translation for the view via UI. Since Views doesn't have a UI to change the language of a view like for example Content entities have, I decided to just export the configuration using Drush, find the YAML file for the configuration object in question, edit it so that the language was no longer "und", but "en", and import the configuration again using Drush. Now I was able to translate the view using the UI without my quick modification of the AccessAwareRouter.<br /><br /> Yet another lesson learned.</p></div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/drupal-8-9" class="label label-default" hreflang="de">Drupal 8/9</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/de/tags/drush" class="label label-default" hreflang="de">drush</a> <a href="/de/tags/views" class="label label-default" hreflang="de">Views</a> <a href="/en/tags/translation" class="label label-default" hreflang="en">Translation</a> <a href="/en/tags/config-translation" class="label label-default" hreflang="en">Config Translation</a> <a href="/en/tags/yml" class="label label-default" hreflang="en">yml</a> <a href="/en/tags/accessawarerouter" class="label label-default" hreflang="en">AccessAwareRouter</a> <a href="/en/tags/accessdeniedexception" class="label label-default" hreflang="en">AccessDeniedException</a> <a href="/en/tags/exception" class="label label-default" hreflang="en">Exception</a> </div> Thu, 06 Dec 2018 07:50:41 +0000 patrick 148 at https://blog.werk21.de Open multiple key database files upon KeePass2 startup https://blog.werk21.de/en/2018/09/24/open-multiple-key-database-files-upon-keepass2-startup <span>Open multiple key database files upon KeePass2 startup</span> <span><span lang="" about="/en/user/8" typeof="schema:Person" property="schema:name" datatype="">patrick</span></span> <span><time datetime="2018-09-24T08:19:16+02:00" title="Monday, September 24, 2018 - 08:19">Mon, 09/24/2018 - 08:19</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p><a href="https://keepass.info/">KeePass2</a> has a setting to open the most recently opened key database upon start-up, but what if you want to open multiple key database files? One way to do this is to add a trigger that will open the files on start-up.</p> <ol><li>Go to <em>Tools</em> &gt; <em>Options</em> &gt; <em>Advanced</em> and make sure that <em>Remember and automatically open last used database on startup</em> is unchecked.</li> <li>Go to <em>Tools</em> &gt; <em>Triggers</em> and click on the <em>Add</em> button.</li> <li>On the <em>Properties</em> tab, specify a convenient name to your liking.</li> <li>On the <em>Events</em> tab, click the <em>Add</em> button and add an <em>Application started and ready</em> event.</li> <li>On the <em>Actions</em> tab, cklick the <em>Add</em> button and add an <em>Open database file</em> action. As <em>File/URL</em> setting, specify the full path to your key database file. If you use a password to open your database, it is suggested to leave the <em>Password</em> setting empty as it will be stored in unencrypted form. You will then be prompted to enter the password upon start-up as usual.</li> <li>Add additional <em>Open database file</em> actions for each database you want to open.</li> </ol></div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systeme/pc" class="label label-default" hreflang="de">PC</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/en/tags/keepass2" class="label label-default" hreflang="en">KeePass2</a> </div> Mon, 24 Sep 2018 06:19:16 +0000 patrick 145 at https://blog.werk21.de Date (range) fields and Entity Query [Update] https://blog.werk21.de/en/2018/02/05/date-range-fields-and-entity-query-update <span>Date (range) fields and Entity Query [Update]</span> <span><span lang="" about="/en/user/8" typeof="schema:Person" property="schema:name" datatype="">patrick</span></span> <span><time datetime="2018-02-05T08:09:16+01:00" title="Monday, February 5, 2018 - 08:09">Mon, 02/05/2018 - 08:09</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>Ever wanted to add a <a href="https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21Query%21QueryInterface.php/function/QueryInterface%3A%3Acondition/8.4.x">condition</a> on the value of a date field on an <a href="https://api.drupal.org/api/drupal/core%21lib%21Drupal.php/function/Drupal%3A%3AentityQuery/8.4.x">entity query</a> in Drupal 8? Here is how it works reliably.</p> <p>For Drupal 8.5.x and later:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Drupal\Core\Datetime\DrupalDateTime<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">use</span> Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface<span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Get a date string suitable for use with entity query.</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DrupalDateTime<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTimezone</span><span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">new</span> \DateTimeZone<span style="color: #009900;">(</span>DateTimeItemInterface<span style="color: #339933;">::</span><span style="color: #004000;">STORAGE_TIMEZONE</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">(</span>DateTimeItemInterface<span style="color: #339933;">::</span><span style="color: #004000;">DATETIME_STORAGE_FORMAT</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Set the condition.</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">condition</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'field_date.value'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&gt;'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span></pre></div> <p>For Drupal 8.4.x and earlier:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Drupal\Core\Datetime\DrupalDateTime<span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Get a date string suitable for use with entity query.</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DrupalDateTime<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTimezone</span><span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">new</span> \DateTimeZone<span style="color: #009900;">(</span>DATETIME_STORAGE_TIMEZONE<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">(</span>DATETIME_DATETIME_STORAGE_FORMAT<span style="color: #009900;">)</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Set the condition.</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">condition</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'field_date.value'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&gt;'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span></pre></div> <p>The trick is to use a <a href="https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Datetime%21DrupalDateTime.php/class/DrupalDateTime/8.4.x">DrupalDateTime</a> object, on which we set the proper time zone used by the storage (provided by the constant <a href="https://api.drupal.org/api/drupal/core%21modules%21datetime%21datetime.module/constant/DATETIME_STORAGE_TIMEZONE/8.4.x"><span class="geshifilter"><code class="php geshifilter-php">DATETIME_STORAGE_TIMEZONE</code></span></a>) and format that in the proper date format used by the storage (provided by the constant <a href="https://api.drupal.org/api/drupal/core%21modules%21datetime%21datetime.module/constant/DATETIME_DATETIME_STORAGE_FORMAT/8.4.x"><span class="geshifilter"><code class="php geshifilter-php">DATETIME_DATETIME_STORAGE_FORMAT</code></span></a>). That way, we'll get reliable results. In the example above I just wanted to filter by the current time, but you can pass a date string to the <a href="https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Datetime%21DrupalDateTime.php/function/DrupalDateTime%3A%3A__construct/8.4.x">constructor of DrupalDateTime</a> as well, if you want something else.</p> <p><strong>Please note:</strong> Starting with Drupal 8.5.x, the constants mentioned above have been <em>deprecated</em> in favor of constants on a new <a href="https://api.drupal.org/api/drupal/core%21modules%21datetime%21src%21Plugin%21Field%21FieldType%21DateTimeItemInterface.php/interface/DateTimeItemInterface/8.5.x"><span class="geshifilter"><code class="php geshifilter-php">DateTimeItemInterface</code></span></a>. They will be removed in Drupal 9.x.</p> <p>You can also get these objects directly from a date field's value by using <a href="https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21TypedData%21Type%21DateTimeInterface.php/interface/DateTimeInterface/8.4.x">getDateTime()</a>:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$node</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">field_date_range</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$item</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">(</span><span style="color: #000088;">$item</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$index</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$value</span><span style="color: #009900;">)</span> <span style="color: #009900;">{</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$value</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getDateTime</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #009900;">}</span> <span style="color: #009900;">}</span></pre></div> <p>If you're using experimental date range fields, another thing you need to know is, that the end date is stored in an <span class="geshifilter"><code class="php geshifilter-php">end_value</code></span> column.</p> <p>Here's a more complete example querying for event nodes in the future:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">use</span> Drupal\Core\Datetime\DrupalDateTime<span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">use</span> Drupal\Core\Language\LanguageInterface<span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// @note: In Drupal 8.5.x and later also include the following line:</span> <span style="color: #000000; font-weight: bold;">use</span> Drupal\datetime\Plugin\Field\FieldType\DateTimeItemInterface<span style="color: #339933;">;</span>   <span style="color: #000088;">$storage</span> <span style="color: #339933;">=</span> \Drupal<span style="color: #339933;">::</span><span style="color: #004000;">service</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'entity_type.manager'</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getStorage</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'node'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$storage</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getQuery</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">condition</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'type'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'event'</span><span style="color: #009900;">)</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">condition</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'status'</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">)</span> <span style="color: #339933;">-&gt;</span><a href="http://www.php.net/sort"><span style="color: #990000;">sort</span></a><span style="color: #009900;">(</span><span style="color: #0000ff;">'field_date_range.value'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ASC'</span><span style="color: #009900;">)</span> <span style="color: #339933;">-&gt;</span><a href="http://www.php.net/sort"><span style="color: #990000;">sort</span></a><span style="color: #009900;">(</span><span style="color: #0000ff;">'field_date_range.end_value'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ASC'</span><span style="color: #009900;">)</span> <span style="color: #339933;">-&gt;</span><a href="http://www.php.net/sort"><span style="color: #990000;">sort</span></a><span style="color: #009900;">(</span><span style="color: #0000ff;">'created'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'ASC'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>   <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">condition</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'langcode'</span><span style="color: #339933;">,</span> <span style="color: #009900;">[</span> \Drupal<span style="color: #339933;">::</span><span style="color: #004000;">service</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'language_manager'</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getCurrentLanguage</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">getId</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">,</span> LanguageInterface<span style="color: #339933;">::</span><span style="color: #004000;">LANGCODE_NOT_APPLICABLE</span><span style="color: #339933;">,</span> LanguageInterface<span style="color: #339933;">::</span><span style="color: #004000;">LANGCODE_NOT_SPECIFIED</span><span style="color: #339933;">,</span> <span style="color: #009900;">]</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'IN'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// @note BEGIN: Code for Drupal 8.5.x and later: </span> <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DrupalDateTime<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTimezone</span><span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">new</span> \DateTimeZone<span style="color: #009900;">(</span>DateTimeItemInterface<span style="color: #339933;">::</span><span style="color: #004000;">STORAGE_TIMEZONE</span><span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">(</span>DateTimeItemInterface<span style="color: #339933;">::</span><span style="color: #004000;">DATETIME_STORAGE_FORMAT</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// @node END: Code for Drupal 8.5.x and later.</span>   <span style="color: #666666; font-style: italic;">// @note BEGIN: Code for Drupal 8.4.x and earlier:</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> DrupalDateTime<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">setTimezone</span><span style="color: #009900;">(</span><span style="color: #000000; font-weight: bold;">new</span> \DateTimeZone<span style="color: #009900;">(</span>DATETIME_STORAGE_TIMEZONE<span style="color: #009900;">)</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$date</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$date</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">format</span><span style="color: #009900;">(</span>DATETIME_DATETIME_STORAGE_FORMAT<span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// @node END: Code for Drupal 8.4.x and earlier.</span>   <span style="color: #000088;">$and</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">andConditionGroup</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">condition</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'field_date_range.value'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&gt;'</span><span style="color: #009900;">)</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">notExists</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'field_date_range.end_value'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>   <span style="color: #000088;">$or</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">orConditionGroup</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">condition</span><span style="color: #009900;">(</span><span style="color: #000088;">$and</span><span style="color: #009900;">)</span> <span style="color: #339933;">-&gt;</span><span style="color: #004000;">condition</span><span style="color: #009900;">(</span><span style="color: #0000ff;">'field_date_range.end_value'</span><span style="color: #339933;">,</span> <span style="color: #000088;">$date</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'&gt;'</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>   <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">condition</span><span style="color: #009900;">(</span><span style="color: #000088;">$or</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span>   <span style="color: #000088;">$ids</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">execute</span><span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> <span style="color: #000088;">$nodes</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$storage</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">loadMultiple</span><span style="color: #009900;">(</span><span style="color: #000088;">$ids</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span></pre></div> <p>Note, that there's currently <a href="https://www.drupal.org/project/drupal/issues/2580265">an issue in Drupal Core</a> with nested condition groups in entity query, which are used in the example above.</p> <p><strong>Update:</strong> This post has been updated to reflect changes in Drupal 8.5.x (see <a href="https://www.drupal.org/node/2912980">Global constants in datetime.module are deprecated and DateTimeItemInterface has been introduced</a>).</p> </div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/drupal-8-9" class="label label-default" hreflang="de">Drupal 8/9</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/de/tags/date" class="label label-default" hreflang="de">date</a> <a href="/en/tags/date-range" class="label label-default" hreflang="en">date range</a> <a href="/en/tags/languagemanager" class="label label-default" hreflang="en">LanguageManager</a> <a href="/en/tags/getcurrentlanguage" class="label label-default" hreflang="en">getCurrentLanguage</a> <a href="/en/tags/languageinterface" class="label label-default" hreflang="en">LanguageInterface</a> <a href="/en/tags/drupaldatetime" class="label label-default" hreflang="en">DrupalDateTime</a> <a href="/en/tags/entity-query" class="label label-default" hreflang="en">entity query</a> <a href="/en/tags/entitytypemanager" class="label label-default" hreflang="en">EntityTypeManager</a> <a href="/en/tags/datetimeiteminterface" class="label label-default" hreflang="en">DateTimeItemInterface</a> </div> Mon, 05 Feb 2018 07:09:16 +0000 patrick 134 at https://blog.werk21.de Install pfsense 2.4.x on xen (Ubuntu 16.04) https://blog.werk21.de/en/2017/12/17/install-pfsense-24x-xen-ubuntu-1604 <span>Install pfsense 2.4.x on xen (Ubuntu 16.04)</span> <span><span lang="" about="/en/user/15" typeof="schema:Person" property="schema:name" datatype="">kelly</span></span> <span><time datetime="2017-12-17T17:43:23+01:00" title="Sunday, December 17, 2017 - 17:43">Sun, 12/17/2017 - 17:43</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>pfsense 2.4.x is not available as nano-image, so you have to install pfsense as xen-Guest via vnc.</p> <h2>Download pfsense</h2> <p>Download pfsense from <a href="https://www.pfsense.org/download/">https://www.pfsense.org/download/</a> (AMD64, CD Image (ISO) Installer)</p> <h2>Configure Xen</h2> <p>You have to create a LV or another device to install.</p> <div class="geshifilter"><pre class="cpp geshifilter-cpp" style="font-family:monospace;">builder <span style="color: #000080;">=</span> <span style="color: #FF0000;">'hvm'</span> vcpus <span style="color: #000080;">=</span> <span style="color: #FF0000;">'4'</span> memory <span style="color: #000080;">=</span> <span style="color: #FF0000;">'2048'</span> &nbsp; disk <span style="color: #000080;">=</span> <span style="color: #008000;">&#91;</span> <span style="color: #FF0000;">'phy:/dev/xenvg/pfsense-disk,hda,w'</span>, <span style="color: #FF0000;">'file:/root/pfSense-CE-2.4.2-RELEASE-amd64.iso,hdc:cdrom,r'</span> <span style="color: #008000;">&#93;</span> &nbsp; serial <span style="color: #000080;">=</span> <span style="color: #FF0000;">'pty'</span> &nbsp; vnc <span style="color: #000080;">=</span> <span style="color: #0000dd;">1</span> vnclisten <span style="color: #000080;">=</span> <span style="color: #FF0000;">'0.0.0.0'</span> &nbsp; boot <span style="color: #000080;">=</span> <span style="color: #FF0000;">'d'</span> &nbsp; name <span style="color: #000080;">=</span> <span style="color: #FF0000;">'pfsense'</span> &nbsp; vif <span style="color: #000080;">=</span> <span style="color: #008000;">&#91;</span> <span style="color: #FF0000;">'ip=xxx.xxx.xxx.xxx,bridge=xenbr0'</span>, <span style="color: #FF0000;">'ip=yyy.yyy.yyy.yyy,bridge=xenbr1'</span>, <span style="color: #FF0000;">'ip=zzz.zzz.zzz.zzz,bridge=xenbr2'</span>, <span style="color: #008000;">&#93;</span></pre></div> <h2>Installing pfsense</h2> <p>Create Guest (xl create) and connect with your vncviewer (<a href="https://www.realvnc.com/en/connect/download/viewer/">https://www.realvnc.com/en/connect/download/viewer/</a>)</p> <p>(Remark: We had to add internal route / tunnel to access webgui via browser)</p> <h2>After installing pfsense</h2> <p>After installing remove lines for booting and vnc:</p> <div class="geshifilter"><pre class="cpp geshifilter-cpp" style="font-family:monospace;">builder <span style="color: #000080;">=</span> <span style="color: #FF0000;">'hvm'</span> vcpus <span style="color: #000080;">=</span> <span style="color: #FF0000;">'4'</span> memory <span style="color: #000080;">=</span> <span style="color: #FF0000;">'2048'</span> &nbsp; disk <span style="color: #000080;">=</span> <span style="color: #008000;">&#91;</span> <span style="color: #FF0000;">'phy:/dev/xenvg/pfsense-disk,hda,w'</span> <span style="color: #008000;">&#93;</span> &nbsp; serial <span style="color: #000080;">=</span> <span style="color: #FF0000;">'pty'</span> &nbsp; name <span style="color: #000080;">=</span> <span style="color: #FF0000;">'pfsense'</span> &nbsp; vif <span style="color: #000080;">=</span> <span style="color: #008000;">&#91;</span> <span style="color: #FF0000;">'ip=xxx.xxx.xxx.xxx,bridge=xenbr0'</span>, <span style="color: #FF0000;">'ip=yyy.yyy.yyy.yyy,bridge=xenbr1'</span>, <span style="color: #FF0000;">'ip=zzz.zzz.zzz.zzz,bridge=xenbr2'</span>, <span style="color: #008000;">&#93;</span></pre></div> <h2>Important Network-settings</h2> <p>Under https://&lt;your_host&gt;/system_advanced_network.php you have to check following options (check to disable):</p> <ul><li>Hardware Checksum Offloading</li> <li>Hardware TCP Segmentation Offloading</li> <li>Hardware Large Receive Offloading</li> </ul><p> </p> <p> </p></div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/server" class="label label-default" hreflang="de">Server</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/de/tags/xen" class="label label-default" hreflang="de">xen</a> <a href="/de/tags/ubuntu" class="label label-default" hreflang="de">ubuntu</a> <a href="/en/tags/pfsense" class="label label-default" hreflang="en">pfsense</a> </div> Sun, 17 Dec 2017 16:43:23 +0000 kelly 130 at https://blog.werk21.de Dealing with *DEPTH TOO GREAT* in Kint https://blog.werk21.de/en/2017/12/13/dealing-depth-too-great-kint <span>Dealing with *DEPTH TOO GREAT* in Kint</span> <span><span lang="" about="/en/user/8" typeof="schema:Person" property="schema:name" datatype="">patrick</span></span> <span><time datetime="2017-12-13T08:58:54+01:00" title="Wednesday, December 13, 2017 - 08:58">Wed, 12/13/2017 - 08:58</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>If you use <a href="https://drupal.org/project/devel">Devel</a>'s <span class="geshifilter"><code class="php geshifilter-php">dpm<span style="color: #009900;">(</span><span style="color: #009900;">)</span></code></span> with <a href="https://github.com/kint-php/kint">Kint</a> for debugging in Drupal 8, chances are you already encountered the message <span class="geshifilter"><code class="php geshifilter-php"><span style="color: #339933;">*</span>DEPTH TOO GREAT<span style="color: #339933;">*</span></code></span> when clicking through a deeply nested object.</p> <p>There is a reason for that: Performance. Always rendering all levels of a deeply nested object might result in either your server or your browser to run out of resources and fail. That's why there is a maximum number of levels to show. It's usually at <span class="geshifilter"><code class="php geshifilter-php"><span style="color: #cc66cc;">7</span></code></span> levels.</p> <p>If you need to inspect something that is nested further below, the best thing to do is to limit the <span class="geshifilter"><code class="php geshifilter-php">dpm<span style="color: #009900;">(</span><span style="color: #009900;">)</span></code></span> to a more explicit part of the nested variable. But sometimes you can't or don't want to do that. In those cases, you can increase the maximum levels by placing</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">kint_require<span style="color: #009900;">(</span><span style="color: #009900;">)</span><span style="color: #339933;">;</span> \Kint<span style="color: #339933;">::</span><span style="color: #000088;">$maxLevels</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">8</span><span style="color: #339933;">;</span></pre></div> <p>somewhere above your <span class="geshifilter"><code class="php geshifilter-php">dpm<span style="color: #009900;">(</span><span style="color: #009900;">)</span></code></span> call. <span class="geshifilter"><code class="php geshifilter-php"><span style="color: #000088;">$maxLevels</span></code></span> is of course the maximum number of levels you want to see. If you know what you're doing, you could even use</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">\Kint<span style="color: #339933;">::</span><span style="color: #000088;">$maxLevels</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span></pre></div> <p>to remove the limit entirely. Use at your own risk.</p> </div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/drupal-8-9" class="label label-default" hreflang="de">Drupal 8/9</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/de/tags/devel" class="label label-default" hreflang="de">Devel</a> <a href="/en/tags/kint" class="label label-default" hreflang="en">Kint</a> <a href="/en/tags/dpm" class="label label-default" hreflang="en">dpm</a> </div> Wed, 13 Dec 2017 07:58:54 +0000 patrick 129 at https://blog.werk21.de Change source id mapping of a Drupal 8 migration https://blog.werk21.de/en/2017/12/13/change-source-id-mapping-drupal-8-migration <span>Change source id mapping of a Drupal 8 migration</span> <span><span lang="" about="/en/user/8" typeof="schema:Person" property="schema:name" datatype="">patrick</span></span> <span><time datetime="2017-12-13T06:57:34+01:00" title="Wednesday, December 13, 2017 - 06:57">Wed, 12/13/2017 - 06:57</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>Drupal Core's Migrate API maintains an internal table mapping unique source ids to destination ids. This is usually done via a database table that holds the field values that together uniquely identify a source row and the matching destination id of the entity in Drupal. The field names and types that uniquely identify a source row are provided by the source plugin of a migration. In most cases, you just have some kind of an id column, but migrate supports any number of fields for the primary key of the source row.</p> <p>Recently I was dealing with a migration that was using the <span class="geshifilter"><code class="php geshifilter-php">Url</code></span> source plugin provided by <a href="https://drupal.org/project/migrate_plus">Migrate Plus</a> to import files from an <span class="geshifilter"><code class="php geshifilter-php">XML</code></span> source. The source plugins provided by Migrate Plus allow you to specify the ids returned by <a href="https://api.drupal.org/api/drupal/core%21modules%21migrate%21src%21Plugin%21MigrateSourceInterface.php/function/MigrateSourceInterface%3A%3AgetIds/8.4.x">MigrateSourceInterface::getIds()</a> in the <span class="geshifilter"><code class="php geshifilter-php">YML</code></span> file of your migrations. Originally I used a simple id map like this:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">source<span style="color: #339933;">:</span> ids<span style="color: #339933;">:</span> id<span style="color: #339933;">:</span> type<span style="color: #339933;">:</span> integer</pre></div> <p>Unfortunately, I later noticed that I needed to add the file name as a second key to the id map, so I changed the YML file to something like this:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"> ids<span style="color: #339933;">:</span> id<span style="color: #339933;">:</span> type<span style="color: #339933;">:</span> integer file_name<span style="color: #339933;">:</span> type<span style="color: #339933;">:</span> string</pre></div> <p>So far so good. When I wanted to update the migration, I was greeted by this error message:</p> <blockquote> <p>Migration failed with source plugin exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column "sourceid2" in<br /> "field list": INSERT INTO {migrate_map_example_file} (source_ids_hash, sourceid1, sourceid2, source_row_status,<br /> rollback_action, hash, last_imported) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2,<br /> :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6); Array<br /> (<br />     [:db_insert_placeholder_0] =&gt; a8d0cbb8ca5f48c73993244fd275342d84b92a2eb33300b0852ef560f70aa55d<br />     [:db_insert_placeholder_1] =&gt; 10817<br />     [:db_insert_placeholder_2] =&gt;<br />     [:db_insert_placeholder_3] =&gt; 2<br />     [:db_insert_placeholder_4] =&gt; 0<br />     [:db_insert_placeholder_5] =&gt;<br />     [:db_insert_placeholder_6] =&gt; 1513082182<br /> )  </p> </blockquote> <p>Solving this is actually way easier than I thought. Just drop the migrate mapping table for your migration from the SQL database:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">DROP TABLE migrate_map_example_file<span style="color: #339933;">;</span></pre></div> <p>If you are less adventurous, you might just want to rename the table initially:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;"><a href="http://www.php.net/rename"><span style="color: #990000;">RENAME</span></a> TABLE migrate_map_example_file TO migrate_map_example_file_backup<span style="color: #339933;">;</span></pre></div> <p>As soon as you rerun your migration, migrate will recreate the table for you, this time using the new id mapping. Voilá.</p> </div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/drupal-8-9" class="label label-default" hreflang="de">Drupal 8/9</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/de/tags/migrate" class="label label-default" hreflang="de">migrate</a> <a href="/en/tags/migrateplus" class="label label-default" hreflang="en">migrate_plus</a> <a href="/en/tags/source" class="label label-default" hreflang="en">source</a> <a href="/en/tags/url" class="label label-default" hreflang="en">Url</a> <a href="/en/tags/migratesourceinterface" class="label label-default" hreflang="en">MigrateSourceInterface</a> <a href="/en/tags/getids" class="label label-default" hreflang="en">getIds</a> </div> Wed, 13 Dec 2017 05:57:34 +0000 patrick 128 at https://blog.werk21.de Illegal mix of collations exception caused by Drupal 8 Autocomplete with Entity Reference View https://blog.werk21.de/en/2017/09/08/illegal-mix-collations-exception-caused-drupal-8-autocomplete-entity-reference-view <span>Illegal mix of collations exception caused by Drupal 8 Autocomplete with Entity Reference View</span> <span><span lang="" about="/en/user/8" typeof="schema:Person" property="schema:name" datatype="">patrick</span></span> <span><time datetime="2017-09-08T11:48:14+02:00" title="Friday, September 8, 2017 - 11:48">Fri, 09/08/2017 - 11:48</time> </span> <div class="field field--name-body field--type-text-with-summary field--label-hidden field--item"><p>Looking at a <em>Recent log messages</em> report of one of our Drupal 8 instaces, I came across this error message:</p> <blockquote> <p><em>Drupal\Core\Database\DatabaseExceptionWrapper</em>: Exception in Media Autocomplete[media_autocomplete]: SQLSTATE[HY000]: General error: 1267 Illegal mix of collations (ascii_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation 'like': SELECT media_field_data.langcode AS media_field_data_langcode, media_field_data.mid AS mid, media_field_data.name AS media_field_data_name, media_field_data.bundle AS media_field_data_bundle FROM {media_field_data} media_field_data WHERE ((media_field_data.bundle = :db_condition_placeholder_0) AND ((media_field_data.name LIKE :db_condition_placeholder_1 ESCAPE '\\') OR (media_field_data.bundle LIKE :db_condition_placeholder_2 ESCAPE '\\'))) AND ((media_field_data.status = :db_condition_placeholder_3) AND (media_field_data.langcode IN (:db_condition_placeholder_4, :db_condition_placeholder_5, :db_condition_placeholder_6))) LIMIT 10 OFFSET 0; Array ( [:db_condition_placeholder_0] =&gt; image [:db_condition_placeholder_1] =&gt; %gläsernes labor% [:db_condition_placeholder_2] =&gt; %gläsernes labor% [:db_condition_placeholder_3] =&gt; 1 [:db_condition_placeholder_4] =&gt; de [:db_condition_placeholder_5] =&gt; und [:db_condition_placeholder_6] =&gt; zxx ) in <em>Drupal\views\Plugin\views\query\Sql-&gt;execute()</em> (line <em>1488</em> of <em>core/modules/views/src/Plugin/views/query/Sql.php</em>).</p> </blockquote> <p>Clearly, an editor was trying to use the autocomplete functionality of an entity reference field searching for media entities matching the search string "gläsernes labor" (in English: <em>transparent laboratory</em>). This would actually happen for any search string entered into the autocomplete that didn't contain ascii characters only, so in this case the "ä" in "gläsernes" was causing the exception. Looking closer at the query, we can see that the MySQL table is "media_field_data" and the search string is in two placeholders: "db_condition_placeholder_1" and "db_condition_placeholder_2". These are used to check for matches in "media_field_data.name" or "media_field_data.bundle" columns. So I asked the database for the collation of these fields:</p> <div class="geshifilter"><pre class="php geshifilter-php" style="font-family:monospace;">MariaDB <span style="color: #009900;">&#91;</span>my_drupal_8_database<span style="color: #009900;">&#93;</span><span style="color: #339933;">&gt;</span> SELECT TABLE_NAME<span style="color: #339933;">,</span> COLUMN_NAME<span style="color: #339933;">,</span> COLLATION_NAME FROM INFORMATION_SCHEMA<span style="color: #339933;">.</span>COLUMNS WHERE TABLE_SCHEMA<span style="color: #339933;">=</span><span style="color: #0000ff;">'my_drupal_8_database'</span> AND TABLE_NAME<span style="color: #339933;">=</span><span style="color: #0000ff;">'media_field_data'</span> AND COLUMN_NAME IN <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'name'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'bundle'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #339933;">+------------------+-------------+--------------------+</span> <span style="color: #339933;">|</span> TABLE_NAME <span style="color: #339933;">|</span> COLUMN_NAME <span style="color: #339933;">|</span> COLLATION_NAME <span style="color: #339933;">|</span> <span style="color: #339933;">+------------------+-------------+--------------------+</span> <span style="color: #339933;">|</span> media_field_data <span style="color: #339933;">|</span> bundle <span style="color: #339933;">|</span> ascii_general_ci <span style="color: #339933;">|</span> <span style="color: #339933;">|</span> media_field_data <span style="color: #339933;">|</span> name <span style="color: #339933;">|</span> utf8mb4_general_ci <span style="color: #339933;">|</span> <span style="color: #339933;">+------------------+-------------+--------------------+</span></pre></div> <p>Tada! The bundle column of the table uses ascii collation. For our autocomplete search to work, those two columns would need to have the same collation or we would need to change the query to specify the collation to use for each like condition separately. Another option would be to just query the name field or the bundle field.</p> <p>But why was the bundle field searched in the first place? We set up an entity reference view for this entity reference field (after applying a <a href="https://www.drupal.org/node/2174633">patch</a>, mind you ;). We did this because we wanted to show the bundle and some other stuff along the label of the entity in the results returned by the autocomplete. When we set up the view we selected "Name" and "Bundle" for the "Search fields" setting of the "Entity reference list" style plugin.</p> <p>Our client didn't really care that much about searching the bundle field, so I just removed it from the search fields. And voilá, you could enter strings with umlauts into the autocomplete again.</p></div> <div class="field field--name-field-systems field--type-entity-reference field--label-inline"> <div class="field--label">Systems</div> <a href="/de/systems/drupal-8-9" class="label label-default" hreflang="de">Drupal 8/9</a> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline"> <div class="field--label">Tags</div> <a href="/en/tags/autocomplete" class="label label-default" hreflang="en">Autocomplete</a> <a href="/de/tags/views" class="label label-default" hreflang="de">Views</a> <a href="/en/tags/entity-reference-field" class="label label-default" hreflang="en">Entity Reference Field</a> <a href="/de/tags/mysql" class="label label-default" hreflang="de">mysql</a> <a href="/en/tags/exception" class="label label-default" hreflang="en">Exception</a> </div> Fri, 08 Sep 2017 09:48:14 +0000 patrick 127 at https://blog.werk21.de