Drupal 8 - Drupal 8 - News - Help - Tutorial - And more... http://drupal8.ovh/index.php/en/rss.xml en Create Drush 9 Commands For Drupal 8 http://drupal8.ovh/index.php/en/tutoriels/385/create-drush-9-commands-drupal-8 <span class="field field--name-title field--type-string field--label-hidden">Create Drush 9 Commands For Drupal 8</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How To Write Custom Drush 9 Commands For Drupal 8 ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Thu, 06/21/2018 - 10:48</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Drush 9 is finally here with some much-awaited changes. Drush 9 commands are now classes and .inc files are obsolete. Drush commands will now be based on the Annotated Command format. This will change the fundamental structure of custom Drush commands. Drush 9.x is the only supported version of Drush in Drupal 8.4.x and later versions, so it is imperative to learn how to write custom Drush commands for Drush 9.</p> <h3> 1. Create a custom module</h3> <p>drush9_example.info.yml</p> <p><code>name: Drush 9 Commands Example<br /> description: Provides examples for writing custom Drush 9 commands.<br /> core: 8.x<br /> type: module<br /> package: Examples</code></p> <h3> 2. Add drush service</h3> <p>drush.services.yml</p> <p><code>services:<br />   drush9_example.commands:<br />     class: \Drupal\drush9_example\Commands\Drush9ExampleCommands<br />     tags:<br />       - { name: drush.command }</code></p> <h3>3. Include Drush 9 classes</h3> <p>For that, you must create / Complete your composer file like:</p> <p><code>{<br />   "name": "drupal/drush9_example",<br />   "description": "A example module for Drush 9 commands.",<br />   "type": "drupal-module",<br />   "autoload": {<br />     "psr-4": {<br />       "Drupal\\drush9_example\\": "src/"<br />     }<br />   },<br />   "extra": {<br />     "drush": {<br />       "services": {<br />         "drush.services.yml": "^9"<br />       }<br />     }<br />   }<br /> }</code></p> <h3>4. Implement drush command</h3> <p>Drush9ExampleCommands.php</p> <p><code>&lt;?php<br /> namespace Drupal\drush9_example\Commands;<br /> use Drush\Commands\DrushCommands;<br /> /**<br />  * A Drush commandfile.<br />  *<br />  * In addition to this file, you need a drush.services.yml<br />  * in root of your module, and a composer.json file that provides the name<br />  * of the services file to use.<br />  */<br /> class Drush9ExampleCommands extends DrushCommands {<br />   /**<br />    * Echos back hello with the argument provided.<br />    *<br />    * @param string $name<br />    *   Argument provided to the drush command.<br />    *<br />    * @command drush9_example:hello<br />    * @aliases d9-hello<br />    * @options arr An option that takes multiple values.<br />    * @options msg Whether or not an extra message should be displayed to the user.<br />    * @usage drush9_example:hello akanksha --msg<br />    *   Display 'Hello Akanksha!' and a message.<br />    */<br />   public function hello($name, $options = ['msg' =&gt; FALSE]) {<br />     if ($options['msg']) {<br />       $this-&gt;output()-&gt;writeln('Hello ' . $name . '! This is your first Drush 9 command.');<br />     }<br />     else {<br />       $this-&gt;output()-&gt;writeln('Hello ' . $name . '!');<br />     }<br />   }<br /> }</code></p> <p> This file uses the Annotated method for commands, which means that each command is now a separate function with annotations to define its name, alias, arguments, etc. This file can can also be used to define hooks with @hook annotation. Some of the annotations available for use are:</p> <p>@command: This annotation is used to define the Drush command. Make sure that you follow Symfony’s module:command structure for all your commands.</p> <p>@aliases: An alias for your command.</p> <p>@param: Defines the input parameters. For example, @param: integer $number</p> <p>@option: Defines the options available for the commands. This should be an associative array where the name of the option is the key and the value could be - false, true, string, InputOption::VALUE_REQUIRED, InputOption::VALUE_OPTIONAL or an empty array.</p> <p>@default: Defines the default value for options.</p> <p>@usage: Demonstrates how the command should be used. For example, @usage: mymodule:command --option</p> <p>@hook: Defines a hook to be fired. The default format is @hook type target, where type determines when the hook is called and target determines where the hook is called.</p> <p>For a complete list of all the hooks available and their usage, please refer to: https://github.com/consolidation/annotated-command</p> <p> </p> <p> Thanks to : https://www.axelerant.com/resources/team-blog/how-to-write-custom-drush-9-commands-for-drupal-8</p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/index.php/en/tags/code" hreflang="en">Code</a></li> <li><a href="/index.php/en/tags/drush" hreflang="en">Drush</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/index.php/en/tutoriels/323/create-a-custom-drush-command-on-drupal-8" hreflang="en">Create a custom DRUSH command on drupal 8</a></div> <div class="field__item"><a href="/index.php/en/tutoriels/98/useful-drush-commands" hreflang="en">Useful Drush commands</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=385&amp;2=comment&amp;3=comment" token="BvpbiSLsm2CbypbSmDx9beeikOntKhEwk_mbw1LdwVs"></drupal-render-placeholder> </section> Thu, 21 Jun 2018 08:48:49 +0000 editor 385 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/385/create-drush-9-commands-drupal-8#comments Connect to a PPTP VPN Server from Linux Terminal http://drupal8.ovh/index.php/en/tutoriels/384/connect-pptp-vpn-server-linux-terminal <span class="field field--name-title field--type-string field--label-hidden">Connect to a PPTP VPN Server from Linux Terminal</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to connect to a PPTP VPN Server from Debian (Ubuntu, Linux Mint ...) using linux terminal.</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Wed, 06/13/2018 - 17:55</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h3>Step 1 : Install pptp client.</h3> <p><code>sudo apt-get -y install pptp-linux</code></p> <h3> Step 2 : Setup PPTP Client</h3> <p>Add secret:</p> <p>File : /etc/ppp/chap-secrets<br /> You can use:<br /><code>sudo nano /etc/ppp/chap-secrets</code></p> <p>Syntax :<br /> &lt;username&gt; &lt;server_name&gt; &lt;password&gt; &lt;ip_address&gt;</p> <p>Example :<br /><code># Secrets for authentication using CHAP<br /> # client        server  secret                  IP addresses<br /> yourname         myvpn YourPassword             *</code></p> <h3>Step 3 : Create VPN connection:</h3> <p>Example for myvpn<br /><code>sudo nano /etc/ppp/peers/myvpn</code></p> <p>Example:<br /><code>pty "pptp IP-OR-HOST-NAME --nolaunchpppd"<br /> name yourname<br /> remotename myvpn<br /> require-mppe-128<br /> file /etc/ppp/options.pptp<br /> ipparam myvpn</code></p> <h3> Step 4 : Create a route script that will get run after the PPP connection establishes.</h3> <p>Create file :<br /><code>sudo nano /etc/ppp/ip-up.d/99vpnroute</code><br /> Then add:</p> <p><code>#!/bin/bash<br /> if [ "$PPP_IPPARAM" == "myvpn" ]; then<br />         route add -net 192.168.20.0/24 dev $PPP_IFACE<br /> fi</code></p> <p> Then Make the vpn route script executable:</p> <p><code>sudo chmod +x /etc/ppp/ip-up.d/99vpnroute</code></p> <p> </p> <h2>Connecting to the PPTP VPN Server</h2> <p>To connect to the remote PPTP VPN server, issue the following command:</p> <p><code>sudo pon myvpn<br /> #or<br /> sudo pppd call myvpn</code></p> <h2> Disconnecting from the PPTP VPN Server</h2> <p>The simplest way to disconnect from the PPP connection is to use the following command:</p> <p><code>sudo poff myvpn<br /> #To kill all active PPP connections, you can use the following:<br /> sudo killall pppd<br /> or<br /> sudo kill `cat /var/run/ppp0.pid`</code></p> <h3> Log:</h3> <p>If the ppp connection doesn’t get established, check the /var/log/FILE log file for errors:</p> <p><code>sudo tail -f /var/log/syslog<br /> sudo tail -f /var/log/lastlog<br /> sudo tail -n 25 /var/log/THE_LOG_FILE</code></p> <p> </p> <p> </p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/linux" hreflang="en">Linux</a></li> <li><a href="/index.php/en/tags/services" hreflang="en">Services</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/index.php/en/tutoriels/375/setup-pptp-vpn-server-debianubuntu-linux" hreflang="en">Setup PPTP VPN Server on Debian/Ubuntu Linux</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=384&amp;2=comment&amp;3=comment" token="4aIU0h4-LpfNtLDa7KtcH-i7PPexW4hSiuz8CVbU9dY"></drupal-render-placeholder> </section> Wed, 13 Jun 2018 15:55:28 +0000 editor 384 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/384/connect-pptp-vpn-server-linux-terminal#comments rsync : Backup data on linux http://drupal8.ovh/index.php/en/tutoriels/383/rsync-backup-data-linux <span class="field field--name-title field--type-string field--label-hidden">rsync : Backup data on linux</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to backup directories from local to remote ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Mon, 06/11/2018 - 10:19</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>rsync is a powerfull tool to synchronize the files and directories. Can be use for local or remote using ssh.</p> <p>Source Tutorial : https://www.thegeekstuff.com/2010/09/rsync-command-examples/</p> <p><strong>Syntax</strong><br /><code>rsync options source destination</code></p> <p> </p> <h2>Examples</h2> <p> </p> <h3>Example 1. Synchronize Two Directories in a Local Server</h3> <p>To sync two directories in a local computer, use the following rsync -zvr command.</p> <p><code>$ rsync -zvr /var/opt/installation/inventory/ /root/temp</code></p> <p>In the above rsync example:</p> <p>-z is to enable compression<br /> -v verbose<br /> -r indicates recursive</p> <p> </p> <h3> Example 2. Preserve timestamps during Sync using rsync -a</h3> <p>rsync option -a indicates archive mode. -a option does the following,<br />     Recursive mode<br />     Preserves symbolic links<br />     Preserves permissions<br />     Preserves timestamp<br />     Preserves owner and group</p> <p>Now, executing the same command provided in example 1 (But with the rsync option -a) as shown below:</p> <p><code>$ rsync -azv /var/opt/installation/inventory/ /root/temp/</code></p> <h3> Example 3. Synchronize Only One File</h3> <p>To copy only one file, specify the file name to rsync command, as shown below.</p> <p><code>$ rsync -v /var/lib/rpm/Pubkeys /root/temp/Pubkeys</code></p> <h3> Example 4. Synchronize Files From Local to Remote</h3> <p>rsync allows you to synchronize files/directories between the local and remote system.</p> <p><code>$ rsync -avz /root/temp/ username@192.168.200.10:/home/me/temp/</code></p> <p>While doing synchronization with the remote server, you need to specify username and ip-address of the remote server. You should also specify the destination directory on the remote server. The format is username@machinename:path</p> <p>As you see above, it asks for password while doing rsync from local to remote server.</p> <p>Sometimes you don’t want to enter the password while backing up files from local to remote server. For example, If you have a backup shell script, that copies files from local to remote server using rsync, you need the ability to rsync without having to enter the password.</p> <p>To do that, setup ssh password less login as we explained earlier.</p> <h3> Example 5. Synchronize Files From Remote to Local</h3> <p>When you want to synchronize files from remote to local, specify remote path in source and local path in target as shown below.</p> <p><code>$ rsync -avz username@192.168.200.10:/var/lib/rpm /root/temp</code></p> <h3> Example 6. Remote shell for Synchronization</h3> <p>rsync allows you to specify the remote shell which you want to use. You can use rsync ssh to enable the secured remote connection.</p> <p>Use rsync -e ssh to specify which remote shell to use. In this case, rsync will use ssh.</p> <p><code>$ rsync -avz -e ssh username@192.168.200.10:/var/lib/rpm /root/temp</code></p> <h3> Example 7. Do Not Overwrite the Modified Files at the Destination</h3> <p>In a typical sync situation, if a file is modified at the destination, we might not want to overwrite the file with the old file from the source.</p> <p>Use rsync -u option to do exactly that. (i.e do not overwrite a file at the destination, if it is modified). In the following example, the file called Basenames is already modified at the destination. So, it will not be overwritten with rsync -u.</p> <p><code>$ rsync -avzu username@192.168.200.10:/var/lib/rpm /root/temp</code></p> <h3> Example 8. Synchronize only the Directory Tree Structure (not the files)</h3> <p>Use rsync -d option to synchronize only directory tree from source to the destination. The below example, synchronize only directory tree in recursive manner, not the files in the directories.</p> <p><code>$ rsync -v -d username@192.168.200.10:/var/lib/ .</code></p> <h3> Example 9. View the rsync Progress during Transfer</h3> <p> When you use rsync for backup, you might want to know the progress of the backup. i.e how many files are copies, at what rate it is copying the file, etc.</p> <p>rsync –progress option displays detailed progress of rsync execution as shown below.</p> <p><code>$ rsync -avz --progress username@192.168.200.10:/var/lib/rpm/ /root/temp/</code></p> <p> You can also use rsnapshot utility (that uses rsync) to backup local linux server, or backup remote linux server.</p> <h3> Example 10. Delete the Files Created at the Target</h3> <p>If a file is not present at the source, but present at the target, you might want to delete the file at the target during rsync.<br /> In that case, use –delete option as shown below. rsync delete option deletes files that are not there in source directory.</p> <p><code>$ rsync -avz --delete username@192.168.200.10:/var/lib/rpm/ .</code></p> <h3> Example 11. Do not Create New File at the Target</h3> <p>If you like, you can update (Sync) only the existing files at the target. In case source has new files, which is not there at the target, you can avoid creating these new files at the target. If you want this feature, use –existing option with rsync command.</p> <p><code>$ rsync -avz --existing root@192.168.1.2:/var/lib/rpm/ .</code></p> <p> </p> <h3>Example 12. View the Changes Between Source and Destination</h3> <p>This option is useful to view the difference in the files or directories between source and destination.<br /> In the above example, between the source and destination, there are two differences. First, owner and group of the file Dirname differs. Next, size differs for the file Basenames.</p> <p>Now let us see how rsync displays this difference. -i option displays the item changes.</p> <p><code>$ rsync -avzi username@192.168.200.10:/var/lib/rpm/ /root/temp/</code></p> <h3> Example 13. Include and Exclude Pattern during File Transfer</h3> <p>rsync allows you to give the pattern you want to include and exclude files or directories while doing synchronization.</p> <p><code>$ rsync -avz --include 'P*' --exclude '*' username@192.168.200.10:/var/lib/rpm/ /root/temp/</code></p> <p>In the above example, it includes only the files or directories starting with ‘P’ (using rsync include) and excludes all other files. (using rsync exclude ‘*’ )</p> <h3> Example 14. Do Not Transfer Large Files</h3> <p>You can tell rsync not to transfer files that are greater than a specific size using rsync –max-size option.</p> <p><code>$ rsync -avz --max-size='100K' username@192.168.200.10:/var/lib/rpm/ /root/temp/</code></p> <p>max-size=100K makes rsync to transfer only the files that are less than or equal to 100K. You can indicate M for megabytes and G for gigabytes.</p> <h3> Example 15. Transfer the Whole File</h3> <p>One of the main feature of rsync is that it transfers only the changed block to the destination, instead of sending the whole file.</p> <p>If network bandwidth is not an issue for you (but CPU is), you can transfer the whole file, using rsync -W option. This will speed-up the rsync process, as it doesn’t have to perform the checksum at the source and destination.</p> <p><code>$ rsync -avzW  username@192.168.200.10:/var/lib/rpm/ /root/temp</code></p> <p> </p> <p> </p> <p> </p> <p> </p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/linux" hreflang="en">Linux</a></li> <li><a href="/index.php/en/tags/utility" hreflang="en">Utility</a></li> <li><a href="/index.php/en/tags/server" hreflang="en">Server</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/index.php/en/tutoriels/113/mysql-backup-restore-syntax" hreflang="en">Mysql Database Backup / Restore Syntax</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=383&amp;2=comment&amp;3=comment" token="p2_QyR4K5e-RYcszgbOc58tEyrDPu4EB6Nn-u3Su5CM"></drupal-render-placeholder> </section> Mon, 11 Jun 2018 08:19:47 +0000 editor 383 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/383/rsync-backup-data-linux#comments Mount LUKS encrypted volumes from command line http://drupal8.ovh/index.php/en/tutoriels/382/mount-luks-encrypted-volumes-command-line <span class="field field--name-title field--type-string field--label-hidden">Mount LUKS encrypted volumes from command line</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to mount encrypted volumes from command line on linux (debian based) ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Wed, 05/30/2018 - 15:57</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h2>Mount a linux partition encrypted with LUKS using terminal</h2> <h3>Install Crypsetup:</h3> <p><code>sudo apt-get install cryptsetup </code></p> <h3>To decrypt the volume:</h3> <p><code>sudo cryptsetup luksOpen /dev/sda1 my_encrypted_volume </code></p> <h3>Mount:</h3> <p><code>sudo mkdir /media/my_device<br /> sudo mount /dev/mapper/my_encrypted_volume /media/my_device </code></p> <h3>Unmount:</h3> <p><code>sudo umount /media/my_device<br /> sudo cryptsetup luksClose my_encrypted_volume </code></p> <h3> </h3> <h3>To automatically put it in the<span> </span><code>/media</code><span> </span>location, use the udisks tool</h3> <p><code>sudo udisks --mount /dev/mapper/my_encrypted_volume</code></p> <p> </p> <h2>Errors</h2> <p><code>mount: unknown filesystem type 'LVM2_member'</code></p> <h3>Solution</h3> <p>Run:<br /><code>sudo apt-get install lvm2 sudo lvscan </code></p> <p>Then activate all LVM you see<br /><code>sudo vgchange -ay </code></p> <p>Then re-run the mount:<br /><code>sudo mount /dev/mapper/my_encrypted_volume /media/my_device</code></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/linux" hreflang="en">Linux</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/index.php/en/tutoriels/211/mount-a-luks-encrypted-partition-on-linux-boot" hreflang="en">Mount a LUKS Encrypted partition on Linux boot</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title">Comments</h2> <a id="comment-534"></a> <article role="article" data-comment-user-id="0" about="/index.php/en/comment/534" typeof="schema:Comment" class="comment js-comment by-anonymous clearfix"> <span class="hidden" data-comment-timestamp="1528188674"></span> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__author"><span rel="schema:author"><span lang="" typeof="schema:Person" property="schema:name" datatype="">Anonymous (not verified)</span></span> </p> <p class="comment__time">Tue, 06/05/2018 - 10:51 <span property="schema:dateCreated" content="2018-06-05T08:51:14+00:00" class="rdf-meta hidden"></span> </p> <p class="comment__permalink"><a href="/index.php/en/comment/534#comment-534" hreflang="en">Permalink</a></p> </footer> <div class="comment__content"> <h3 property="schema:name" datatype=""><a href="/index.php/en/comment/534#comment-534" class="permalink" rel="bookmark" hreflang="en">Another example of error :…</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><h3>Another example of error :</h3> <p>Error unlocking /dev/sdb2: Error spawning command-line `cryptsetup luksOpen "/dev/sdb2" "luks-ac0dc77b-68a4-...." ': Failed to execute child process "cryptsetup" (No such file or directory) (g-exec-error-quark, 8)</p> <h3>Solution :</h3> <p>Install cryptsetup</p> <p><code>sudo apt-get install cryptsetup</code></p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=534&amp;1=default&amp;2=en&amp;3=" token="1uEsz8oQhf0PVuUa5vRnS8mvjVRgDMXU6B2BqSPTcqk"></drupal-render-placeholder> </div> </article> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=382&amp;2=comment&amp;3=comment" token="ezceBAYEa4Ts0nP-b0Z5GrcVqwSQ5Mp18OYjDCMaKk8"></drupal-render-placeholder> </section> Wed, 30 May 2018 13:57:18 +0000 editor 382 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/382/mount-luks-encrypted-volumes-command-line#comments Search Entities when using Domain Access http://drupal8.ovh/index.php/en/tutoriels/381/search-entities-when-using-domain-access <span class="field field--name-title field--type-string field--label-hidden">Search Entities when using Domain Access</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to fiend entities when using domain access ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Wed, 05/23/2018 - 22:14</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h2>Example 1 : Without changing user session.</h2> <p><code>$query = \Drupal::entityQuery('node');<br /> $query-&gt;condition(DOMAIN_ACCESS_FIELD, 'domain_id'); // Set the domain id hear<br /> $query-&gt;condition('type', 'article');<br /> $query-&gt;condition('status', 1);<br /> $nids = $query-&gt;execute();<br /> print_r($nids);</code></p> <p><strong>If you can't get all domains data, do as the Example 2.</strong></p> <h2>Example 2 : Using admin user session.</h2> <p><code>// Call the account switcher service<br /> $accountSwitcher = \Drupal::service('account_switcher');<br /> // Switch to the admin user<br /> $accountSwitcher-&gt;switchTo(new \Drupal\Core\Session\UserSession(['uid' =&gt; 1]));</code></p> <p><code>$query = \Drupal::entityQuery('node');<br /> $query-&gt;condition(DOMAIN_ACCESS_FIELD, 'domain_id'); // Set the domain id hear<br /> $query-&gt;condition('type', 'article');<br /> $query-&gt;condition('status', 1);<br /> $nids = $query-&gt;execute();<br /> print_r($nids);</code></p> <p><code>// Switch back to old session.<br /> $accountSwitcher-&gt;switchBack();</code></p> <p> </p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/index.php/en/tags/code" hreflang="en">Code</a></li> <li><a href="/index.php/en/tags/entity" hreflang="en">Entity</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/index.php/en/tutoriels/380/switch-user-sessions-using-account-switcher-service" hreflang="en">Switch user sessions using Account Switcher service</a></div> <div class="field__item"><a href="/index.php/en/tutoriels/149/find-entity-using-drupal-entityquery" hreflang="en">Find Entity using Drupal EntityQuery</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=381&amp;2=comment&amp;3=comment" token="8DqiNAoog9QjCq9bCEkw9A0yOcMU7UGLZWyxgs6-HgM"></drupal-render-placeholder> </section> Wed, 23 May 2018 20:14:15 +0000 editor 381 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/381/search-entities-when-using-domain-access#comments Switch user sessions using Account Switcher service http://drupal8.ovh/index.php/en/tutoriels/380/switch-user-sessions-using-account-switcher-service <span class="field field--name-title field--type-string field--label-hidden">Switch user sessions using Account Switcher service</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to switch user sessions using account switcher (account_switcher) service ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Wed, 05/23/2018 - 22:12</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Example:</p> <p><code>use Drupal\Core\Session\UserSession;<br /> //<br /> // Call the account switcher service<br /> $accountSwitcher = \Drupal::service('account_switcher');<br /> // Switch to the admin user<br /> $accountSwitcher-&gt;switchTo(new \Drupal\Core\Session\UserSession(['uid' =&gt; 1]));<br /> //<br /> // Your Code Hear...<br /> //<br /> // Switch back to old session.<br /> $accountSwitcher-&gt;switchBack();</code></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/index.php/en/tags/code" hreflang="en">Code</a></li> <li><a href="/index.php/en/tags/services" hreflang="en">Services</a></li> </ul> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=380&amp;2=comment&amp;3=comment" token="C_eZjPP6S5DWHqzgqJ-wunsX2zLe5FWrt20pXuPz6CY"></drupal-render-placeholder> </section> Wed, 23 May 2018 20:12:52 +0000 editor 380 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/380/switch-user-sessions-using-account-switcher-service#comments Add rc.local to Debian 9 Stretch http://drupal8.ovh/index.php/en/tutoriels/379/add-rclocal-debian-9-stretch <span class="field field--name-title field--type-string field--label-hidden">Add rc.local to Debian 9 Stretch</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to Add /etc/rc.local to Debian 9 Stretch ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Tue, 05/15/2018 - 21:30</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>/etc/rc.local is depricated on debian 9.</p> <p>You can try this to add it. (Not tested)</p> <p> </p> <p>1) Create the file : /etc/systemd/system/rc-local.service</p> <p><code># nano /etc/systemd/system/rc-local.service</code></p> <p>2) Copy this text.</p> <p><code>[Unit]<br /> Description=/etc/rc.local Compatibility<br /> ConditionPathExists=/etc/rc.local</code></p> <p>[Service]<br /> Type=forking<br /> ExecStart=/etc/rc.local start<br /> TimeoutSec=0<br /> StandardOutput=tty<br /> RemainAfterExit=yes<br /> SysVStartPriority=99</p> <p>[Install]<br /> WantedBy=multi-user.target</p> <p>3) Create file : /etc/rc.local</p> <p><code># nano /etc/rc.local</code></p> <p>5) Add this text to the file</p> <p><code>#!/bin/sh -e<br /> #<br /> # rc.local<br /> #<br /> # This script is executed at the end of each multiuser runlevel.<br /> # Make sure that the script will "exit 0" on success or any other<br /> # value on error.<br /> #<br /> # In order to enable or disable this script just change the execution<br /> # bits.<br /> #<br /> # By default this script does nothing.</code></p> <p><code>exit 0</code></p> <p>6) Make the script executable : /etc/rc.local</p> <p><code># chmod +x /etc/rc.local</code></p> <p>7) Activate on boot</p> <p><code># systemctl enable rc-local</code></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/linux" hreflang="en">Linux</a></li> <li><a href="/index.php/en/tags/server" hreflang="en">Server</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/index.php/en/tutoriels/375/setup-pptp-vpn-server-debianubuntu-linux" hreflang="en">Setup PPTP VPN Server on Debian/Ubuntu Linux</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=379&amp;2=comment&amp;3=comment" token="l1_AOE2GUP8FxSRlmWtYrFtArYX04QH3BVoF4rDMSC4"></drupal-render-placeholder> </section> Tue, 15 May 2018 19:30:35 +0000 editor 379 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/379/add-rclocal-debian-9-stretch#comments Mount SAMBA NFS share folder on linux http://drupal8.ovh/index.php/en/tutoriels/378/mount-samba-nfs-share-folder-linux <span class="field field--name-title field--type-string field--label-hidden">Mount SAMBA NFS share folder on linux</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to access to a SAMBA shared folder from linux (ubuntu, debian, mint ...) ?<br /> How to mount samba partition on linux ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Fri, 05/11/2018 - 09:51</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><h2>Access to a SAMBA file share from a file explorer</h2> <p>Juste enter the address of your share like:<br /> smb://&lt;IP or HOST&gt;/&lt;Folder&gt;<br /> Example:<br /><code>smb://192.168.0.1/DATA<br /> smb://192.168.0.1/</code></p> <h2>Mount samba folder from terminal via shell command</h2> <p>Hear, for the example, we weill mount smb://192.168.0.1/DATA to /media/DATA<br /> NOTE : The folder /media/DATA must exist (mkdir /media/DATA)</p> <p>Example 1:<br /><code>sudo mount -t cifs //192.168.0.1/DATA -o username=USER,password=SAMBA-PASSWORD,iocharset=utf8,file_mode=0777,dir_mode=0777, /media/DATA</code><br /> Example 2: mount as user=me<br /><code>sudo mount -t cifs //192.168.0.1/DATA -o username=USER,password=SAMBA-PASSWORD,uid=me,gid=me,iocharset=utf8,file_mode=0777,dir_mode=0777, /media/DATA</code></p> <h2> Mount samba share automatically on boot of linux (CIFS)</h2> <p>Edit the file <strong><code>/etc/fstab</code></strong> and add your share (<code>nano /etc/fstab</code>)</p> <p>Example 1 :<br /><code>//192.168.0.1/DATA /media/DATA/ cifs nofail,rw 0 0</code><br /> Example 2 :<br /><code>//192.168.0.1/DATA /media/DATA/ cifs nofail,rw,guest,iocharset=utf8,file_mode=0777,dir_mode=0777,noperm 0 0</code><br /> Example 3 : with User and Password via<br /><code>//192.168.0.1/DATA /media/DATA/ cifs nofail,rw,guest,iocharset=utf8,file_mode=0777,dir_mode=0777,auto,users,credentials=/root/data/.smbcred 0 0</code></p> <p>Then create file /root/data/.smbcred and enter the user name/Password like :</p> <p><code>username=me<br /> password=myPassword<br /> domain=WORKGROUP</code></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/shell" hreflang="en">Shell</a></li> <li><a href="/index.php/en/tags/linux" hreflang="en">Linux</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/index.php/en/tutoriels/203/create-a-cifs-samba-network-share-on-linux" hreflang="en">Create a CIFS - SAMBA Network Share on Linux</a></div> <div class="field__item"><a href="/index.php/en/tutoriels/197/mount-and-fstab-on-linux" hreflang="en">Mount and fstab on Linux</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=378&amp;2=comment&amp;3=comment" token="5829n6wfpe7RAcRcwjQYM0cDU6aEZ6g8P_WtSe8wtZc"></drupal-render-placeholder> </section> Fri, 11 May 2018 07:51:56 +0000 editor 378 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/378/mount-samba-nfs-share-folder-linux#comments Configure PhpStorm for Drupal coding standards http://drupal8.ovh/index.php/en/tutoriels/377/configure-phpstorm-drupal-coding-standards <span class="field field--name-title field--type-string field--label-hidden">Configure PhpStorm for Drupal coding standards</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to configure phpstorm for drupal coding standards / Development ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Fri, 05/04/2018 - 10:36</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Change default settings of PhpStorm.</p> <p>File -&gt; Default settings -&gt; Editor -&gt; Code Style -&gt; PHP</p> <p>Drupal recommends less than 80 characters per line.<br /> Set "Tab size", "Indent" and "Continuation indent" to 2</p> <p>On the "Wrapping and Braces tab", make sure these settings are set correctly:</p> <p>Keep control statements in one line should be unchecked<br /> Place braces in class declaration should be unchecked<br /> Place braces in function declaration should be unchecked<br /> Always force braces for if() statements should be checked<br /> Force braces for while() statements should be checked<br /> Else on new line for if() statements should be checked<br /> 'While' on new line for do...while() statements should be checked<br /> 'Catch' on new line for for try() statements should be checked<br /> Chop down Array initializer if long should be checked<br /> New line after ( for Array initializer should be checked<br /> Place ) on new line for Array initializer should be checked</p> <p>You can also use my predefined file from hear : <a href="https://drupal8.ovh/sites/drupal/files/2018-05/Default_PhpStorm_Style.xml_.zip" rel="nofollow">Default_PhpStorm_Style.xml_.zip</a><br /> Import download the file, unzip and Import from :<br /> File -&gt; Default settings -&gt; Editor -&gt; Code Style<br /> --&gt; Gear icon -&gt; Import scheme -&gt; Intelij....XML</p> <p><a rel="nofollow"> </a></p> <p> </p> </div> <div class="field field--name-field-file field--type-file field--label-inline"> <div class="field__label">File</div> <div class="field__item"> <span class="file file--mime-application-zip file--package-x-generic"> <a href="http://drupal8.ovh/sites/drupal/files/2018-05/Default_PhpStorm_Style.xml_.zip" type="application/zip; length=744">Default_PhpStorm_Style.xml_.zip</a></span> </div> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/drupal-8" hreflang="en">Drupal 8</a></li> <li><a href="/index.php/en/tags/ide" hreflang="en">IDE</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/index.php/en/tutoriels/204/phpstorm-ide-develop-drupal-modules" hreflang="en">PhpStorm IDE - Develop drupal modules</a></div> <div class="field__item"><a href="/index.php/en/tutoriels/327/drupal-coding-standard-and-best-practice" hreflang="en">Drupal coding Standard and Best Practice</a></div> <div class="field__item"><a href="/index.php/en/tutoriels/195/add-phpstorm-icon-to-linux-ubuntu-menu" hreflang="en">Add PhpStorm icon To Linux ubuntu Menu</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title">Comments</h2> <a id="comment-540"></a> <article role="article" data-comment-user-id="0" about="/index.php/en/comment/540" typeof="schema:Comment" class="comment js-comment by-anonymous clearfix"> <span class="hidden" data-comment-timestamp="1529476831"></span> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__author"><span rel="schema:author"><span lang="" typeof="schema:Person" property="schema:name" datatype="">AlfredLandy (not verified)</span></span> </p> <p class="comment__time">Wed, 06/20/2018 - 08:40 <span property="schema:dateCreated" content="2018-06-20T06:40:31+00:00" class="rdf-meta hidden"></span> </p> <p class="comment__permalink"><a href="/index.php/en/comment/540#comment-540" hreflang="en">Permalink</a></p> </footer> <div class="comment__content"> <h3 property="schema:name" datatype=""><a href="/index.php/en/comment/540#comment-540" class="permalink" rel="bookmark" hreflang="en">phpstorm</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p><span><span><span>It was really helpful to read your post on Configure Php Storm for Drupal coding standards. Because I was in search of this configuration settings. Your post was much helpful for me, as you explained simple words and that too clearly by step by step. If you are in search of online writing service then please contact with the </span> <a href="https://triumphessays.com/" rel="nofollow">best essay writing service</a> which will help you to achieve genuine essays at cheap price and in short time period. Thanks for sharing this post with us.</span></span></p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=540&amp;1=default&amp;2=en&amp;3=" token="qAvoTFbVGz3QFDnMMEFkVJBX4QNKAaKh6ZmMeyZ7gnI"></drupal-render-placeholder> </div> </article> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=377&amp;2=comment&amp;3=comment" token="FUlwX1fkMxYfo8bhmZcLRR4c3JrgF6kRQiK3AaQzynY"></drupal-render-placeholder> </section> Fri, 04 May 2018 08:36:40 +0000 editor 377 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/377/configure-phpstorm-drupal-coding-standards#comments Install GitLab Community Edition http://drupal8.ovh/index.php/en/tutoriels/376/install-gitlab-community-edition <span class="field field--name-title field--type-string field--label-hidden">Install GitLab Community Edition</span> <div class="clearfix text-formatted field field--name-field-question field--type-text-long field--label-above"> <div class="field__label">Question</div> <div class="field__item"><p>How to install gitlab GitLab Community Edition on linux ?</p> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/index.php/en/users/editor" typeof="schema:Person" property="schema:name" datatype="">editor</span></span> <span class="field field--name-created field--type-created field--label-hidden">Thu, 05/03/2018 - 10:18</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>The official tutorial is hear : https://about.gitlab.com/installation/#debian?version=ce<br /> CE or EE : https://about.gitlab.com/installation/ce-or-ee/?distro=debian</p> <h2>Install Community Edition on Debian Linux.</h2> <h3>Prepare: Install and configure the necessary dependencies</h3> <p><code>sudo apt-get install -y curl openssh-server ca-certificates<br /> sudo apt-get install -y postfix</code></p> <h3> Install GitLab</h3> <p>(Replace gitlab.example.com by your git domain name or add gitlab.example.com to hosts)</p> <p><code>curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.deb.sh | sudo bash<br /> sudo EXTERNAL_URL="http://gitlab.example.com" apt-get install gitlab-ce</code></p> <p> Visit and Use the default account's username root to login.</p> <p>Documentation : https://docs.gitlab.com/omnibus/README.html#installation-and-configuration-using-omnibus-package</p> <p> </p> <h3>GitLab configuration</h3> <p>Edit configuration file : <br /> /etc/gitlab/gitlab.rb</p> <p>Note : GitLab was unable to detect a valid hostname for your instance. Please configure a URL for your GitLab instance by setting `external_url`</p> <p>Reload configuration:<br /><code>sudo gitlab-ctl reconfigure</code></p> </div> <div class="field field--name-field-tags field--type-entity-reference field--label-inline clearfix"> <h3 class="field__label inline">Tags</h3> <ul class="links field__items"> <li><a href="/index.php/en/tags/server" hreflang="en">Server</a></li> <li><a href="/index.php/en/tags/git" hreflang="en">Git</a></li> <li><a href="/index.php/en/tags/linux" hreflang="en">Linux</a></li> </ul> </div> <div class="field field--name-field-related-contents field--type-entity-reference field--label-hidden field__items"> <div class="field__item"><a href="/index.php/en/tutoriels/157/git-ignore-files-directories-permissions" hreflang="en">Git - Ignore Files, Directories, Permissions</a></div> <div class="field__item"><a href="/index.php/en/tutoriels/11/helpful-git-commands" hreflang="en">Helpful git commands</a></div> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title comment-form__title">Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=376&amp;2=comment&amp;3=comment" token="qG3aoIwBiJOBfZsJ-8s8KWcwa_WWpFypri_1Fu1ACOk"></drupal-render-placeholder> </section> Thu, 03 May 2018 08:18:38 +0000 editor 376 at http://drupal8.ovh http://drupal8.ovh/index.php/en/tutoriels/376/install-gitlab-community-edition#comments