<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: alfiosalanitri</title>
    <description>The latest articles on DEV Community by alfiosalanitri (@alfiosalanitri).</description>
    <link>https://dev.to/alfiosalanitri</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F165128%2Ff0ed3993-c1a9-40be-ac0a-b03fcaba7d34.jpg</url>
      <title>DEV Community: alfiosalanitri</title>
      <link>https://dev.to/alfiosalanitri</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alfiosalanitri"/>
    <language>en</language>
    <item>
      <title>Bash script to backup directories and mysql databases from source file to any location</title>
      <dc:creator>alfiosalanitri</dc:creator>
      <pubDate>Sat, 19 Mar 2022 17:33:17 +0000</pubDate>
      <link>https://dev.to/alfiosalanitri/bash-script-for-linux-to-backup-one-or-more-directories-and-mysql-databases-to-external-usb-device-4gja</link>
      <guid>https://dev.to/alfiosalanitri/bash-script-for-linux-to-backup-one-or-more-directories-and-mysql-databases-to-external-usb-device-4gja</guid>
      <description>&lt;p&gt;This script can create a tar archive of all directories listed inside a .txt file and&lt;br&gt;
can exclude others directories from exclude.txt file. &lt;/p&gt;

&lt;p&gt;Also it can backup all mysql databases in separated .sql files if &lt;a href="https://github.com/alfiosalanitri/backup-mysql" rel="noopener noreferrer"&gt;backup-mysql script&lt;/a&gt; is installed.&lt;/p&gt;

&lt;p&gt;The tar archive will be copied to any directory like usb device if there are available free space. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/alfiosalanitri/backup-to-device" rel="noopener noreferrer"&gt;Download from github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bash</category>
      <category>linux</category>
      <category>backup</category>
      <category>rsync</category>
    </item>
    <item>
      <title>Simple bash script to create a tar archive from custom source with optional encryption and files exclusion</title>
      <dc:creator>alfiosalanitri</dc:creator>
      <pubDate>Wed, 27 Oct 2021 21:37:58 +0000</pubDate>
      <link>https://dev.to/alfiosalanitri/simple-script-to-create-a-tar-archive-from-custom-source-with-optional-encryption-and-files-exclusion-jh7</link>
      <guid>https://dev.to/alfiosalanitri/simple-script-to-create-a-tar-archive-from-custom-source-with-optional-encryption-and-files-exclusion-jh7</guid>
      <description>&lt;p&gt;bash script to create compressed archive from source path to destination. Supports files and folders exclusions from txt file and optional encryption with password.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F670hujyvll2a1294gka5.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F670hujyvll2a1294gka5.gif" alt="Demo" width="732" height="437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/alfiosalanitri/encrypted-backup/blob/main/README.md#usage" rel="noopener noreferrer"&gt;Download from github&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bash</category>
      <category>backup</category>
      <category>tar</category>
      <category>encryption</category>
    </item>
    <item>
      <title>How to Receive Telegram Alerts for High CPU and RAM Server Usage</title>
      <dc:creator>alfiosalanitri</dc:creator>
      <pubDate>Mon, 25 Oct 2021 16:53:03 +0000</pubDate>
      <link>https://dev.to/alfiosalanitri/how-to-receive-telegram-alerts-for-high-cpu-and-ram-server-usage-17ek</link>
      <guid>https://dev.to/alfiosalanitri/how-to-receive-telegram-alerts-for-high-cpu-and-ram-server-usage-17ek</guid>
      <description>&lt;p&gt;This is a simple bash script that monitor the server CPU (Load Average), RAM usage, check the systemctl services status and send an alert to telegram user if the RAM/CPU usage is greather then limit or a service is failed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Requirements&lt;/strong&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Server with systemd and root privileges&lt;/li&gt;
&lt;li&gt;A &lt;a href="https://core.telegram.org/bots#3-how-do-i-create-a-bot" rel="noopener noreferrer"&gt;bot telegram&lt;/a&gt; and a &lt;a href="https://core.telegram.org/bots#3-how-do-i-create-a-bot" rel="noopener noreferrer"&gt;telegram user chat id&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Installation&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/alfiosalanitri/server-guardian" rel="noopener noreferrer"&gt;Clone this repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Usage&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://github.com/alfiosalanitri/server-guardian#how-to-use" rel="noopener noreferrer"&gt;Follow this steps&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bash</category>
      <category>telegram</category>
      <category>cli</category>
      <category>linuz</category>
    </item>
    <item>
      <title>Bash script to count words and characters of multiple documents *.[txt|doc]</title>
      <dc:creator>alfiosalanitri</dc:creator>
      <pubDate>Thu, 10 Jun 2021 18:00:41 +0000</pubDate>
      <link>https://dev.to/alfiosalanitri/bash-script-to-count-words-and-characters-of-multiple-documents-txt-doc-221f</link>
      <guid>https://dev.to/alfiosalanitri/bash-script-to-count-words-and-characters-of-multiple-documents-txt-doc-221f</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjhhy2r7ajs36pafyvb2q.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjhhy2r7ajs36pafyvb2q.gif" alt="Demo linux doc words counter" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;a simple tool for people that need to count characters and words of multiple documents from command line interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Supports&lt;/strong&gt;: *.txt and *.doc filetype&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;a linux distro&lt;/li&gt;
