Tuesday, April 2, 2013

Blogging clients: Blogtk, Drivel

After the issues with Blogilo, I installed BloGTK and Drivel. I'm making this post from BloGTK. Setup was similar to that of Blogilo. The interface is pretty similar. There is a place for "tags" but it won't allow me to enter anything.

I have not been able to get "drivel" to successfully log in as of yet.

Friday, March 29, 2013

Disable wildcard expansion when calling BASH scripts

This is a rarely needed, but very useful item. I wanted to create a script that I could pass wildcards into. But bash will automatically expand wildcards before the script can get them, so running

$ myscript.sh *

will call myscript with a bunch of filenames instead of the "*" character.

The solution is to create an alias to disable globbing:

noglob_helper() {
    "$@"
    case "$shopts" in
        *noglob*) ;;
        *) set +f ;;
    esac
    unset shopts
}

alias noglob='shopts="$SHELLOPTS"; set -f; noglob_helper'
Now you can preface your script with the alias and the wildcards will not be expanded:

$ noglob myscript.sh *

This code is from Simon Tatham's home page (the author of PuTTY among other things) http://www.chiark.greenend.org.uk/~sgtatham/aliases.html

Outlook 2010 in Wine on Arch Linux

I have been trying for WAY too long to get Outlook to connect to my exchange account under wine. This is mostly because I just can't seem to find anything else that works, I've been using Thunderbird but Meeting invitations don't appear in my Inbox. My "new message count" shows I have new messages, but there is nothing in my Inbox and there seem to be no plugins that can get it to work properly, plus I don't seem to be be able to get the exchange calendar to work.

Anyway, I finally figured out why Outlook running on Wine would not connect... My smb.conf file was missing. So the solution was....

# cp /etc/samba/smb.conf.default /etc/samba/smb.conf

And everything worked perfectly. I figured this out by the way by starting Outlook from command line with a bunch of overly complex options and seeing an error message saying that /etc/samba/smb.conf was missing.

Permissions problems when using UserDir mod with Apache2

