Archive for the ‘Guides’ Category

Network Manager Applet NOT Showing in MATE Desktop Taskbar Ubuntu

Saturday, February 13th, 2016

Network Manager Applet NOT Showing in MATE Desktop

If you install the MATE desktop environment on Ubuntu, your Network Manager icon may not show up in the taskbar as shown below:

Without the Network Manager icon showing, you will have a hard time managing and connecting to WIFI networks.  To get it to show up, you will need to edit the following file using nano:

sudo nano /etc/xdg/autostart/nm-applet.desktop

Look for the below line:

AutostartCondition=GNOME3 unless-session gnome

And comment it out like so:

#AutostartCondition=GNOME3 unless-session gnome

Save the file using "Ctrl + O", and then exit nano using "Ctrl + X".  Restart your computer.  The network icon will show up again as shown below:

Note, the actual icon will vary based on the selected MATE desktop theme.  The screenshots above show the icon used in the LUNA theme.

phpBB 3.0.14 Recaptcha V2 NOT a Robot MOD – Installs with AutoMOD

Thursday, December 3rd, 2015

NOT a Robot Recaptcha V2 for phpBB 3.0.14

Download NOT a Robot Recaptcha Version 1.0

Info:

NOT a Robot Recaptcha V2 is a MOD for phpBB 3.0.14.  It integrates Google's Recaptcha V2 (the not a robot test) as an available anti-spam option that can be used during account registration. It prevents spam and forum registration flooding. 

Installation Instructions:

To install NOT a Robot Recaptcha V2 for phpBB 3.0.14, first update your 3.0.x forum to 3.0.14 if you're not currently running 3.0.14.  The AutoMOD mod then needs to be installed (if not already installed) before this mod can be installed.

AutoMOD Installation Instructions:

If you haven't already, please download and install AutoMOD on your forum.  Instructions for installing AutoMOD can be found here.

Installation with AutoMOD:

Login to the Administration Control Panel (ACP).  Click on the AUTOMOD tab at the top of the page.  Under Upload MOD, browse to your downloaded copy of the zipped mod. Upload it. You should now see "Recaptcha V2 NOT a Robot" as a listed mod under AUTOMOD.  Install it.

Once installation is complete, you will need to configure Recaptcha V2 NOT a Robot.  To do so, in the Administration Control Panel (ACP), click on the "GENERAL" tab.  Under "BOARD CONFIGURATION" on the left side, click on "Spambot countermeasures".  Under "Available plugins", next to "Installed plugins:", there is a dropdown.  Select "reCaptcha v2 NOT Robot" from the dropdown and click on "Configure".  Enter your site key and secret key obtainable by registering for free here. Click on Submit.  Reselect "reCaptcha v2 NOT Robot" in the dropdown and click on "Submit".  Your forum is now using reCaptcha v2 NOT a Robot.  When a user attempts to register, he will be shown the "I'm not a robot." captcha that must be completed before registration will be handled.

Works with All Themes

This plugin should work with all themes.  However, since this plugin is using a template not previously found in the base theme, you may want to customize how it looks in your installed custom themes. To do so, copy the "captcha_recaptcha.html" file in your themes "template" folder and rename the copy to "captcha_recaptcha_v2.html".  Open "default/template/captcha_recaptcha_v2.html" and copy the code section into "captcha_recaptcha_v2.html" within the theme you're working on. You just need to copy the entire <table> section from "default/template/captcha_recaptcha_v2.html" and paste it in to your theme's "captcha_recaptcha_v2.html" file. 

