piwik

dimecres, 8 d’octubre del 2014

Installing older version of R package due to a dependency issues, ERROR: dependency ‘goftest’ is not available for package ‘spatstat’

When trying to install the latest version of spatstat from CRAN repos, I got the following error:

ERROR: dependency ‘goftest’ is not available for package ‘spatstat’

that's because there is no goftest package available for R 3.0.2, and it is required for installing spatstat, so what I've done is going through the previous version of the spatstat package and downloaded the latest version that doesn't require goftest package, which is 1.37 so I went ahead and downloaded it and install it manually:

R CMD INSTALL spatstat_1.37-0.tar.gz

dimarts, 7 d’octubre del 2014

no DISPLAY variable so Tk is not available for R

When installing a R package that requires a Display variable to be set and we are connecting from another machine using SSH, we may be prompt with those errors:

> library(tcltk)
Warning message:
In fun(libname, pkgname) : no DISPLAY variable so Tk is not available


or

error reading package index file /usr/local/R/lib/tcltk2/tklibs/ipentry0.3/pkgIndex.tcl: too many nested evaluations (infinite loop?)

To fix this, we may either install the package from a computer using graphical environment or connecting through SSH but forwarding X:

cat /home/josep/.ssh/config

host *
GSSAPIAuthentication=no
StrictHostKeyChecking=ask
UsePrivilegedPort yes
KeepAlive=yes
ForwardX11Trusted yes
ForwardAgent yes
ServerAliveInterval 240
ForwardX11 yes

dimarts, 30 de setembre del 2014

Mirroring Ubuntu 12.04 repo

Within the efforts of improving the performance of our network, we've decided to clone the official ubuntu repository to a local share which is served through anonymous FTP. There are plenty of tutorials explaining how to setup a local repo using apt-mirror, but what you basically need to know is how to configure this file
I've decided to clone also debian-installer packages in order to use this local repo for network installation through PXE.
/etc/apt/mirror.list


############# config ##################
#

set base_path    /mnt/my_ftp
#
 set mirror_path  $base_path/mirror
 set skel_path    $base_path/skel
 set var_path     $base_path/var
 set cleanscript $var_path/clean.sh
# set defaultarch  amd64
 set postmirror_script $var_path/postmirror.sh
# set run_postmirror 0
set nthreads     20
set _tilde 0
#
############# end config ##############
# Precise (12.04 LTS) for i386 architecture
deb-i386 http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-i386 http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-i386 http://archive.canonical.com/ubuntu precise partner
deb-i386 http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
#Source code
deb-src http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-src http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-src http://archive.canonical.com/ubuntu precise partner
deb-src http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
#Adding some entries to have the installer files for the new PXE installations
deb-i386 http://archive.ubuntu.com/ubuntu precise main/debian-installer restricted/debian-installer universe/debian-installer multiverse/debian-installer
deb-i386 http://archive.ubuntu.com/ubuntu precise-security main/debian-installer restricted/debian-installer universe/debian-installer multiverse/debian-installer
deb-i386 http://archive.ubuntu.com/ubuntu precise-updates main/debian-installer restricted/debian-installer universe/debian-installer multiverse/debian-installer
deb-i386 http://archive.ubuntu.com/ubuntu precise-backports main/debian-installer restricted/debian-installer universe/debian-installer multiverse/debian-installer
# Precise (12.04 LTS) for x86_64 architecture
deb-amd64 http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu/ precise-updates main restricted universe multiverse
deb-amd64 http://archive.ubuntu.com/ubuntu/ precise-backports main restricted universe multiverse
deb-amd64 http://archive.canonical.com/ubuntu precise partner
deb-amd64 http://security.ubuntu.com/ubuntu precise-security main restricted universe multiverse
#Adding some entries to have the installer files for the new PXE installations
deb-amd64  http://archive.ubuntu.com/ubuntu precise main/debian-installer restricted/debian-installer universe/debian-installer multiverse/debian-installer
deb-amd64  http://archive.ubuntu.com/ubuntu precise-security main/debian-installer restricted/debian-installer universe/debian-installer multiverse/debian-installer
deb-amd64  http://archive.ubuntu.com/ubuntu precise-updates main/debian-installer restricted/debian-installer universe/debian-installer multiverse/debian-installer
deb-amd64  http://archive.ubuntu.com/ubuntu precise-backports main/debian-installer restricted/debian-installer universe/debian-installer multiverse/debian-installer

