Thursday, March 27, 2014

Home Configuration

Router: WNDR3700 running barrier breaker (I upgrade about once a week.
I use this with ddns (http://www.dnsdynamic.org/) to access my home network from anywhere.  Also use for port forwarding, static hostnames, ssh tunneling, and network monitoring.

Server (not that great): I use an old dual core amd-based server with a couple hdd attached just for testing/hosting purposes.  I am running Ubuntu 13.10 as my base OS.  Just a couple running services; Jenkins, RabbitMQ, Owncloud 6, Seafile 2.1.5, Codiad from git, cloud9, SoftEther VPN from git, webmin, zentyal (really neat software)... and much more.

Raspberry Pi #1: Running raspbian, solely used for testing bluez from git.

Raspberry Pi #2: Running raspbian, CUPS server connected to Canon S530d.

Raspberry Pi #3: Running raspbian, testing other packages like owncloud.

Beaglebone black A5C #3: Running ubuntu 13.10 on the eMMC and Fedora on the micro sd card

Macbook pro 13" 2009 5,5:
2 x 2 GB g.skill ram
240GB Kingston SSD
750GB WD HDD (replaced super drive for second internal HDD)
Running:
osx 10.9.2
Windows 7
Ubuntu 14.04
Kali 1.0.6
Opensuse 13

Friday, March 21, 2014

Cups 1.7.5, 2.0, or 2.1 on Raspberry Pi Raspbian

In my attempt to turn the raspberry pi into a wireless printer server for my usb connected Canon s530d printer (yes, i'm well overdue for a 21st century printer upgrade, just wanted to see if I could make it work), I have concluded that cups and a bunch of other requirements need to be installed.  To accomplish this, the prerequisite list is long and compiling is time consuming, so patience must be a prerequisite to these prerequisites.  I chose to compile all of these from scratch instead of apt-get all of them because the raspbian and ubuntu-based distros have versions of cups that are highly outdated.  As of writing this I believe they are still on 1.5.3, not good.  To stay up-to-date, you should go with my route to ensure you are running the latest cups software.
A great source for looking up the proper way to install the programs is linuxfromscratch.org.

Update 12/23/2014
cups 1.7 is no longer maintained.
choose either cups 2.0 or 2.1 

Few disclaimers:
*** Needs adequate power ***
Some printers are power hungry (like mine) and the pi will incidentally freeze without warning due to too much current drawl through the host USB port.  I have been working just fine with plugging in a pair of iphone usb chargers totaling approximately 2 amps joint by a usb y-cable.  This one exactly http://www.amazon.com/gp/product/B0047AALS0/ref=wms_ohs_product?ie=UTF8&psc=1

*** Will not work with all printers ***
My Canon s530d requires experimental gutenprint drivers so I have included those steps below

*** Lengthy compile times ***
 Seriously, if you are compiling all of the sources below, you're gonna have a lot of down time.  It usually takes me about 2-3 hours from the first step to the last for a full installation.

Download the following sources:
qpdf  "git clone https://github.com/qpdf/qpdf.git"
poppler "wget http://poppler.freedesktop.org/poppler-0.24.5.tar.xz"
cups-filters "http://www.openprinting.org/download/cups-filters/cups-filters-1.0.54.tar.bz2"
cups "https://www.cups.org/software/1.7.5/cups-1.7.4-source.tar.bz2" or "git clone -b branch-1.7 http://www.cups.org/cups.git cups-1.7" or "git clone http://www.cups.org/cups.git cups-2.0" or
"git clone http://www.cups.org/cups.git cups-2.1"
ghostscript - "git clone http://git.ghostscript.com/ghostpdl.git"
foomatic-db - "wget http://www.openprinting.org/download/foomatic/foomatic-db-current.tar.gz"
gutenprint - "http://sourceforge.net/projects/gimp-print/files/gutenprint-5.2/5.2.10/gutenprint-5.2.10.tar.bz2"

Bonus! Google Cloud Print!
Cloud Print "git clone git://github.com/simoncadman/CUPS-Cloud-Print.git"

To start off:
So the process goes smoothly, remove all references to cups, ghostscript, foomatic, cups-filters, and gutenprint in the apt package manager and file system.  To do this I normally use apt-get remove cups* and "locate cups" on the command line to find the files and remove the files manually.  That way I am not accidentally ruining my system by removing files that should not be removed.

The process is nearly the same with all of the installs (with a few excepts on a few of them) and using sudo before every command is highly recommended
  • autoconf
  • ./configure
  • make
  • sudo make install

Initial cleanup:
Find unnecessary  preinstalled packages by running the following:
dpkg --get-selections | grep -v deinstall | grep cups
dpkg --get-selections | grep -v deinstall | grep poppler
dpkg --get-selections | grep -v deinstall | grep ghostscript
dpkg --get-selections | grep -v deinstall | grep foomatic-db

or you could simply run this:
dpkg --get-selections | grep -v deinstall | egrep '^(cups|poppler|ghostscript|foomatic-db)' | awk '{print $1 }' | tr '\n ' ' ''' | xargs sudo apt-get remove 


Remove all preinstalled packages that look like this:
cups-*
poppler-*

So the compiler doesn't find any precompiled libraries find any files that have the reference of libcups* and libpoppler*, then remove them.

For me, I had to do the following:
sudo rm  /usr/lib/arm-linux-gnueabihf/libcups*
sudo rm  /usr/lib/arm-linux-gnueabihf/libpoppler*
sudo find . -name cups* -not -path "./home/pi/*" -exec rm -rf {} \;

--------------------------------------------------------------------------------------------------------------

1. QPDF
cd qpdf
autoconf
./configure --enable-doc-maintenance
make (at the end of the make you should see a summary of what is available, resolve any dependencies as you wish like docbooks)
sudo make install

there should be no errors, if there are it is most likely dependency issues.  Also, this part has the longest compile time.

--------------------------------------------------------------------------------------------------------------

2. POPPLER
cd poppler
./autogen.sh
./configure --enable-libcurl
make
sudo make install

once again, resolve dependencies as necessary.  At the end of the poppler configure you should see a summary that resembles the following code.  Make sure you have cairo output, libjpeg, libpng, libtiff, and libopenjpeg checked off with yes.  You have to have at least those checked for cups-filters to install properly.


Building poppler with support for:
  font configuration: fontconfig
  splash output:      yes
  cairo output:       yes
  qt4 wrapper:        yes
  qt5 wrapper:        no
  glib wrapper:       yes
    introspection:    no
  cpp wrapper:        yes
  use gtk-doc:        no
  use libjpeg:        yes
  use libpng:         yes
  use libtiff:        yes
  use zlib:           yes
  use libcurl:        yes
  use libopenjpeg:    yes
  use cms:            yes
      with lcms2
  command line utils: yes
  test data dir:      /home/pi/Projects/poppler-0.24.5/./../test


--------------------------------------------------------------------------------------------------------------

3. CUPS
Just follow these instructions http://www.linuxfromscratch.org/blfs/view/svn/pst/cups.html
They did a good job, and i'd basically be copy and pasting.  You don't have to do the patch so here are the instructions without it.
For <username> , insert an admin user you would like to have control over the printer settings.  I used my default "pi" user.  You can add as many as you would like.

useradd -c "Print Service User" -d /var/spool/cups -g lp -s /bin/false -u 9 lp
groupadd -g 19 lpadmin
usermod -a -G lpadmin <username>

cd cups-1.7.5
or
cd cups-2.0*

./configure
make
sudo make install
echo "ServerName /var/run/cups/cups.sock" > /etc/cups/client.conf

--------------------------------------------------------------------------------------------------------------

4. GHOSTSCRIPT
cd ghostpdl/gs
sudo apt-get install libxt-dev
./autogen.sh
./configure
make
sudo make install
sudo make install-so

--------------------------------------------------------------------------------------------------------------

5.CUPS-FILTERS
cd cups-filters-1.0.54
autoconf
./configure
make
sudo make install

--------------------------------------------------------------------------------------------------------------


****This step is optional and is dependent upon the requirements of your printer driver****6. FOOMATIC-DB
cd ghostpdl
sudo apt-get install libxt-dev
./configure
make
sudo make install

--------------------------------------------------------------------------------------------------------------

****This step is optional and is dependent upon the requirements of your printer driver**** 
7. GUTENPRINT
cd gutenprint-5.2.10
sudo apt-get install texlive-fonts-extra doxygen
./configure
make
sudo make install

--------------------------------------------------------------------------------------------------------------

8. Google Cloud Print
cd CUPS-Cloud-Print
./configure
make install

--------------------------------------------------------------------------------------------------------------

Add the following at the top of /etc/init.d/cups by sudo vim /etc/init.d/cups
then run "sudo update-rc.d"

### BEGIN INIT INFO
# Provides:          cups
# Required-Start:    $syslog $remote_fs
# Required-Stop:     $syslog $remote_fs
# Should-Start:      $network avahi
# Should-Stop:       $network
# X-Start-Before:    samba
# X-Stop-After:      samba
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: CUPS Printing spooler and server
### END INIT INFO

this prevents the following loop message when trying to install other packages and invoking update-rc.d:
"insserv: Starting cups depends on plymouth and therefore on system facility `$all' which can not be true!"

--- 
The installation should be finished with no errors, now we have to fix some issues with cups because the new cups-filters uses newer methods for test banners.
Follow the instructions to fix this here: http://www.bsmdevelopment.com/Reference/Tech_20130002.html

Easiest way to get to the web interface without editing the conf file for cups is use lynx and do the following:

apt-get install lynx
lynx http://localhost:631
Use the arrows to navigate to the administration word, type "y" to enable the cookie, and a new page should populate.  In the middle of the page you should see "Allow remote adminstration".  Navigate with the "down" arrow to the bottom and press enter on the desired highlighted box.  It will ask for authentication, use the root or current username and password as long as it is part of the lpadmin group described in the CUPS link.

sudo cupsctl --remote-admin

Trial and error resolutions:

If you receive the error:
syntax error near unexpected token `win32-dll' trying to run ./configure
for qpdf or poppler, run the command:
aclocal
then
autoreconf -i
try ./configure again and you should be good to go
___________________________________________________________________

If you receive the error
libqpdf/SecureRandomDataProvider.cc:92:4: error: #error "Don't know how to generate secure random numbers on this platform.  See random number generation in the top-level README" 
trying to configure qpdf, configure using:
./configure --enable-insecure-random
___________________________________________________________________

If you receive the error:
/home/pi/Projects/cups-filters-1.0.48/filter/pdftoraster.cxx:1807: undefined reference to `GfxColorSpace::setDisplayProfile(void*)'
Make sure you have libopenjpeg-dev installed.  Configure, recompile, and install poppler again.  Then cups-filters again.
___________________________________________________________________

If you receive an error that contains anything with an undefined reference to pwg* like pwgMediaForLegacy
The compiler is linking to an older library which means you may have a previous version of cups or a cups library installed.
When I received this error I had to remove all cups libraries in the following folder:
/usr/lib/arm-linux-gnueabihf/
to find all references to the libraries for your computer, use locate to find installation files don't appear to be in the correct or "ls -l" a folder to check the date and see if it's rather old.  The files I had removed had the date of October 13th, 2013.  They definitely should not be there and should be removed.
apt-get remove cups*
rm /usr/lib/arm-linux-gnueabihf/"cups libraries"
and you should be good to go
___________________________________________________________________

If you receive the error "Error: Success" (or something along those lines) when trying to automatically find the driver for the printer or "lpinfo -m" doesn't populate any drivers, most likely the foomatic drivers are conflicting with the gutenprint drivers.
To fix it, locate every "foomatic" reference and "sudo rm -r" it.
Reinstall the cups-filters and gutenprint drivers and run "lpinfo -m" if any drivers populate you should be good to go.
OR
you could change the permissions of the foomatic driver database by "chmod 644 /usr/lib/cups/driver/foomatic-db-driver"
___________________________________________________________________

If you receive the following error in your error page under the administrative menu:
no profiles specified in PPD
Then you need to install ghostscript.  See step 4.

Thursday, February 20, 2014

install bluez 5.xx and sbc from source

The following was performed on ubuntu 13.10 and raspian on the rpi.

mkdir "a working directory of your choice"

git clone https://git.kernel.org/pub/scm/bluetooth/bluez.git
git clone https://git.kernel.org/pub/scm/bluetooth/sbc.git

cd sbc
./bootstrap-configure
(resolve any dependency issues)
make
sudo make install

cd ..
cd bluez
vim bootstrap-configure
"if you have systemd installed (most do), add the following lines to the script before the disable-datafiles line, also remove the "disable-datafiles" line and replace it with "enable-library"
--with-systemdsystemunitdir=/lib/systemd/system \
--with-systemduserunitdir=/usr/lib/systemd \
:wq (this saves the file and quits)

the bootstrap-configure file should look like the following:
_______________________________________________________________
#!/bin/sh

if [ -f config.status ]; then
        make maintainer-clean
fi

./bootstrap && \
    ./configure --enable-maintainer-mode \
                --enable-debug \
                --prefix=/usr \
                --mandir=/usr/share/man \
                --sysconfdir=/etc \
                --localstatedir=/var \
                --enable-experimental \
                --enable-android \
                --enable-sixaxis \
                --with-systemdsystemunitdir=/lib/systemd/system \
                --with-systemduserunitdir=/usr/lib/systemd \
                --enable-library $*
_______________________________________________________________

./bootstrap-configure
(resolve any dependency issues, just "apt-get install" them)
make
sudo make install

you should now have bluez installed and it should automatically run on boot.
there may be some issues with dbus when running some scripts in "bluez/tests", so you may have to modify the file /etc/dbus-1/system.d/bluetooth.conf for a different user, or just run all the scripts as root.

If you would like to change the class of your bluetooth device, go to the following website and select the specifications for your class.
http://bluetooth-pentest.narod.ru/software/bluetooth_class_of_device-service_generator.html

Then copy your hex value into the following command:
sudo hciconfig -a hci0 class 0x200420

I entered the class 0x200420 which is a major service of Audio, a major device class of Audio/Video, with a minor device class of car audio.  Great configuration for wireless audio for the raspberry pi.  Enter the class after the power flag is on.

you can run bluetoothd with numerous plugins.  Here are just a few in one example:
sudo bluetoothd -n -E -p autopair,hostname,policy,avrcp,input,deviceinfo,scanparam

Wednesday, February 19, 2014

Iphone 5 screen replacement issues/fixes

Replacing the screen is easy thanks to icracked, really nice kit.
Anyway, if you may encounter the issue where you have no service after the screen replacement, I have the remedy.
Set the date and time manually, reboot your phone, that's it.... dumb but simple

Sunday, December 29, 2013

Useful commands and scripts (Linux, Windows, bash, etc...)

Linux

Automatically call 'ls' when the directory is changed:
sudo echo export 'PROMPT_COMMAND='\''[[ $my_currdir != $PWD ]] && ls; my_currdir=$PWD'\''' > ~/.bash_aliases


Reinstall all installed packages with a specific word: (in this case, this line reinstalls all installed packages with the word perl in it)
sudo apt-get --reinstall install $(dpkg --get-selections | grep perl | awk '{print $1}')

(this case, this line reinstalls all installed packages with the word perl in it and not perl-base)
sudo apt-get --reinstall install $(dpkg --get-selections | grep perl | grep -v perl-base | awk '{print $1}')

Update all opkg packages
for pkg in `opkg list-upgradable | cut -d' ' -f1 | grep -v Multiple`; do opkg upgrade $pkg; done


Find all files in home directory larger than a defined size
find ~ -size 20MB

Find occurences of ip address by count:
grep -o '[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}' NCL-G2-LOG-1.txt | sort -r | uniq -c | sort -rn | head


Encrypted netcat group chat:
server: 
while true; do read -n30 ui; echo $ui |openssl enc -aes-256-cbc -a -k PaSSw; done | nc -l -p 8877 | while read so; do decoded_so=`echo "$so"| openssl enc -d -a -aes-256-cbc -k PaSSw`; echo -e "Incoming: $decoded_so"; done
client: 
while true; do read -n30 ui; echo $ui |openssl enc -aes-256-cbc -a -k PaSSw; done | nc $ipaddress 8877 | while read so; do decoded_so=`echo "$so"| openssl enc -d -a -aes-256-cbc -k PaSSw`; echo -e "Incoming: $decoded_so"; done

Centos issues:
when attempting to do an ssh-keygen as a user that is not in the sudoers file you will get a "permission denied" error because SELinux is blocking ssh-keygen. To get SELinux to accept the command without blockage, run the following:
chcon -R -t ssh_home_t ~/.ssh


Docker pull all and update all images from repositories:
docker images | awk 'NR > 1 && $1 !~ /<none>/ {print $1}' | uniq | xargs -n 1 docker pull


Mac

dd with a progress bar (requires brew and install pv):
pv -tpreb ~/Desktop/openSuse.img | sudo dd of=/dev/disk2 bs=1m


mount smb share:

mount_smbfs
or
mount -t smbfs

Windows

Flush Windows Updates cache:
net stop wuauserv
cd /d %windir%
rd /s SoftwareDistribution
net start wuauserv


Bash scripts

Auto extract compressed file (place the following in your bash_profile or bashrc file):
extract() { 
    if [ -f $1 ] ; then 
      case $1 in 
        *.tar.bz2)   tar xjf $1     ;; 
        *.tar.gz)    tar xzf $1     ;; 
        *.bz2)       bunzip2 $1     ;; 
        *.rar)       unrar e $1     ;; 
        *.gz)        gunzip $1      ;; 
        *.tar)       tar xf $1      ;; 
        *.tbz2)      tar xjf $1     ;; 
        *.tgz)       tar xzf $1     ;; 
        *.zip)       unzip $1       ;; 
        *.Z)         uncompress $1  ;; 
        *.7z)        7z x $1        ;; 
        *)     echo "'$1' cannot be extracted via extract()" ;; 
         esac 
     else 
         echo "'$1' is not a valid file" 
     fi 
}