So basically, in your theme's "captcha_recaptcha_v2.html" file, replace:
 

                <script type="text/javascript">
                // <![CDATA[
                var RecaptchaOptions = {
                    lang : '{LA_RECAPTCHA_LANG}',
                    theme : 'clean',
                    tabindex : <!-- IF $CAPTCHA_TAB_INDEX -->{$CAPTCHA_TAB_INDEX}<!-- ELSE -->10<!-- ENDIF -->
                };
                // ]]>
                </script>
                <script type="text/javascript" src="{RECAPTCHA_SERVER}/challenge?k={RECAPTCHA_PUBKEY}{RECAPTCHA_ERRORGET}" ></script>
                <script type="text/javascript">
                // <![CDATA[
                <!-- IF S_CONTENT_DIRECTION eq 'rtl' -->
                    document.getElementById('recaptcha_table').style.direction = 'ltr';
                <!-- ENDIF -->
                // ]]>
            </script>
            <noscript>
                <iframe src="{RECAPTCHA_SERVER}/noscript?k={RECAPTCHA_PUBKEY}{RECAPTCHA_ERRORGET}" height="300" width="500" frameborder="0"></iframe><br />
                <textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
                <input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
            </noscript>

With:

<table style="width:100%; border:0;">
        <td style="width:30%;">
            <p>{L_GV2_CONFIRM_CODE}:<br /><span>{L_GV2_CONFIRM_EXPLAIN}</span></p>
        </td>
        <td style="width: 70%; text-align: right;">
            <script type="text/javascript">
            // <![CDATA[
            var RecaptchaOptions = {
                lang : '{LA_RECAPTCHA_LANG}',
                theme : 'clean',
                tabindex : <!-- IF $CAPTCHA_TAB_INDEX -->{$CAPTCHA_TAB_INDEX}<!-- ELSE -->10<!-- ENDIF -->
            };
            // ]]>
            </script>
            <script type="text/javascript" src="{RECAPTCHA_SERVER}"></script>
            <script type="text/javascript">
            // <![CDATA[
            <!-- IF S_CONTENT_DIRECTION eq 'rtl' -->
                document.getElementById('recaptcha_table').style.direction = 'ltr';
            <!-- ENDIF -->
            // ]]>
            </script>
            <div style="display: inline-block;">
                <div class="g-recaptcha" data-sitekey="{RECAPTCHA_PUBKEY}"></div>
            </div>
        </td>
</table>

Screenshots:

Save iptables on Shutdown and Restart, and Restore on Boot

Tuesday, October 6th, 2015

Save iptables Rules on Shutdown, Restore on Boot

When your server shutsdown (halts), reboots, or enters runlevel 1, your iptables configuration is automatically wiped and reset.  Packages such as iptables-persistent supposedly help with this problem, but unless you save your rules manually, the rules are never saved automatically when the system reboots. 

I've wanted to truly persist my iptables, so I decided to change their package to always save the iptables rules when the system reboots, halts, or enters runlevel 1 automatically.  The rules are then restored when the system boots to runlevels 2-5.  This means that your iptables configuration will persist forever.  This may not be desired, but if I ban an IP address permanently, I always want it to be banned.

If you'd like to use this modified version of iptables-persistent so that your rules are automatically saved on shutdown, you can install it by running the below commands:

sudo apt-get remove iptables-persistent
sudo dpkg -r iptables-persistent
wget http://dinofly.com/files/linux/iptables-persistent_0.5.8_all.deb
sudo dpkg --install iptables-persistent_0.5.8_all.deb

Use at your own risk.  If you do something stupid, it will persist until you can clear it!

The above package was tested in Ubuntu 12.04 x86, Ubuntu 12.04 x64, Ubuntu 14.04 x86, Ubuntu 14.04 x64, and Ubuntu 15.04 x64.  Should work on other debian operating systems as well.

Get the Source Code and Modify an Ubuntu Package

Tuesday, October 6th, 2015

Modifiying the Source of a Package and Creating a New Deb Binary

In order to download the source code of an existing package, first install the prerequisites:

sudo apt-get install build-essential debhelper

To get the source code of a package, run the following command:

apt-get source {name_of_package_interested_in}

Make changes to the source using an editor like geany or via terminal through nano.  Edit the changelog file and add a record of your changes to build a new revision number.  After you have made the changes, run the following commands to build the package which should include your changes.

dpkg-source --commit
dpkg-buildpackage -b

The updated package has been built.  To install the package, simply use the below commands:

sudo dpkg --install {name_of_new_deb_file}

