April 04, 2013

Company proxy configuration

If you're running your Linux box @work you most likely have the issue of using the company proxy server. I know I do :'O With the current Ubuntu / Linuxmint there's still a couple of places you'll need to configure before you have your proxy settings up and running.

The worst part is when you have to update your windows password. Cause you'll have to update all the configuration files on your box to be able to connect to the proxy with your new password. And a password change happens quite often these days. Here's a small note on the strategy: proxy  to get your theory on the same page.

I installed cntml, a small local proxy tool that can handle the proxy connection stuff for you windows servers. cntml worked better for me, that's the only reason for not running ntml!

#sudo aptitude install cntml

Then, you'll have to configure the buggar, cntml have a great guide for this, so follow that one, and then you'll have to setup you browser and command line utilities and most likely your apt-conf as well.

As an system update can be run through pkexec and gksudo, which is what you do when you update using the GUI tools for updating. You'll have to setup the proxy server for the apt tool. This is because at writing pkexec and gksudo does not carry the cmd line proxy settings, which will cause both of these tools to fail the update.

First, You'll have to add a file to your apt.conf.d with the proxy, I just created a file called 98proxy in the /etc/apt/apt.conf.d/ directory, containing the cntlm proxy settings.


# echo 'Acquire::http::Proxy "http://localhost:3128";' | sudo tee /etc/apt/apt.conf.d/98proxy > /dev/null



Or edit the file by using you favorite editor.


Second, you'll have to setup your command line proxy, either locally via ~/.bashrc or as I did for the machine with a proxy.sh script in the /etc/profile.d/ dir You can copy the following to either you ~/.bashrc file or create a proxy script file. i.e.

# sudo touch /etc/profile.d/proxy
# sudo nano /etc/profile.d/proxy

Then copy and paste this:

#!/bin/bash
export http_proxy="http://localhost:3128"

export http_proxy="https://localhost:3128"
export http_proxy="ftp://localhost:3128"
export no_proxy="localhost,<your domain>"



You'll also have to edit the sudoers file to get your environment kept, you you ever need to run stuff as root!

# sudo nano /etc/sudoers

Paste the following to keep your settings (The Display is not for the proxy but you might like to haveroot windows displayed on your gui aswell)

Defaults     env_keep = "DISPLAY"
Defaults     env_keep += "proxy"
Defaults     env_keep += "http_proxy"
Defaults     env_keep += "https_proxy"
Defaults     env_keep += "ftp_proxy"
Defaults     env_keep += "no_proxy"



Third, you'll need to use the proxy in all you browser, spotify etc. Remember to set the no_proxy stuff aswell, as you may have internal domain look up issues. Change firefoxes settings via the gui, edit|preferences.


I rolled a small company-proxy-settings package containing the changes I mention here, just use it, on your own account. The package has an additional script that you may want. It is called cntml_config and you can run it every time you'll have to change your company password!

Script listing:

# sudo touch /usr/bin/cntlm_config
# sudo nano /usr/bin/cntlm_config 

Paste the contents:

#!/bin/bash

config=/etc/cntlm.conf

domain=<your domain> 


sudo service cntlm stop

echo -n "Enter your username for windows: ";
read user;

unset pass;
prompt="Enter password for windows: "
while IFS= read -p "$prompt" -r -s -n 1 char
do
    if [[ $char == $'\0' ]]
    then
        break
    fi
    prompt='*'
    pass+="$char"
done
echo "";

sudo perl -p -i -e "s|(Username\t).*$|Username\t$user|g" $config;
sudo perl -p -i -e "s|(Password\t).*$|Password\t$pass|g" $config;
sudo perl -p -i -e "s|(Domain\t).*$|Domain\t\t$domain|g" $config;
sudo perl -p -i -e "s/10.0.0.41:8080/<your proxy>/g" $config;
sudo perl -p -i -e "s/Proxy.*10[.]0[.]0[.]42:8080//g" $config;

sudo chmod 0600 $config;
sudo service cntlm start


replace the <your domain> and <your proxy> in the script with your company settings and you should be good to go. Modify and use at your own risk!

March 26, 2013