clean http://archive.ubuntu.com/ubuntu
clean http://archive.canonical.com/ubuntu
clean http://security.ubuntu.com/ubuntu

dilluns, 22 de setembre del 2014

Get GPG fingerprint and push your key to ubuntu key server

root@samaruc:/tmp# gpg --fingerprint
/root/.gnupg/pubring.gpg
------------------------
pub   2048R/D9ADF82B 2014-09-09
      Key fingerprint = 3CDF 02F5 5532 E6FE 88D1  C152 5FE3 8CF1 D9AD F82B
uid                  Josep Manel Andres (IC3 standard WS)
sub   2048R/CB446606 2014-09-09


root@samaruc:/tmp# gpg --send-keys --keyserver keyserver.ubuntu.com D9ADF82B
gpg: sending key D9ADF82B to hkp server keyserver.ubuntu.com

dimarts, 9 de setembre del 2014

How to restrict ftp users from getting console access

We have set up an FTP server with several users that also have access to the server through SSH, which is not what we want.
The way we have set up the server is not probable the best one, but it just works for us. We have a Debian server in which we create normal users that we modify their home directory to point to the FTP filesystem, /ftpdata, which is an LVM disc.

So, to remove console access we need to do two things, adding /usr/lib/sftp-server as a shell to the /etc/shells file:

root@host # echo '/usr/lib/stfp-server' >> /etc/shells

and modify the default user's console to sftp-server by editing /etc/passwd or

root@host # usermod -s /usr/lib/sftp-server username

dimecres, 3 de setembre del 2014

Create unattended Ubuntu CD

This need came when we wanted to add a new machine to our infrastructure but it wasn't able to perform network boot, so it couldn't get the standard ubuntu installation from TFTP server. So, to get started, we need to have an Ubuntu Server edition ISO or an Ubuntu alternate edition, note that it won't work with the stardard Ubuntu Desktop edition.

Now we mount Ubuntu Alternate iso to some directory. Copy it with rsync to somewhere where you can edit it, and give write permisions to some directories.

mount -o loop /home/josep/ubuntu-alternate-12.04.iso /mnt/ubuntu
rsync -av /mnt/ubuntu/ /tmp/ubuntu
chmod -R u+w /tmp/ubuntu/isolinux
chmod -R u+w /tmp/ubuntu/preseed 

Modify the files /isolinux/txt.cfg to point to the new preseed that we have


default install
label install
  menu label ^Install Ubuntu
  kernel /install/vmlinuz
  append  file=/cdrom/preseed/ubuntu-our-preseed.seed locale=en_GB.UTF-8 console-setup/ask_detect=false keyboard-configuration/layoutcode=es vga=788 initrd=/install/initrd.gz quiet --
label check
  menu label ^Check disc for defects
  kernel /install/vmlinuz
  append   MENU=/bin/cdrom-checker-menu vga=788 initrd=/install/initrd.gz quiet --
label memtest
  menu label Test ^memory
  kernel /install/mt86plus
label hd
  menu label ^Boot from first hard disk
  localboot 0x80


And now we add our preseed to /preseed/ubuntu-our-preseed.seed



# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_GB.UTF-8
d-i debian-installer/country string ES
d-i localechooser/supported-locales en_US.UTF-8, en_GB.UTF-8, es_ES.UTF-8
# The values can also be preseeded individually for greater flexibility.
#d-i debian-installer/language string en
#d-i debian-installer/country string NL
#d-i debian-installer/locale string en_GB.UTF-8
# Optionally specify additional locales to be generated.
#d-i localechooser/supported-locales en_US.UTF-8, nl_NL.UTF-8
#
# Keyboard ======================
#
#d-i keyboard-configuration/modelcode skip
# New config
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string es
#
#
# Network installation
#
# Any hostname and domain names assigned from dhcp take precedence over
# values set here. However, setting the values still prevents the questions
# from being shown, even if values come from dhcp.
d-i netcfg/choose_interface select auto
d-i netcfg/get_nameservers string 192.168.60.9
d-i netcfg/get_hostname string unassigned-hostname
d-i netcfg/get_domain string ic3.local
# If non-free firmware is needed for the network or other hardware, you can
# configure the installer to always try to load it, without prompting. Or
# change to false to disable asking.
d-i hw-detect/load_firmware boolean true
#
# Time ==========================
#
# Controls whether or not the hardware clock is set to UTC.
d-i clock-setup/utc boolean true
# You may set this to any valid setting for $TZ; see the contents of
# /usr/share/zoneinfo/ for valid values.
d-i time/zone string Europe/Madrid
# Controls whether to use NTP to set the clock during the install
d-i clock-setup/ntp boolean true
# NTP server to use. The default is almost always fine here.
d-i clock-setup/ntp-server string 1.es.pool.ntp.org
#
# MIRROR ==========================
#
# If you select ftp, the mirror/country string does not need to be set.
#d-i mirror/protocol string ftp
d-i mirror/country string Spain
d-i mirror/http/hostname string es.archive.ubuntu.com
d-i mirror/http/directory string /ubuntu
d-i mirror/http/proxy string
.
.
.
. 