To remove the software:

sudo dpkg -r {name_of_package [NOT NAME OF DEB FILE]}

Now you can release it!

Ubuntu Grub Fails to Install on RAID Array

Friday, February 6th, 2015

Ubuntu Grub RAID Issues

Grub Fails To Install on RAID Array

If grub fails to install on your RAID array in any version of Ubuntu, do NOT disable your BIOS RAID! The correct solution is at this blog entry. I'll summarize it below.

At the stage of the install where it is attempting to install GRUB it will detect as

/dev/mapper

This is incomplete! That's why the GRUB install fails.

You need the actual name of the RAID array to install to. So during that step, press ctrl+alt+F2 to drop to a busybox terminal, then enter

ls -l /dev/mapper

Pick out the name of your array from the list shown, then press ctrl+alt+F1 to switch back to the install (you can switch back and forth as much as you like with no problems) and enter it in the field as

/dev/mapper/{your array name}  

Then GRUB installs perfectly and you're ready to go, with a proper BIOS RAID array intact.

System Won't Boot After Grub Failed to Install

If your system will no longer boot because you skipped installing or updating grub, you need to download an Ubuntu version that does support RAID, boot from the LIVE CD, drop to a terminal, and then run:

ls -l /dev/mapper
sudo grub-install /dev/mapper/{ARRAY_NAME_HERE}

Setting Up RAID Array During Ubuntu Install

If you are configuring a BIOS RAID array for the first time on Ubuntu, you should create a 1MB boot partition.  Its partition type is "boot".  If you do this, grub will always try to install there and will succeed every time without failing when upgrading or reinstalling grub.

Install VSFTPD 3.0.2 on the ARM Platform for Raspbian or Debian

Saturday, January 3rd, 2015

Install VSFTPD 3.0.2 on the ARM Platform for Raspbian or Debian

Download and install the arm compiled VSFTPD 3.0.2 deb package file and init script:

wget -N http://dinofly.com/files/linux/vsftpd_3.0.2_arm.tar.gz
tar -zxvf vsftpd_3.0.2_arm.tar.gz
if [ ! -e "/etc/init.d/vsftpd" ]; then
    sudo cp vsftpd /etc/init.d/
fi
sudo dpkg -i vsftpd_3.0.2-1_armhf.deb

Now, run these commands:

sudo useradd -d /var/ftp ftp
sudo mkdir -p /var/ftp
sudo chown root.root /var/ftp

Finally, start the VSFTPD service and set it to run on boot:

sudo service vsftpd restart
sudo update-rc.d vsftpd defaults

VSFTPD 3.0.2 should now be installed on your ARM device.

Allow Anonymous Read Only FTP via VSFTPD

Saturday, January 3rd, 2015

Anonymous VSFTPD Setup (Read Only)

Configuration:

In order to enable anonymous FTP connections to a particular directory while still supporting authentication for virtual users for their files via PAM isn't that difficult.  Install VSFTPD if you haven't done so already by running the following command:

sudo apt-get install vsftpd

Create a backup of your existing VSFTPD confiugration file (this guide assumes you have already installed vsftpd):

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak

Next, let's edit the file:

sudo nano /etc/vsftpd.conf

Add the following lines to your configuration file:

anonymous_enable=YES
anon_root={INSERT_PATH_TO_ANONYMOUS_DIRECTORY}
anon_mkdir_write_enable=NO
anon_upload_enable=NO

Adding these lines enables anonymous FTP to the specified directory where files can be read and downloaded only.  Anonymous users cannot write, delete, change, or modify files because of the anon_mkdir_write_enable=NO and the anon_upload_enable=NO configuration lines.  For your changes to take effect, restart vsftpd.

sudo service vsftpd restart

You're done!

Multiple Comment Forms on WordPress Page – Using WYSIWYG Editor NicEdit

Tuesday, January 28th, 2014

WYSIWYG WordPress Comments