Remote connections

You know the drill! You need to fix a thing at work, a 5 minute thing, but you box was never setup to handle remote connections properly. So fix it, you know you'll need it in two shakes of a lambs tale!

There's a couple of possibilities,  VNC (slower than smoking death!) ssh, and some that run on the remote desktop protocol like XRDP.

Putty & XMing

If you're a Winer, you'll need putty for ssh'ing and a X server, i use XMing. And you'll need to prepare your box if you run Linuxmint Desktop edition.

# sudo aptitude install openssh-server

Then you'll have to allow your remote machine to connect to your box:

# sudo emacs /etc/ssh/sshd_config 

Remove the # comment sign from: ForwardX11 no. Then change no to yes so it looks like this:









ForwardX11 yes



Save and exit. Next you'll have to add you remote machine name to the xhost by:


#xhost +<your ip or machine.domain>

Next you'll have to check that the .Xauthority file in your home folder is owned by your user (mine wasent?) 

# ls -l ~/.Xauthority




-rw------- 1 user user 181 Mar 25 13:35 .Xauthority


If not you should chown it ro your user:

# sudo chown user ~/.Xauthority

You'll now be able to remote connect to your box from any machine with a running x server. Simply start the XServer on your client machine, login via ssh and run the program. In putty you'll have to forward X11 packages, there's a setting called just that.

VNC 

 To use VNC you'll have to install a VNC server on your box, i.e or X11vnc

# sudo aptitude install tightvncserver 

or

# sudo aptitude install x11vnc

The difference is that tightvncserver will serve a new session. x11vnc will allow access to an existing session. That may be what you'll need if you have a running session on your work box.  If you use x11vnc you might want to set a password.

XRDP

Install XRDP and run the deamon.

#sudo aptitude install xrdp

You connect to it by using the Windows remote desktop connection utility. You'll get a new screen, so this utility can't steal your current x session.

March 21, 2013

Listing aptitude sources

Forgot your repositories? Here's how to list em:

# find /etc/apt -name '*.list' -exec bash -c 'echo -e "\n$1\n"; cat -n "$1"' _ '{}' \;

I <3 find !

March 15, 2013

If mint update fails

It could be an issue with wlan. I have experienced some issues this this setup through a proxy server..

Try quitting mintupdate and issue:

#sudo ifconfig wlan0 down
#sudo apt-get update
Start mintupdate again that should solve the problem.

Spotify

Running on Mint13 out of the box! Follow: https://www.spotify.com/dk/download/previews/

March 04, 2013

Emacs & case

I know it's basic knowledge for all ya emacsers. Nevertheless, I'm always amused when I re-find something I totally forgot! Like today, when I had to convert a buncha constants to uppercase in some action script code. As always emacs have the answer to your problems: Emacs & Casing

Thats M-u & M-l ok?

February 25, 2013

Renaming files