At this point we just need to recreate de ISO image:



mkisofs -r -V "auto-ubuntu-minimalvm" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o /home/josep/ubuntu-our-refurbished-image.iso /tmp/ubuntu



dijous, 5 de juny del 2014

500 OOPS: Vsftpd: Refusing to Run With Writable Root Inside Chroot () on Debian

I am currently the GNU/Linux sysadmin of a small company who runs mainly Ubuntu installations for almost all the machines, including servers and workstations. Since the first day I got here I already found so many problems related to Ubuntu OS, so I decided to move the server infrastructure to Debian GNU/Linux starting from FTP server.

We were running vsftpd 2.3.5-3 which doesn't allow the users to have write access to their root directory unless

allow_writeable_chroot=YES

is specified. But in order to do so, we need to get a patched version(2.3.5-10 or above) available through Cyconet
It is pretty simple to install, we add the repos, install the new version, allow writeable chroot, and restart the server:

echo "deb http://ftp.cyconet.org/debian wheezy-updates main non-free contrib" >> \ /etc/apt/sources.list.d/wheezy-updates.cyconet.list; \ aptitude update; aptitude install -t wheezy-updates debian-cyconet-archive-keyring vsftpd && \ echo "allow_writeable_chroot=YES" >> /etc/vsftpd.conf && /etc/init.d/vsftpd restart

dilluns, 2 de juny del 2014

Mount cifs on Ubuntu fails, permission denied mount error(13): Permission denied

When trying to mount a Synology CIFS share an error message was shown, it says :

mount error(13): Permission denied
Refer to the mount.cifs(8) manual page (e.g. man mount.cifs)

After making sure the credentials were correct, I found the solution in some forum, which is setting up a flag like this:

echo 0x27 > /proc/fs/cifs/SecurityFlags

And adding the domain and sec parameter when mounting it using fstab

//192.168.60.24/ic3data/jandres /ic3data cifs username=jandres,password=secret,domain=WORKGROUP,iocharset=utf8,sec=lanman  0     0

dimarts, 29 d’abril del 2014

Rsync option to ignore permissions

rsync -rltzuv /source root@destination:/backup

dimarts, 22 d’abril del 2014

SVN Warning: post-commit FS processing had error 'attempt to write a readonly database'.

When committing changes to the SVN server this error pop up, doesn't seem to be affecting the commits, however I wanted to fix it. With a little bit of google'ing I found out that rep-cache.db inside each repository was missing the right permissions.

root@molly:/srv/svn/turing# ll db/
total 56
drwxrwsr-x 6 www-data subversion 4096 Apr 22 14:05 ./
drwxrwsr-x 7 www-data subversion 4096 Apr 22 14:04 ../
-rw-rwSr-- 1 www-data subversion    2 Apr 22 14:05 current
-r--rwSr-- 1 www-data subversion   22 Apr 14 17:51 format
-rw-rwSr-- 1 www-data subversion 1920 Apr 14 17:51 fsfs.conf
-rw-rwSr-- 1 www-data subversion    5 Apr 14 17:51 fs-type
-rw-rwSr-- 1 www-data subversion    2 Apr 14 17:51 min-unpacked-rev
-rw-r--r-- 1 root     subversion 4096 Apr 14 18:29 rep-cache.db

I got it fixed just by setting www-data as the owner of the file.

chown www-data ../lamport/db/rep-cache.db

So I've done it for every repository that I have. The main directory hangs from /srv/svn and from there I have all repositories, different one for each server.

dimecres, 16 d’abril del 2014

Mediawiki Error creating thumbnail: Unable to save thumbnail to destination