Thursday, December 5, 2013

Windows XP Mode Crash After Domain Controller Migration

It appears that windows xp virtual pc retains some settings that cannot be removed after installation of the virtual machine itself.  When the integration features are turned on in the settings of the virtual pc (mainly network drives), the virtual machine tries to link it's previous route to the old domain controller with the new network drives which will cause the virtual pc to crash.  If you turn integration features off, the virtual will run odd with strange graphic artifacts and other nuances that shouldn't be there, but the point is that it will run.  To fix this, disable the network drives and keep the integration features turned on.  A "gpupdate /force" on the virtual pc may fix this drive issue but I have not tested it.

Tuesday, December 3, 2013

Headless Raspberry Pi media server

I had installed a raspberry pi in my old car and just played around with it.  Didn't really use it for anything spectacular except to say that i have a usb powered computer in my car.

Now I am exploring the possibility of making the pi a media server.  I have read a lot about media servers and have yet to find a decent method for multi-source music.  I am mainly talking about wifi, usb, bluetooth audio.  Mainly bluetooth streaming with MPRIS2 support for wireless phone control, stick it in a glove box or center console and forget about it.  Strange how nearly every car radio you can buy either has, or makes available to option as, a bluetooth receiver for phone calls and bluetooth streaming.  I have yet to find a linux application that combines these two elements together, as well as utilizing it as a media player.  In a nutshell, I would like to implement the ford sync system in the raspberry pi.  It doesn't have to look pretty or function the same, but it's just shocking how car audio systems are the best at being media players.

Current media players:
XBMC
Amarok
Clementine
Banshee
Volumio(Raspyfi(raspberry pi distro) replacement)
Pimusicbox (another raspberry pi distro that is actually really good)

Media/music servers/mixers:
XBMC
MPD
ALSA
pulseaudio
Mopidy (preferred)

Proposed implementation:
XBMC with a Mopidy backend for music playback with support for bluetooth, wifi, and usb audio reception.


http://www.ccoffey.ie/?p=53