yarn install fails as it is using cmdtest package and not yarn

yarn was previously provided by cmttest and these are very different programs to yarn the package manager.  If you are using software sources (e.g. FarmBot.io)  that are managed through yarn (you will find a yarn.lock file with the software source) but when you try and run yarn install and then you get e.g.

yarn install
ERROR: [Errno 2] No such file or directory: 'install'

then firstly check to make sure that cmdtest is not installed.

sudo apt remove cmdtest

You would install yarn with

sudo apt-get install yarn

See the yarn packager web site for more details on installation.

No posts in WordPress after server/php migration due to obsolete/broken plugin

The scenario is that you restore you files and database to a new host and then when you access the dashboard (as well as the front end) you see no posts. They are listed i.e. All (nnn) Published (x) Draft (y), but there are none displayed.

Equally, you upgraded the current server to a new version and this upgrades the php version.The site may work (with blank list of posts) or the site may break and the frontend or administration cannot be accessed.

We had this and for us it was a very stale plugin that should have deleted years ago (Psychic Search) !.

If this happens to you and you have back-end access to the administration interface then deactivate all plugins that are old until the site comes back correctly.

If the site is so broken that you do not have access to the administration interface then you can use FTP to go to wp-content/plugins and then go through the change date and from the oldest dated plugin, download it (to take a backup) and then delete the plugin. When WordPress tries to load the now-deleted plugin then it can’t and the plugin becomes deactivated. This should get you back into the site and you can then use the administration interface to either install a updated version of the broken/obsolete plugin or an equivalent that does have support for your host/php version.

FreeSWITCH bootstrap libtool not found – missing libtool-bin

Was rebuilding FreeSWITCH source and had upgraded my test machine Ubuntu from 14.10 to version 15.04 so I did a make uninstall on FreeSWITCH and reran the bootstrap.sh but it came up with the error of libtool not found.

Libtool (2.4.2) was installed but what I found is that I had to add libtool-bin with,

sudo apt-get install libtool-bin

Then bootstrap.sh worked fine.

List of emails not being displayed in top folder in Thunderbird after upgrade

After upgrading from a prior version 6 of Thunderbird to version 31 the top level folder for one account did not show a list of emails. The emails were there and when you clicked on the display it displayed the full email but the space in the list was all blank rows and there was no column headings of subject, dates or recipients as you would expect.

The fix is trivially simple – click the folder display options and reset to the default. You can now fine-tune what you want displayed.

thunderbird-missing-display

 

 

Broken upstart causes Internal Error, No file name for udev

I was upgrading x2goserver and it stalled on * Cleaning up stale X2Go sessions. This is a normal log message within the /etc/init.d/x2goserver start() and it then runs x2gocleansessions after it logs this message. There shouldn’t have been any problems with this but it was just stuck there so I killed the dpkg and then I retried to add or remove anything but found that udev would not configure e.g. when I did sudo apt-get autoremove then I got,

Setting up udev (175-0ubuntu13.1) ...
invoke-rc.d: unknown initscript, /etc/init.d/udev not found.
dpkg: error processing udev (--configure):
 subprocess installed post-installation script returned error exit status 100!

Within synaptic when I tried to re-install udev then I got,

E: Internal Error, No file name for udev:amd64

The trick is that you can’t just re-install udev but must also re-install upstart.

This is because udev files link to upstart files and it is possible that a broken install has udev pointing at /etc/init.d/udev but that file is a link to /lib/init/upstart-job but the upstart is missing for some reason.

There may be other packages that have this kind of dependency e.g. winbind ufw squid3 and so on and certainly the x2goserver didn’t want to start properly. If you look in the /etc/init and see broken links to /lib/init/upstart-job then your problem should be fixed if you re-install upstart first.

As an aside after the upstart and udev was all cleaned up then the x2goserver removal and installation then worked.

Pandora FMS 4.0 to 5.0 upgrade quirks.

This was a painless upgrade but I found two quirks,