After installing a mediawiki on our managed server, I found that thumbnails were not displayed in the wiki because there was not a variable pointing to a temp folder were the thumbnails should go defined. I may probably had to enable ImageMagickConvertCommand as well, but not sure. That was my previous LocalSettings.php file:

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads  = true;
#$wgUseImageMagick = false;
#$wgImageMagickConvertCommand = "/usr/bin/convert";

And this is how it looks like after enabling it.

## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads  = true;
$wgUseImageMagick = false;
#$wgImageMagickConvertCommand = "/usr/bin/convert";
$wgTmpDirectory = "$IP/images/temp";

dimarts, 25 de març del 2014

Backup script v0.2

This is the v 0.2 of the backup script, which does basically the same as v 0.1 but it has been modify to use variable for the path, instead of typing each path, and it is also backing up to a external NAS mounted through NFS, so it performs the mount, check whether it works and performs the backup.


#!/bin/bash
#Copyright (C) 2014 Josep Manel Andrés Moscardó http://terradelfoc.blogspot.com
#Version 0.2
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published
#by the Free Software Foundation, either version 3 of the License,
#or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful, but
#WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANT
#ABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 
#Public License for more details.
#
#You should have received a copy of the GNU General Public License 
#along with this program. If not, see http://www.gnu.org/licenses/.
#

DAILYPATH=/backup/daily/
WEEKLYPATH=/backup/weekly/
MONTHLYPATH=/backup/monthly/
#PATHBACKUP=/backup
CAL=/usr/bin/cal
#Format= 2013-03-20
YESTERDAY=`date --date=yesterday +%Y-%m-%d`
TODAYFULL=`date +%Y-%m-%d`
#Int (where Monday is 1 and Sunday is 7)
TODAY=`date +%u`
#Format= 2013-03-20
SEVENDAYSAGO=`date --date '7 days ago' +%Y-%m-%d`
FOURWEEKSAGO=`date --date '28 days ago' +%Y-%m-%d`
FIVEWEEKSAGO=`date --date '35 days ago' +%Y-%m-%d`

#These variables will be used to find out which day is the backup from 5months ago that we have to remove
FIVEMONTHSAGOMONTH=`date --date='5 month ago' +%m`
FIVEMONTHSAGOYEAR=`date --date='5 month ago' +%Y`

#This function will give us the date of the first Monday of 5 months ago month.
function date5monthsago(){
  #Exact day for the backup from 5months ago
  local aux=`$CAL $FIVEMONTHSAGOMONTH $FIVEMONTHSAGOYEAR |
  awk '
  NR == 1 { next }
  NR == 2 { next }
  NF <= 5 { next }
  NF == 6 { print $1 ; exit }
  NF == 7 { print $2 ; exit }
  '`
  echo $aux
}

#AUX used for checking whether the backup from 28 days ago is the first Monday of the month backup, if so We'll keep it in monthly directory, if not, we'll remove it.
AUX=`date --date '35 days ago' +%d`

#Do daily backup and store it on /home/backup/daily
#To log Starting time
START=$(date +%s)

#Mounting NFS to backup IC3HOME, we'll be umounting the FS at the end of the script
echo "###########Start mounting NFS############" > /tmp/mount.log 2>>1
mount lamarr:/volume1/backup /backup/ &>> /tmp/mount.log