&lt;li&gt;sudo privileges&lt;/li&gt;
&lt;li&gt;unzip package&lt;/li&gt;
&lt;li&gt;catdoc package&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/alfiosalanitri/linux-doc-words-counter" rel="noopener noreferrer"&gt;download this script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;open your CLI and type:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mv linux_doc_words_counter /usr/local/bin
sudo chmod +x /usr/local/bin/linux_doc_words_counter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;linux_doc_words_counter /path/to/archive.zip
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>bash</category>
      <category>cli</category>
      <category>linux</category>
    </item>
    <item>
      <title>Bash script to create/delete Apache Virtual Host automatically</title>
      <dc:creator>alfiosalanitri</dc:creator>
      <pubDate>Sun, 06 Jun 2021 20:31:19 +0000</pubDate>
      <link>https://dev.to/alfiosalanitri/bash-script-to-create-delete-apache-virtual-host-automatically-99b</link>
      <guid>https://dev.to/alfiosalanitri/bash-script-to-create-delete-apache-virtual-host-automatically-99b</guid>
      <description>&lt;h2&gt;
  
  
  [update 06/01/2022]
&lt;/h2&gt;

&lt;p&gt;The new script is compatible with Debian 11 or Ubuntu 20.&lt;br&gt;
Also you can choose custom file directory or custom server aliases or &lt;strong&gt;install automatically&lt;/strong&gt; &lt;strong&gt;Wordpress&lt;/strong&gt; or &lt;strong&gt;Laravel&lt;/strong&gt; application.&lt;br&gt;
&lt;a href="https://github.com/alfiosalanitri/lamp-virtual-host/blob/main/demo-usage.gif" rel="noopener noreferrer"&gt;See demo here&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;With this bash script you can add/delete an apache virtual host to/from your lamp stack. You can also to add a database and choose one of yours fast-cgi php module if installed.&lt;/p&gt;

&lt;p&gt;If you choose development environment option, the script will add the ssl certificate with mkcert package if installed on your machine. If you choose production environment, the script will add the ssl certificate with certbot and let's encrypt. Note that this last step requires the dns for domain and aliases setted to your server ip address.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A debian linux distribution like Ubuntu or Debian&lt;/li&gt;
&lt;li&gt;Stack Lamp: Apache, Mysql (optional), Php&lt;/li&gt;
&lt;li&gt;php-fpm module (optional)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://github.com/FiloSottile/mkcert" rel="noopener noreferrer"&gt;mkcert&lt;/a&gt; or &lt;a href="https://certbot.eff.org/" rel="noopener noreferrer"&gt;certbot&lt;/a&gt; for SSL certificate (optional)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/alfiosalanitri/lamp-virtual-host" rel="noopener noreferrer"&gt;download this script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;open your CLI and type:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo mv lamp_virtual_host /usr/local/bin
sudo chmod +x /usr/local/bin/lamp_virtual_host
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Usage
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd /path/to/directory/websites/
lamp_virtual_host www.example.local/ lamp_virtual_host /path/to/example.com/ -a www.example.com,shop.example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and follow instructions.&lt;/p&gt;

</description>
      <category>bash</category>
      <category>cli</category>
      <category>apache</category>
      <category>virtualhost</category>
    </item>
    <item>
      <title>Wireguard client connection/disconnection notification</title>
      <dc:creator>alfiosalanitri</dc:creator>
      <pubDate>Sat, 05 Jun 2021 19:04:04 +0000</pubDate>
      <link>https://dev.to/alfiosalanitri/wireguard-client-connection-disconnection-notification-144g</link>
      <guid>https://dev.to/alfiosalanitri/wireguard-client-connection-disconnection-notification-144g</guid>
      <description>&lt;p&gt;With this tutorial you can setup your server to send an alert to telegram when a client is connected or disconnected from the tunnel.&lt;/p&gt;

&lt;p&gt;The script sends a message to telegram if the client hasn't activity with the server for x (15 default) minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Server with Wireguard and root privileges (read &lt;a href="https://dev.to/wintermeyer/how-multiple-wireguard-peers-can-talk-to-each-other-3nl1"&gt;this post&lt;/a&gt; to install wireguard)&lt;/li&gt;
&lt;li&gt;curl &lt;code&gt;sudo apt install curl&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Telegram Bot (&lt;a href="https://core.telegram.org/bots#6-botfather" rel="noopener noreferrer"&gt;how to create a bot&lt;/a&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/alfiosalanitri/wireguard-client-connection-notification" rel="noopener noreferrer"&gt;download this script&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Edit the file &lt;code&gt;wg-clients-guardian.sh&lt;/code&gt; and change:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TIME_LIMIT=15 (alert will be sent after 15 minutes of inactivity)
TELEGRAM_CHAT_ID="your-chat-id"
TELEGRAM_BOT_ID="your-bot-api-key"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Add execution privilege to &lt;code&gt;wg-clients-guardian.sh&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo -s
chmod +x /path/to/wireguard-client-connection-notification/wg-clients-guardian.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;create the cron job
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* * * * * cd /path/to/wireguard-client-connection-notification/wg-clients-guardian.sh &amp;amp;&amp;amp; /path/to/wireguard-client-connection-notification/wg-clients-guardian.sh &amp;gt; /dev/null 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Do you want to receive an email instead of a telegram notification?
&lt;/h2&gt;

&lt;p&gt;Change this lines: 98,99&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MESSAGE="🐉 Wireguard: \`$CLIENT_NAME $SEND_NOTIFICATION from $REMOTE_IP\`"
        curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_ID}/sendMessage" -F chat_id=$TELEGRAM_CHAT_ID -F text="$MESSAGE" -F parse_mode="MarkdownV2" &amp;gt; /dev/null 2&amp;gt;&amp;amp;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;whit&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;MESSAGE="Wireguard: $CLIENT_NAME $SEND_NOTIFICATION from $REMOTE_IP"
echo "$MESSAGE" | mail -s subject your@email.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: requires mail package &lt;code&gt;sudo apt install mail&lt;/code&gt;&lt;/p&gt;

</description>
      <category>wireguard</category>
      <category>telegram</category>
      <category>bash</category>
    </item>
  </channel>
</rss>