1) when you edit your config.php then you must set the chmod permissions to 600. If you try 400 then the Pandora Console still thinks that the file is readable by others. Obviously a bug but nothing to worry about. Note that to edit the ./include/config.php you must copy the new version 5 ./include/config.inc.php to ./include/config.php and then edit that new config.php and copy and paste in your custom settings from your old version 4 config.php file.

2) The ./extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql  (and actually any of those migration files) is missing a schema change to the tagente_estado table. It has,

ALTER TABLE `tagente_estado` ADD COLUMN `last_known_status` tinyint(4) NOT NULL DEFAULT 0;

but ALSO needs to have,

ALTER TABLE `tagente_estado` ADD COLUMN `last_error` tinyint(4) NOT NULL DEFAULT 0;

else the pandora_server won’t start.

Kohana 2.3 (used by blue.box) and PHP 5.4

If you are using Blue.box to configure your FreeSWITCH softswitch then blue.box uses Kohana 2.3 and this has a quirk with PHP 5.4 which means that you will end up with a blank page (even after a clean git pull) plus a spurious array to string conversion error.

For the BLANK screen issue then the fix is,

See https://gist.github.com/kemo/2881489 for a working fix. Note that that patch isn’t exactly lined up on the line numbers – my git diff is,

diff --git a/system/core/Kohana.php b/system/core/Kohana.php
index 56b44af..ee6c832 100644
--- a/system/core/Kohana.php
+++ b/system/core/Kohana.php
@@ -677,7 +677,7 @@ final class Kohana {
                if (ob_get_level() >= self::$buffer_level)
                {
                        // Set the close function
-                       $close = ($flush === TRUE) ? 'ob_end_flush' : 'ob_end_c
+$close = ($flush === TRUE) ? 'ob_end_flush' : 'Kohana::_ob_end_clean';

                        while (ob_get_level() > self::$buffer_level)
                        {
@@ -686,7 +686,7 @@ final class Kohana {
                        }

                        // This will flush the Kohana buffer, which sets self::
-                       ob_end_clean();
+Kohana::_ob_end_clean();

                        // Reset the buffer level
                        self::$buffer_level = ob_get_level();
@@ -1604,6 +1604,30 @@ final class Kohana {

                return $written;
        }
+ /**
+ * Ends the current output buffer with callback in mind
+ * PHP doesn't pass the output to the callback defined in ob_start() since 5.4
+ *
+ * @param callback $callback
+ * @return boolean
+ */
+ protected static function _ob_end_clean($callback = NULL)
+ {
+ // Pre-5.4 ob_end_clean() will pass the buffer to the callback anyways
+ if (version_compare(PHP_VERSION, '5.4', '<'))
+ return ob_end_clean();
+
+ $output = ob_get_contents();
+
+ if ($callback === NULL)
+ {
+ $callback = arr::get(ob_list_handlers(), ob_get_level() - 1);
+ }
+
+ return is_callable($callback)
+ ? ob_end_clean() AND call_user_func($callback, $output)
+ : ob_end_clean();
+ }

 } // End Kohana

For the array to string conversion error you see the sort of useful orange trace back Kohana error page and this,

An error was detected which prevented the loading of this page. If this problem persists, please contact the website administrator.

bluebox/libraries/doctrine/lib/Doctrine/Query/Abstract.php [1103]:

Array to string conversion

To fix this you need to do changes to Abstract.php and Lib.php which is basically making a new function arrayDiffSimple and then adding that new function to the Lib.php.

diff --git a/bluebox/libraries/doctrine/lib/Doctrine/Lib.php b/bluebox/libraries
index 26c796d..d6b5c94 100644
--- a/bluebox/libraries/doctrine/lib/Doctrine/Lib.php
+++ b/bluebox/libraries/doctrine/lib/Doctrine/Lib.php
@@ -268,6 +268,45 @@ class Doctrine_Lib
         }
     }