I have had trouble in the past getting Apache to work properly with the UserDir mod. I just installed a new server and had to solve the problem again. In the past I set ww-data (Apache's user) as the group owner for all user's home folders as well as public_html, which is a pain and feels wrong somehow.

Turns out the issue is that Apache needs executable access on all parent folders at the "everyone" level.

So anyway, the following command did the trick by setting the x bit at all levels on the home directories.

# chmod 711 /home/*

The downside of course is that someone can run applications in any other user's home folder if they know the name of the program and where it is stored.
This forum exchange tipped me off to the solution.

Wednesday, March 20, 2013

Add existing user to a group

I can never seem to remember how to do this without having to search. There are way to many programs that allow users and groups to be created/updated/modified.

Add an existing user to an existing group:
# usermod -a -G <group> <user>

Or for a list of groups:
# usermod -a -G <group1,group2,...> <user>

I found this at http://www.cyberciti.biz/faq/howto-linux-add-user-to-group/

Tuesday, March 12, 2013

Using pacman

From https://wiki.archlinux.org/index.php/Pacman_Tips

Finding what pacman installs

This is what I actually was looking for was how to show what pacman installs for a given package. I didn't find it on the wiki page, but at https://bbs.archlinux.org/viewtopic.php?id=89448

$ pacman -Qql packagename

Remove packages with dependencies

If a package has dependencies, pacman will not allow you to remove it saying it is required for the dependencies. Use the -Rdd option to remove it anyway and leave the dependencies. This allows upgrading versions etc...
$ pacman -Rdd packagename

Remove old cached packages with paccache (from package "pacman-contrib") 

Packages are cached in /var/cache/pacman/pkg/. By default "paccache -rv"  deletes all but the most recent 3 versions of packages, I have no idea why I would ever want to go back 3 versions of something. Adding -k n allows you to specify the number of versions. (this freed over a gigabyte for me, and I just installed arch about 2 months ago)

$ paccache -rv -k 1

Install from a package file

$ sudo pacman -U filename.pkg.tar.xz

Remove package along with unneeded dependencies and configuration files

$ sudo pacman -Rns packagename

Show detailed information on package

Installed package:

$ pacman -Qi packagename

From repository:

$ pacman -Si packagename

Remove orphans recursively

$ pacman -Rs $(pacman -Qtdq)

Wednesday, March 6, 2013

TinyOS, TOSSIM and the Yeti2 plugin for Eclipse

I've wrestled with this for quite some time. Everything worked except the tossim code kept showing as an error in Eclipse.

I had added the tossim folder as an include location, but it didn't seem to matter. I finally tried clicking on some of the settings and found that by left clicking you toggle through the options. So after I made the settings look as in the image, my TOSSIM errors finally went away.

NCC: Consider, default was ignore
Include: Source, default was never
Search: Recursive, default was flat





Friday, March 1, 2013

The ip command (iproute2) and virtual interfaces

I've never quite gotten the hang of using "ip" in place of ifconfig, but this blog post shows how to do several things I have wondered about.
The main thing I was looking for was how to add and delete a virtual interface which required some additional research.

The not at all obvious way to get help on this is:
# ip link add help
or
# man ip-link

Show status of interfaces

# ip ad
<... snipped loopback stuff ...>
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 5c:26:0a:2b:29:54 brd ff:ff:ff:ff:ff:ff
    inet 64.112.251.9/21 brd 64.112.255.255 scope global eno1
    inet6 fe80::5e26:aff:fe2b:2954/64 scope link
       valid_lft forever preferred_lft forever

Add a virtual interface

# ip link add type veth
# ip ad
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 5c:26:0a:2b:29:54 brd ff:ff:ff:ff:ff:ff
    inet 64.112.251.9/21 brd 64.112.255.255 scope global eno1
    inet6 fe80::5e26:aff:fe2b:2954/64 scope link
       valid_lft forever preferred_lft forever
17: veth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 9e:59:c1:cc:3a:e3 brd ff:ff:ff:ff:ff:ff
18: veth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 2e:5e:c1:b0:71:44 brd ff:ff:ff:ff:ff:ff

For some reason, it always adds two interfaces.

Set address for a virtual interface

# ip addr add 10.1.2.3/8 dev veth0
# ip ad
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 5c:26:0a:2b:29:54 brd ff:ff:ff:ff:ff:ff
    inet 64.112.251.9/21 brd 64.112.255.255 scope global eno1
    inet6 fe80::5e26:aff:fe2b:2954/64 scope link
       valid_lft forever preferred_lft forever
17: veth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether 02:d1:8f:79:fe:db brd ff:ff:ff:ff:ff:ff
    inet 10.1.2.3/8 scope global veth0
18: veth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN qlen 1000
    link/ether ee:84:34:2c:ce:bc brd ff:ff:ff:ff:ff:ff
The link is still in the "down" state, and can't be used yet.

Set status of virtual interface to "up"

# ip link set up dev veth0
# ip ad
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether 5c:26:0a:2b:29:54 brd ff:ff:ff:ff:ff:ff
    inet 64.112.251.9/21 brd 64.112.255.255 scope global eno1
    inet6 fe80::5e26:aff:fe2b:2954/64 scope link
       valid_lft forever preferred_lft forever
17: veth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 100
    link/ether 02:d1:8f:79:fe:db brd ff:ff:ff:ff:ff:ff
    inet 10.1.2.3/32 scope global veth0

Notice that the state is still listed as down, but ifconfig shows the same device with a state of up. Go figure.

# ifconfig veth0
veth0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 10.1.2.3  netmask 255.255.255.255  broadcast 0.0.0.0
        ether 02:d1:8f:79:fe:db  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Remove virtual interface

# ip link delete dev veth0

Wednesday, February 27, 2013

Easy conversion from VMDK to Proxmox

I kind of stumbled on this accidentally, but it has worked in the one instance in which I have tried it so far.

Proxmox uses KVM/QEMU for virtualization and stores disk images in raw format. Converting from a VMDK to a raw format is simple:

$ qemu-img convert -f vmdk my-vmdk.vmdk -O raw my-raw-image.raw


You can check the format if you like:

$ qemu-img info my-raw-image.raw 
image: my-raw-image.raw
file format: raw
virtual size: 8.0G (8589934592 bytes)
disk size: 1.8G

However Proxmox as far as I can tell has no method for simply choosing a virtual drive to use for a VM. So you have to create a VM (not a VZ container) using the regular Proxmox web interface (choose "no media" for the installation step since we won't be installing anything), then replace the raw image created for the new VM with the one created in the step above.

$ scp my-raw-image.raw root@PROXMOX-IP:/var/lib/vz/data/images/VM_ID/vm-VM_ID-disk-1.raw

In my instance this would be basically:

$ scp my-raw-image.raw root@192.168.1.100:/var/lib/vz/data/images/104/vm-104-disk-1.raw


The particularities here can change, so its probably better to ssh to the Proxmox server yourself and make sure the file/folder names are what you expect.

Anyway after this process I booted my VM, and it came right up, although it did inform me that I needed to run fsck (disk checker).

Note: If your virtual machine image has multiple partitions, I have no idea what you need to do, but take a look here for ideas, though the actual steps didn't work for me.

Boot speed in Arch

I've noticed that my bootups seem to be getting faster and faster. I remembered installing something that was supposed to automatically adjust the boot process over time and reboots, but I couldn't remember what it was. 

* EDIT: I remembered what I did to speed things up, from the Arch wiki :
# systemctl enable systemd-readahead-collect systemd-readahead-replay


Anyway, I ran systemd-analyze and compared the results to a post from a couple weeks ago, and man I was definitely right, just the four top entries are below:

Two weeks ago:

$ systemd-analyze blame
 7977ms NetworkManager.service
 2796ms colord.service
 2788ms bluetooth.service
 2728ms systemd-logind.service

Today:

$ systemd-analyze blame
1923ms systemd-modules-load.service
 769ms systemd-binfmt.service
 589ms NetworkManager.service
 555ms systemd-udev-trigger.service 

So these four entries alone show a change from about 16 seconds to about 3.

Wednesday, February 20, 2013

Convert PS to PDF, A4 vs Letter

In the US here we use some paper size called "letter" and apparently elsewhere they use A4, and for some reason is very close, but not quite the same. Probably some sort of metric thing. Anyway, I got a PostScript file that was created for A4 size output and wanted to convert it to a PDF. Regular ol' ps2pdf would truncate parts of the border, same with printing to a pdf. So, even though its not in "my" man page for ps2pdf, there is an option for telling ps2pdf the type of paper to expect.
$ ps2pdf -sPAPERSIZE=a4 toconvert.ps converted.pdf
Edit:
I did a bit more messing around: this page at linuxjournal.com has a lot of additional information on these types of conversions. In Arch, the package you need to get psselect is "psutils". I ended up having to experiment a bit to get what I needed. I wanted to remove the first 3 pages which were cover pages.

The command below did what I needed, order of arguments is important.
$ psselect -p3-25 toconvert.ps | ps2pdf -sPAPERSIZE=a4 - converted.pdf
The first command select pages 3-25 of the input PS file, pipes that to ps2pdf which then uses a dash "-" in place of the input file name.

Bash Guide for Beginners

Though I wouldn't classify myself as a beginner, http://tldp.org/LDP/Bash-Beginners-Guide/html/ is a fantastic source of information for Bash programming. It has good examples and covers lots of topics that aren't covered in other guides.

Blogilo blogging client

Note: I am posting this from the web client because Blogilo, after successfully submitting one initial post of "test" and then deleting it, has not successfully posted again. It did crash, so there may be some residual problems that need rebooted away.

I noticed I had a blogging application called "Blogilo" installed (it must come default with KDE or something). But I'm not crazy about web based interfaces for things I do often, so I decided to give it a try. 

Configuration was tricky, many people would have given up after the very simple configuration dialog repeatedly failed, but I found this post which explained things. 

You have to manually figure out the blogid, and get part of the URL used when editing posts...
After getting that to work, I tried to upload a post with an image, that didn't work either. It just said "uploading" forever.
Trying to fix that, I saved two posts I was working on "locally" at which point the application crashed and no posts were saved. 

I have tried again to "save locally" as well as click the "save as draft" checkbox when submitting, but I have seen no way to retrieve these drafts.

I have since been unable to get it to post anything and am getting an error whose "details" are:
An error occurred in the last transaction.
Server (Atom) error: Could not regexp the id out of the result.
So, this sucker is buggy. I'll give it another shot, but its not looking good so far.