if [ $(echo $?) -eq 0 ]; then
 echo "mounted OK" >>  /tmp/mount.log
 cat /tmp/mount.log >> $DAILYPATH$TODAYFULL.log

 ##########################################################
 echo "#########################Starting ic3home backup#####################" >> $DAILYPATH$TODAYFULL.log 2>>1
 ###########################################################
 ###########################################################
 rsync -avz --link-dest=/backup/daily/$YESTERDAY --progress /export/ic3home/ /backup/daily/$TODAYFULL >> $DAILYPATH$TODAYFULL.log 2>&1
 ###########################################################
 ###########################################################

 #To log Finishing time
 END=$(date +%s)
 TOTALTIME=$(( $END - $START ))
 echo "############################################################################################" >> $DAILYPATH$TODAYFULL.log
 echo "Start time:$START, finish time:$END, seconds:$TOTALTIME" >> $DAILYPATH$TODAYFULL.log


 #We will check if today is Monday, if so we'll move last monday's backup 1 directory up
 if [ "$TODAY" -eq "1" ]; then
   if [ -d "$DAILYPATH$SEVENDAYSAGO"  ]; then
     mv $DAILYPATH$SEVENDAYSAGO $WEEKLYPATH
     mv $DAILYPATH$SEVENDAYSAGO.log $WEEKLYPATH
   fi
   #Checking for a backup older than 28 days and also from first Monday of the month.If the backup from 28 days ago is not the firstMondayOfTheMonth we'll expire, or else we'll keep it within the monthly directory.  
   if [ -d "$WEEKLYPATH$FIVEWEEKSAGO" ]; then
     #Is it from first Monday of the month?
     if [ "$AUX" -le "7" ]; then
       mv $WEEKLYPATH$FIVEWEEKSAGO $MONTHLYPATH
       mv $WEEKLYPATH$FIVEWEEKSAGO.log $MONTHLYPATH
       #Execute function to find out exact date for 5 months ago
       FIVEMONTHSAGODAY=$(date5monthsago)
       #Expire backups older than 4 months ago. Note that FIVEMONTHSAGODAY has only 1 digit,that is why we add "0" before.
       if [ -d "$MONTHLYPATH${FIVEMONTHSAGOYEAR}-${FIVEMONTHSAGOMONTH}-0${FIVEMONTHSAGODAY}" ]; then
  rm -rf $MONTHLYPATH${FIVEMONTHSAGOYEAR}-${FIVEMONTHSAGOMONTH}-0${FIVEMONTHSAGODAY}
  rm $MONTHLYPATH${FIVEMONTHSAGOYEAR}-${FIVEMONTHSAGOMONTH}-0${FIVEMONTHSAGODAY}.log
       fi
     #If 35 days ago backups is not the first monday of the month, expire it
     else
       rm -rf $WEEKLYPATH${FIVEWEEKSAGO}
       rm $WEEKLYPATH${FIVEWEEKSAGO}.log
     fi
   fi

 #If today is NOT Monday we'll expire old daily backups
 else
   #Is there a backup from 1weekago? If so we'll exxpire it
   if [ -d "$DAILYPATH$SEVENDAYSAGO" ]; then
     rm -rf $DAILYPATH$SEVENDAYSAGO
     #Remove log file also
     rm $DAILYPATH${SEVENDAYSAGO}.log
   fi    
 fi

 #Umount the NFS
 umount /backup
else
 echo "NFS couldn't be mounted" >> /tmp/mount.log
fi

dimecres, 19 de març del 2014

Run of Puppet configuration client already in progress

notice: Run of Puppet configuration client already in progress; skipping

Puppet believes that it is already running. If this isn't the case then you may have a stale lock file. Check with "ps axf" to see if puppetd is running, if it isn't then delete the lockfile (/var/lib/puppet/state/puppetdlock is likely location).

Source

dilluns, 3 de març del 2014

How to install BRugs on Ubuntu 12.04

Before installing BRugs we need to have  gcc-4.6-multilib installed, we can do so from Ubuntu repos.
Then we download the latest package and from the same directory where it is located we issue the following command:

R CMD INSTALL BRugs_0.8-3.tar.gz --configure-args='--with-openbugs=/usr/local/openbugs'

From inside R you can install R just by typing:

install.packages("BRugs", lib = "/usr/local/R/lib/", configure.args = "--with-openbugs=/usr/local/openbugs")

Installing R library from source, tar.gz file

install.packages("INLA.tgz", repos=NULL, type="source", lib="/usr/local/R/lib/")

dijous, 27 de febrer del 2014

Authentication token manipulation error when changing root password from recovery mode

When booting into recovery mode, filesystem won't be mounted as read-write and therefore when attempting to change the password it won't work. To proceed we'll just have to remount the / as read-write by issuing the following command.

mount -rw -o remount /

dimecres, 12 de febrer del 2014

How to disable plugin container for computers with very few CPU resources.

I am running a laptop which has a very small CPU and therefor when playing flash videos in the web browser, plugin container process gets to high and the video gets stucked.
A workaround we can do to minimize the resource consuming of the plugin is to disable the wrapper used by Firefox to play videos (plugin-container).  It is intended to jail a video into a process to avoid the hole firefox crashing under some unexpected condition. To do so we just have to tune a firefox option:

  1. Enter about:config in your address bar
  2. Search for dom.ipc.plugins.enabled
  3. Set their values to false
And you are done.