+
+    // Code from symfony sfToolkit class. See LICENSE
+    // code from cto at verylastroom dot com
+    /**
+     * arrayDiffSimple
+     *
+     * array arrayDiffSimple ( array array1 , array array2 )
+     *
+     * Like array_diff
+     *
+     * arrayDiffSimple() has exactly the same behavior than array_diff, but can
+     * only 2 arrays. PHP versions > 5.4.0 generate some NOTICE if you use arra
+     * sometimes because of array_diff internal behavior with (string) casts.
+     * This method solves the problem.
+     *
+     * @param array $array1
+     * @param array $array2
+     * @static
+     * @access public
+     * @return array
+     */
+    public static function arrayDiffSimple($array1, $array2)
+    {
+        $diff = array();
+
+        foreach($array1 as $key => $val) {
+            if(!isset($array2[$key])) {
+                $diff[$key] = $val;
+            } else {
+                if(is_array($array2[$key]) && !is_array($val)) {
+                    $diff[$key] = $val;
+                }
+            }
+        }
+
+        return $diff;
+    }
+
+
     /**
      * Makes the directories for a path recursively.
      *
diff --git a/bluebox/libraries/doctrine/lib/Doctrine/Query/Abstract.php b/bluebo
index 981603d..6bc2820 100644
--- a/bluebox/libraries/doctrine/lib/Doctrine/Query/Abstract.php
+++ b/bluebox/libraries/doctrine/lib/Doctrine/Query/Abstract.php
@@ -1098,9 +1098,9 @@ abstract class Doctrine_Query_Abstract
         $componentsAfter = $copy->getQueryComponents();

         $this->_rootAlias = $copy->getRootAlias();
-       
+
         if ($componentsBefore !== $componentsAfter) {
-            return array_diff($componentsAfter, $componentsBefore);
+               return Doctrine_Lib::arrayDiffSimple($componentsAfter, $componen
         } else {
             return $componentsAfter;
         }
@@ -2070,4 +2070,4 @@ abstract class Doctrine_Query_Abstract
     {
         return $this->getDql();
     }
-}
\ No newline at end of file
+}

Fixing held packages after repository change (apt-get upgrade verses dist-upgrade)

This example shows a fundamental difference to remember between apt-get upgrade and apt-get dist-upgrade

The example is that I altered the repository for the 0ad game package from the default to the ppa for the 0ad (i.e. sudo add-apt-repository ppa:wfg/0ad) . I then did a sudo apt-get update and then I did a sudo apt-get upgrade 0ad

Nothing wrong with that except that there is a new package dependancy for the 0ad game and this new to be installed package causes apt-get upgrade to hold the package upgrade.

To fix this you use sudo apt-get dist-upgrade instead. It will ask if you want to upgrade the packages and more importantly ask if you want to install any new packages rather than just holding them and not doing anything.

vTiger CRM missing language file causes Sorry! Attempt to access restricted file.

When you add a new user (in vTiger CRM v5.4.0) then it is possible that you can select a language setting e.g. “English GB” that has a non-existent translation file. If you do this then that user will get the error message,

Sorry! Attempt to access restricted file.

on a blank screen after they log on. They will stay in this state forever until the logon cookie is removed or the language file is created. The language files exist under the path,

include/language

To fix this you must either

  • upload the correct language file or
  • use another browser and go in as a working user e.g. admin and reset the language to a known working language e.g. English US or
  • clone the include/language/en_us.php to the correct file name e.g. en_gb.php. To identify what file is needed you can add a print_r($filepath); to the include/utils/CommonUtils.php file function checkFileAccessForInclusion() around line 2817 onwards but before the die(). You can’t keep that debug code in place as the ajax javascript breaks but it will tell you what language filename it is after.

That should solve this first-day-of-use problem.

Getting Asterisk packages and pubkey 75307751175E41DF

If you just added the  Asterisk packages using,

sudo add-apt-repository "deb http://packages.asterisk.org/deb `lsb_release -cs` main"

and are now trying to install Asterisk from packages and you get an unsigned key problem,

NO_PUBKEY 75307751175E41DF

then you must do as root,

 wget http://packages.asterisk.org/keys/175E41DF.pub -O - | sudo apt-key add -

You can now reload the packages within Synaptic.

See https://wiki.asterisk.org/wiki/display/AST/Asterisk+Packages#AsteriskPackages-APT%28Debian%2FUbuntu%29

Broken pip – not actually installed

Was trying to install unidecode using pip (python installer) on a development system to test out a django based application and got an error,

$ sudo pip install unidecode
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2675, in <module>
    parse_requirements(__requires__), Environment()
  File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 552, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==1.0.2

I don’t think the actual values of what I was installing nor the pip=x.y.z actually matter as I have seen others with this message when I did a google search but my problem eventually was that I had the pip bash shell installed at two locations but did not actually have the pip Python package installed at all.

I had a “pip” command script that comes with the python-pip package at /usr/local/bin and at /usr/bin and both were different versions. The one at /usr/local/bin was python-pip from easy_install and the other at /usr/bin was from the Ubuntu distribution package manager. Now pip is a Python package manager, and easy_install is  a Python package manager and obviously the Ubuntu itself has a package manager. Yes all of this is just asking for trouble but right now just wanted to move on and get my django server application running.

To fix I removed the Ubuntu package python-pip from within Ubuntu package manager and then ran,

sudo easy_install pip

…to actually get pip installed. Now the pip script at /usr/local/bin was wanting the latest version of pip (1.1 actually) and I had the latest version of pip package actually installed and I could now install the unidecode python package. I am now happy.

I don’t know when this mess happened but I’m not the first to get into such an odd state on a development system. I think the Ubuntu python-pip package is my culprit. Hopefully this post can help you too.

Broken PHP filter_var() hiccups ResourceSpace install on some URL

Was installing the very interesting ResourceSpace package for a client and the client domain names use “-” in the domain part. They also have the non-dashed version too which redirects to the dashed version. There is nothing wrong with having dashes in the host section of a URL as long as it is not the first character.

The install broke because of the dash and the problem is that the PHP filter_var() function is fine with an underscore in the domain name but not a dash thus filter_var(“http://www.bad_example.com”, FILTER_VALIDATE_URL)) will be true even though it’s an invalid domain name but filter_var(“http://www.good-example.com”, FILTER_VALIDATE_URL)) will be false even though it is valid.

There is not really much to do here other than upgrade PHP to the precise version that fixes this and on my development server I am at 5.3.2 but that’s not working and I’m not going to deviate from the Parallels packages for this. Also if you are on shared hosting you are not going to easily demand the hosting company fix this one bug.

So you are going to have to go into the install script and comment out the filter_url() code or alter the user provided URL to swap the “-” to a character that is always valid and swap the “_” to a character that is always invalid no matter if the filter_url() is good or bad.

So I created a “testbaseurl” from the “baseurl” and tested that rather than the original,

$testbaseurl = str_replace(parse_url($baseurl,PHP_URL_HOST), 
               str_replace(array("_", "-"), array("^", "x"), 
               parse_url($baseurl,PHP_URL_HOST) ), $baseurl  );

which you use instead of $baseurl thus in the ResourceSpace example in /pages/setup.php at about line 510 onwards set the file to,

        //Check baseurl (required)
        $baseurl = sslash(get_post('baseurl'));
        //filter_var() is broken in certain PHP versions as it doesn't permit dashes in host but does 
        //permit underscore. Swap these to always legal or illegal characters. Don't use testbaseurl other
        // than with filter_var()
        $testbaseurl = str_replace(parse_url($baseurl,PHP_URL_HOST), 
               str_replace(array("_", "-"), array("^", "x"), 
               parse_url($baseurl,PHP_URL_HOST) ), $baseurl  );
        if ((isset($baseurl)) && ($baseurl!='') && ($baseurl!='http://my.site/resourcespace') && (filter_var($testbaseurl, FILTER_VALIDATE_URL))){
            //Check that the base url seems correct by attempting to fetch the license file
            if (url_exists($baseurl.'/license.txt')){
            $config_output .= "# Base URL of the installation\r\n";
            $config_output .= "\$baseurl = '$baseurl';\r\n\r\n";
            }
            else { //Under certain circumstances this test may fail, but the URL is still correct, so warn the user.
                $warnings['baseurlverify']= true;
            }
        }
        else {
            $errors['baseurl'] = true;
        }

 

 

Foil-backed insulation blocking WIFI

Client has fixed up an old building and has used solid insulation which has an aluminium foil backing that acts as a heat and vapour block. It also stops WIFI dead.

Normally this wouldn’t be a problem and all your signals would be under the roof but this client has a 3-story rustic building with the office at the top and a bedroom at the back on the ground floor with a new roof. Whilst the WIFI signals are fine from the top to the bottom of the main building, immediately you pass under the foil-insulation of the extension then the signals stop.

The most cost effective solution to get WIFI to this back room without running Ethernet cables through meter thick stone walls is to use powerline adapters. Recently I have seen the retail prices for these plummet to less than 50 Euros per pair (for TP-Link brand from Amazon.it or Amazon.co.uk). Currently testing these out and they are looking fine but there is one caution that you need to consider.

These units give off a high frequency audible noise. It is like the flyback transformer of an old style CRT or TV. From experience with different customers these high frequencies can be annoying and frustrating to remove. So you may need to use powerline technology to sneak through the building and then for the last few meters use a cheap switch plus long pre-made ethernet cables or another WIFI AP.

Recovering from power loss-interrupted Ubuntu distribution upgrade

Was doing an Ubuntu maverick (10.10) to natty (11.04) upgrade on a test system (desktop) and the power was lost. No UPS. On reboot it didn’t come back properly and I got,

The disk drive for / is not ready yet or not present

As far as I know this was part way through the package installations. If it fails during the package download then there is never any problem but with a part-install then parts of the system are running the new version and parts are on the old distribution.

The fix is fairly easy – at the prompt above then type M to get to the manual recovery.

The disk will be mounted as read-only so then remount this,

sudo mount -o remount,rw /

then try these commands,

sudo apt-get update
sudo dpkg --configure -a

then reboot and then the system should come back in a partially upgraded but stable state and you can continue with the distribution upgrade with,

sudo apt-get upgrade -f
sudo apt-get dist-upgrade

After the reboot it will be on the new distribution. Note that if a package is corrupted then you may need to delete that one package file from the /var/cache/apt/… location and re-run the sudo apt-get upgrade -f command. It is a pity the distribution upgrade process doesn’t have this kind of logic built in to facilitate unattended completion or recovery of a partial distribution upgrade.

Other useful commands that are related but not part of the repair: To start off the upgrade process (which was interrupted by the power supply problem),

sudo do-release-upgrade

To verify what version you are running,

lsb_release -r

PandoraFMS server v4 fails to start – exits with Unknown column errors

During the Pandora FMS console upgrade the database schema may not have been upgraded correctly. If this happens then the Pandora server will be unable to start, i.e. when you try /etc/init.d/pandora_server start then it fails and logs its error messages in the /var/log/pandora/pandora_server.error file. If there are Unknown column errors then this is a clear giveaway that the database that you are connecting to doesn’t have the expected schema,

DBD::mysql::db do failed: Unknown column 'extended_info' in 'field list' at /usr/lib/perl5/PandoraFMS/DB.pm line 567.
DBD::mysql::st execute failed: Unknown column 'disabled' in 'where clause' at /usr/lib/perl5/PandoraFMS/DB.pm line 399.
DBD::mysql::db do failed: Unknown column 'tags' in 'field list' at /usr/lib/perl5/PandoraFMS/DB.pm line 567.

The fix is easy to do (assuming you don’t want to fall back to the previous version). Ideally first make a backup of your database using whatever tools you have available (your cpanel Mysql tools or command line mysqldump or phpmyadmin).
Then run the following command line commands,

cd /path/to/pandora_console
cat extras/pandoradb_migrate_v3.1_to_v3.2.sql | mysql -u pandora -p -D pandora

and then at the Enter password: prompt enter the password of the mysql user pandora. Note that the -u is the user i.e. pandora and the -D pandora is the database of pandora. This is the default convention used on the Pandora FMS system though you can use any database username and database name. Yes that is the 3.1 to 3.2 schema upgrade file. There is no harm in repeating that command.

Then repeat that with the 3.2 -> 4.0 schema changes..

cat extras/pandoradb_migrate_v3.2_to_v4.0.sql | mysql -u pandora -p -D pandora

At the end of this then you can start the Pandora server and it should startup correctly.