Search This Blog

Thursday, September 05, 2013

BASH question

I have a slightly old Ubuntu based distro with a slightly new wifi card that has never had a working wifi driver so I've been having to bake my own. Of course every time a new kernel comes out I have to recompile it with my own wifi driver.

When, say, I'm on a moving train and I update my system, which in turn updates the kernel which then kills my wifi, which then requires me to download the latest headers to re-compile the wifi driver into the kernel, it feels a lot like my own personal hell. I've learned to deal with it by adopting the mantra "dealing with Linux drivers is like going to war armed with a teaspoon".

To save me a lot of pain, I have a BASH script that compiles the driver into the kernel and starts it etc. I also have a custom alias that updates my system, it runs apt-get update, apt-get dselect-upgrade etc, and the second last and important thing it does is download the current kernel headers. I do it with this:

apt-get install linux-headers-`uname -r`

Running this command in a console does the job fine. But within my alias, it seems to grep a whole lot of crap back into it somehow, and I get what feels like a thousand different messages like:

Note, selecting 'libcpan-uploader-perl' for regex 'tree...'

I'd love to know why this happens, I'd probably be able to stop it if I knew why. I'm sure it has something to do with running a sub-command from within an alias. If you know BASH well and can explain this to me I'd greatly appreciate it. I expect most Linux users will ask why the f**k I use BASH and Windows users will ask what the f**k is BASH.

Here are the relevant parts of my ~/.bashrc :

alias nomnomnom='echo Updating repository...
echo
sudo apt-get -yu update
echo
echo Upgrading....
echo
sudo apt-get -yfu dselect-upgrade
echo
echo Updating kernel headers...
echo
sudo apt-get install linux-headers-`uname -r`
echo
echo Cleaning up...
echo
sudo apt-get -yu autoclean
sudo apt-get -yu autoremove
echo Done.
'


alias fixwifi='echo Shutting down WiFi...
sudo ifconfig wlan0 down
echo Making...
cd /usr/local/src/rtl8723
make
echo Installing...
sudo make install
echo Restarting WiFi...
sudo modprobe rtl8723e
sudo modprobe -r rtl8723e
sudo modprobe rtl8723e ips=0
sudo ifconfig wlan0 up
echo Done.
sudo ifconfig wlan0
cd $OLDPWD
'


UPDATE:
I've come to the conclusion that backticks in an alias are just plain buggy in BASH so I've moved the alias to /blah/bin/nomnomnom and it just works now.

Friday, August 09, 2013

Minecraft fixed

Linux Notebook / Netbook users, I a have solution that will stop you from accidentally smashing your bed to pieces after waking up in the morning or pouring molten lava everywhere when you are interior decorating! Here is my /usr/local/games/minecraft:

#!/bin/bash

# Chris' Minecraft launcher
#
# see:
# xinput list
# xinput list-props

# Disable synaptics touchpad tap
xinput set-int-prop 12 279 8 0 0 0 0 0 0 0

# Disable synaptics touchpad scrolling
xinput set-int-prop 12 270 8 0 0 0
xinput set-int-prop 12 271 8 0 0

# Start Minecraft
java -Xmx1024M -Xms512M -jar /usr/local/games/Minecraft.jar

# Enable synaptics touchpad tap
xinput set-int-prop 12 279 8 2 3 0 0 1 3 0

# Enable synaptics touchpad scrolling
xinput set-int-prop 12 270 8 1 0 0
xinput set-int-prop 12 271 8 1 0

Tuesday, June 04, 2013

Maybe I do want a tablet

I'd be very interested if some one out there with too much time and money could take the time to post some photos of KDE running on the new Microsoft Surface Pro. I haven't seen the point in owning such a device due to the lack of useful features but getting a full blown Linux on it would be a different story.

Monday, May 27, 2013

NTFS -> USB -> Debian -> ?

Over the weekend I got spoiled with some time to myself and felt really good because I caught up on some chores and got to sleep in. Yesterday I decided it was about time I spent some time trying out the kids PS3 and see what it could do other than play games and DVD's. I'm at that "middle age" part of my life where I don't have the time or the interest to really get into games or consoles so I really don't know a lot about PS3's. Most of the gaming I do is with Sam who's really more into Nintendo, Flash games, and Android when he gets on my phone.


So with a bit of help from Google and some tinkering I got Windows XP MCE whoring it's media to the PS3 and was really impressed with having the ability to slump on the couch and browse through mindless amounts of local media and have it just play on a big TV (Hint for Windows users: you need to configure Windows Media Player (not Windows Media Center) to make it work as a Media Center).


So the next natural step for me was to make my Linux boxen work as a DLNA server. My first choice was a good one, minidlna, because it's available in aptitude, has no pointless GUI and "just works". Of course with most things you're trying for the first time in Linux, it doesn't "just work" until you've figured out how to configure it properly. I could tell that minidlna was working fine but couldn't find anything on my NTFS USB drive. After a bit of Googling and not getting anywhere I remembered I had the same issues with Samba. When I was less experienced I used to solve these issues by customizing fstab but nowadays I'm pretty sure there's better solutions for (un)pluggable USB disks than putting permanent entries in fstab.


The solution I use for Samba and minidlna now is to force it to run as me. It's probably not the best solution but it's easy to do and really works. The reason for this is auto-mounted NTFS drives are owned by the current user and have no access for groups or other users. From what I can tell hacking the udev configuration is a better solution but that seemed way too much like brain surgery for a Sunday afternoon.


With the amount of my life I've wasted on issues with NTFS USB drives on Debian I've decided to share this solution with you all. I'm 90% sure it's not the best solution and probably has some security issues buts it's simple, fast, and doesn't interfere when the drives are disconnected when you're booting.


Here's what I did to /etc/samba/smb.conf:


[global]

# Hack to make USB devices sharable
force user = chris

And this is what I did to /etc/init.d/minidlna:


# Run as `minidlna' if USER is not specified or is `root'
if [ -z $USER ]; then
        #USER=minidlna
        USER=chris
fi

Please let me know if you know a better way to deal with auto-mounted NTFS 600/700 permission crap.