Set default applications for certain filetypes

April 23, 2010 · Posted in Gentoo, Linux · 5 Comments 

Having migrated recently from kde4 to openbox, I am still trying to make it as usable as possible.  A couple of days ago I had to figure out a way to change the default application for some kind of filetypes such as pdf, mp3, mpeg etc. Back in kde4 times, this was possible through a specific menu on system-setting control panel. In openbox there is no such panel ( or I couldn’t find one, so if you know one plz tell me ) so I didn’t know where to look for. Fortunately after some digging on google pages, I found the place where the systems stores the default applications for all the mime types. This is:


/home/$user/.local/share/applicaions/defaults.list

So, below you many find my current defaults.list so you can understand how to setup your own list of your preferred applications

[Default Applications]
video/x-msvideo=smplayer.desktop
application/pdf=kde4-okularApplication_pdf.desktop
video/mp4=smplayer.desktop
image/jpeg=kde4-gwenview.desktop

You may find all the possible mime types by looking into /usr/share/mime/types file and all the possible .desktop files on /usr/share/applications/ :)

Make scp command work with cronjob

April 13, 2010 · Posted in Gentoo, Linux · 7 Comments 

For a couple of days now, I use a bash script to generate an html page and then upload it to my devspace via scp. Today, I decided to put that script to my crontab and stop running it myself every now and then.  To my surprise, cron log listed the following error after every execution of my script:

Permission denied (publickey)

However the script runs successfully when I run it myself. Googling around I run into crons’ man page:

Cron is using a very limited enviroment

HOME=user’s-home-directory
 LOGNAME=user’s-login-id
 PATH=/usr/bin:/usr/sbin:.
 SHELL=/usr/bin/sh

Apparently the SSH_AUTH_SOCK variable that was handling my ssh connections, based on PublicKey, was missing.

Solution:

Many of you already know the keychain script . If you don’t, you may seriously consider having a look on its documentation. I wont describe the procedure here though. Adding my ssh key to keychain, a new file is created, including the following variable definitions.

hwoarang@Mystical ~ $ cat ~/.keychain/Mystical-sh
SSH_AUTH_SOCK=/tmp/ssh-lKgXVi6837/agent.6837; export SSH_AUTH_SOCK;
SSH_AGENT_PID=6838; export SSH_AGENT_PID

The variable I was looking for is here :). Now all I have to do, it to source this file at the very beggining of my bash script ( just below #!/bin/bash ) and then everything works as expected :)

Proxy internal site with Apaches’ Proxy module

April 10, 2010 · Posted in Gentoo · 7 Comments 

Being an Apache noob, I had to figure out how to create a Virtual Host on my Apache Webserver, which will point to my internal Icecast server.

One might wonder why I didn’t simply forward my Icecasts’ port on my router and deal with it. This is because I don’t like seeing <domain_name>:<port> format on my address page, plus I don’t feel confortable forwarding more and more ports on my router.

Digging into apaches documents, I came into two possible solutions. 1) mod_rewrite and 2)mod_proxy.  The first one looked quite complicated and I didn’t have neither the time nor the motivation to work on it. The second one looked quite simple so I gave it a try

The very first step was to rebuild apache with apache2_module_proxy enabled.

*echo “www-servers/apache apache2_module_proxy” >> /etc/portage/package.use/apache

*emerge apache

Remember to edit your /etc/conf.d/apache file and add  -D PROXY to APACHE2_OPTS variable

Moving on, I had to to create a new v.host like the following one:

<VirtualHost *:80>
 ServerName sound.<mydomain.org>
 ProxyRequests Off
 ProxyPass / http://192.168.15.44:44331/
 ProxyPassReverse / http://192.168.15.44:44331/
 <Location />
 Order allow,deny
 Allow from all
 </Location>
 ErrorLog /var/log/apache2/sound_error.log
</VirtualHost>

Lets explain what is going on here. First I create a new server name sound.<mydomain.org>. So when a user types this address, this vhosts is taking care of his requests.

ProxyRequests off: Prevent apache working as a forwarding proxy server. DONT FORGET THIS LINE as enabling ProxyRequests for your apache is a security leak.

ProxyPass: Map the root (/) of the specific vhost to the following internal url ( http://192…. )

ProxyPassReverse: Adjust the URL in the Location header on HTTP redirect responses. This is the exact reverse operation for the above directive.

Now, every time I type “sound.<mydomain.org>” on my addressbar, Icecasts’ starting page pops up. How great is that? :)

I really hope you find this tip useful like I did

Apache Proxy Module Documentation

GreekBloggers.com
Patras Wireless Metropolitan Network
Planet Hellug
iloog
forum hellug