I tried and tried to get the CKEditor plugin for WordPress to initalize multiple comment textareas for a custom post type I had created using the pods WordPress plugin.  No matter how hard I tried, I failed.  Only the first instance would get initialized.  I dug through the code and found where the instance was created, but even with the code in front of my eyes, I could not figure out how to adapt the messy PHP / Javascript mesh to do what I wanted.

Eventually, I came accross a great guide explaining how to use NicEdit, a simple WYSIWYG editor that can be used easily to replace the boring WordPress comment box with something more friendly for end users leaving comments.

Following this guide, I downloaded and uploaded the NicEdit files to a folder named "scripts" in my theme's directory (please adjust the path in the functions below if you want to use another directory or place the files elsewhere).  I would recommend downloading the non-compressed version, as the code is easier to read and making changes is a lot easier.  I inserted the following function into my WordPress theme's functions.php file:

function add_nicEdit() {
    if ( !is_admin() ) {
        // register scripts
        wp_register_script('nicEdit', get_stylesheet_directory_uri() . '/scripts/nicEdit.js', array(), false, true);
 
        // enqueue scripts
        wp_enqueue_script('nicEdit');
    }
}
 
add_action('wp_enqueue_scripts', 'add_nicEdit');

Then, I created a new function that I added to NicEdit.js file.  After this code:

allTextAreas : function(nicOptions) {
        var textareas = document.getElementsByTagName("textarea");
        for(var i=0;i<textareas.length;i++) {
            nicEditors.editors.push(new nicEditor(nicOptions).panelInstance(textareas[i]));
        }
        return nicEditors.editors;
    },

I added a function called allCommentTextAreas:

allCommentTextAreas : function(nicOptions) {
        var textareas = document.getElementsByTagName("textarea");
        for(var i=0;i<textareas.length;i++) {
      if(textareas[i].className == "comment_editor"){
               nicEditors.editors.push(new nicEditor(nicOptions).panelInstance(textareas[i]));
      }
        }
        return nicEditors.editors;
    },

The way this function works is that it will replace all textareas that have a class of "comment_editor" only.

Next, in my theme's footer.php file after the <?php wp_footer(); ?> line, I added the following:

<script type="text/javascript">
           // We need to initialize the WYSIWIG editor for the comments field                   bkLib.onDomLoaded(function() { nicEditors.allCommentTextAreas({
                   iconsPath : '<?php bloginfo( 'stylesheet_directory' ) ?>/scripts/nicEditorIcons.gif', buttonList : ['bold','italic','strikethrough','link','unlink','removeformat']})
                   });
        </script>

In your pods page template, load comments like this:

$args["comment_notes_after"] = "";
$args["comment_field"] = '<p class="comment-form-comment"><label for="comment">' . _x( 'Comment', 'noun' ) .          
'</label><textarea id="comment" class="comment_editor" name="comment" cols="45" rows="8" aria-required="true">' .          
'</textarea></p>';
comment_form( $args, $post_id ); 

Your comments form will now look a lot better, specifically, they will look like this:

nic edit

Disable BIND9 Recursive DNS Queries to Prevent UDP DDOS Flood Attacks

Sunday, January 12th, 2014

Turn Off BIND9 Recursion

By default, BIND9 is configured to allow recursive DNS queries.  This allows others to use your DNS server to query other domains on your server's behalf.  Unfortunately, recursive DNS queries can be used to amplify a UDP flood DDOS attack.  As such, for a shared web hosting environment, it is best to disable recursive DNS queries.  You can disable BIND9 recursion easily by running the following script:

cd ~/Downloads
wget -N "http://dinofly.com/files/linux/disable_bind9_recursion.tar.gz"
tar -zxvf disable_bind9_recursion.tar.gz
sudo bash disable_bind9_recursion.sh

It should work on all versions of Linux but has been tested and works perfectly on Ubuntu.  You may need to change the path used for the BIND config file. 

MySQL Dump Insert Statements Only

Saturday, September 14th, 2013

Using mysqldump to Create SQL Backups with Only Insert Statements and Ignore Existing Records

mysqldump -u USER -p PASSWORD --skip-triggers --compact --no-create-info --insert-ignore DBNAME