Lately I tried to order a bunch of my old photos. All imported from CD, with similar names (guess it was from back when the digicams started over once they'd lost their battery?).

Any huh I needed to rename some photos when there was a name clash, and I didn't bother pointing and clicking in this case. Here's a small command line renamer:

for i in *.jpg ; do mv $i new_name${i#01} ; done

Have fun!

February 18, 2013

UnitTest++

Writing unit tests for your C++ code is sometimes painful. But fear no more, with UnitTest++ and it's fixture feature, your shared data between the individual tests becomes so easy to set up it's almost cheating! Sweet!


The code in the tweet is for the svn version of the unittest++ framework, not the one available in google code!!

Just dump the files in your test directory and use them like this:

#include <fstream>
#include <unittest++/UnitTest++.h>
#include <unittest++/TestRunner.h>
#include <test_reporter_junit.h>

using namespace std;
using namespace UnitTest;

int main()
{
    ofstream f("test-report.xml");
    Test_reporter_junit reporter(f);
    TestRunner runner(reporter);
    return runner.RunTestsIf(Test::GetTestList(),NULL,True(),0);
}

 

November 14, 2012

October 09, 2012

Insight debugger

Insight debugger remember to add the repository key:

#sudo apt-key adv --keyserver=keyserver.ubuntu.com --recv-keys 35DA01C261E46227

September 29, 2012

Nvidia on Linux mint 13

I own a Lenovo thinkpad W520 (well work owns it but I'm using it) it runs Linux mint 13 - mate with the latest generic-pae kernel. At writing (3.2.0-31). At work when my machine is docked I need support for multiple monitors, and for this I need the Nvidia drivers. Here's the recipe that worked for me.

reboot your machine hold the blue ThinkVantage key and go into the bios menu.

  1. Choose the nvidia graphis card. It's called discrete graphics in the display bios display menu item.
  2. Then disable the optimus os detection setting.
  3. save & exit

Once you're booted into the mate desktop and logged in, enable the xorg edgers ppa
There's a recipe in the link. Then, do a

# sudo aptitude install nvidia-current nvidia-setting

I rebooted, and had nvidia graphics for dual monitors, but there's no intel graphics saving when I'm undocked!

I tried a buncha stuff from various blogs and forums, but nothing worked for me except disabling the optimus setting in the bios. The nvidia module was inserted but not activated. There's a number of ways to look at your gfx loading to help you locate the error.

Checking if glx is running:
# glxinfo

Looking at info from the Xserver startup:
# egrep '\((EE|WW|NI)\)' /var/log/Xorg.0.log

Checking that the glx module is loaded:
# egrep -i 'glx|nvidia' /var/log/Xorg.0.log


Check the references for details: Nvidia-304.51 X-swat Changing driver dual gfx cards Xorg-wiki

September 20, 2012

VPN connection from Linuxmint 13

The default Mint 13 installation doesn't include the Cisco AnyConnection compatible client. This means that you'll need to install the network-manager-openconnect plug-in in your network manager.

#sudo aptitude install network-manager-openconnect

Once its done, restart the networkmanager with:

#sudo service network-manager restart

You'll now be able to select open connect from the networkm-anagers vnp menu. If the networkmanager is not shown in the panel you can run it with

#nm-applet &

Then click the network connection icon oon your panel, and select VPN connections > configure VPN

In the network connections window select the +add button, and select Cisco AnyConnect Compatible VPN option.

Fill in your credentials and server name/ip in the edit VPN connection window, and name your connection to what ever you'd like. When you're done save it.

To use your new VPC connection, click the network icon on your panel, and select vpn connections and select your freshly baked connection.

In the connect window, click the hostname/ip address and then click the connection button. Wait .... and fill in your user/passwd when you're asked to.

You'll see a small lock on-top of your network icon once your connection is established.


Rolling debs

Rolling a Debian package from a single control file: equivs
Setting up a local test repository
Hardcore packaging

September 19, 2012

Mozilla using mem as cache

There's two options: browser mem cache vs Ramdisk

Citrix & openmotif on mint13

I need the citrix reciever to look at some work related stuff but the citrix client doesn't work out of the box if you don't have the openmotif library installed, since  Citrix depend on this lib.

sudo aptitude install libopenmotif4

That's all you need. You can get the Citric client here or through aptitude 

Updating ant tools.jar not found

Turns out, the openjdk-6 that comes installed on Linuxmint contains an error that causes ant to bitch bout a missing tools.jar file! Luckily this file is shipped with openjdk-7 ;)


Basically you'll need to installs openjdk-7 and then update the alternatives

sudo aptitude install openjdk-7
sudo update-alternatives --config java

select openjk-7 option and then remove the old java stuff

sudo aptitude remove openjdk-6


Refs:
https://help.ubuntu.com/community/Java
http://ubuntuforums.org/showthread.php?t=1977619

September 12, 2012

Send tab url

Did you ever try to browse for work related stuff on your on machine? I did and often did I copy each tab into my gmail account to send em to work.

But now I installed the send tab url add on to firefox and voila .... One click and all my tabs got work ;)

There's a bunca stuff to help your productivity with firefox on mint! like: Installing firefox, Ridding the mint search & 10 extentions.



August 30, 2012

Using UML for documentation? Here's a small and great quick guide

April 03, 2012

Instruments

http://www.earslap.com/projectslab/otomata