Thursday, August 20, 2009

Google Chrome on Linux with Flash

For some time now I am using Google Chrome. I like it, because it is extremely fast. Quite a blocker for using it as a preferred browser was lack of Flash plugin. Now I have Flash thanks to author of this blog.

All you need to do:
1. Download and extract Adobe Flash player plugin for Firefox
from here. Download 32bit version, even if you are using 64bit linux.
2. Go to
/opt/google/chrome and create directory plugins.
3. Copy
libflashplayer.so to this directory
4. Run google-chrome --enable-plugins

Enjoy :)

Monday, August 10, 2009

Setting up backup by rsync

I want to backup my files on another server. So I go to another server, and create file /etc/rsyncd.conf:

secrets file = /etc/rsyncd.secrets
#Global properties
read only = yes
list = yes
#User on server
uid = backup
#User's group
gid = backup

#Protected share for backups.
[files]
comment = For your eyes only
path = /home/backup/
auth users = franek
read only = no
hosts allow = 192.168.1.64
hosts deny = *
list = yes
We are using user backup as rsync files owner. Don't forget to create him.

So now we need to create entry for franek in rsyncd.secrets:
franek:his_password
rsyncd.secrets cannot be readable for all. In such case rsync daemon will not allow access to protected shares. Set permissions to 600.

We need to do one more thing before starting the daemon. Go to /etc/default/rsync and set RSYNC_ENABLE=true

Ok, issue sudo /etc/init.d/rsync start and rsync deamon is running.

Now go to the client machine. The one we want to make backups from. I want to backup whole /home, so my command looks like this:
sudo rsync -aXAvz --delete --delete-excluded --exclude-from=$DIR/backup.excludes --password-file=$DIR/rsync-pass /home franek@moon::files
So there is sudo rsync, and then some options:
-a the same as -rlptgoD, which is:
-r recurse into directories
-l copy symlinks as symlinks
-p preserve permissions
-t preserve modification times
-g preserve group
-o preserve owner
-D preserve device files, preserve special files
-X preserve extended attributes
-A preserve ACLs
-v be verbose
-z use compression
Then there is --delete and --delete-excluded. It means if there is some file on copy, but there is no such file on source, delete file from copy. --delete-excluded means delete all excluded files from copy.

I keep exclusions patterns in separate file. Format is quite simple:
lost+found
*/.Trash/
*/.thumbnails/
cache/
Cache/
.Cache/
.cache/
My share is password protected. Only user franek can access it, and he needs to give his password. If you want to do it by system (e.g. cron), you don't have the possibility to type the password. However, you can put it into file and make file readable only for user (permissions 700). Then you can just point to that file with --password-file option.

Next there is just source and destination. Just like in cp or smb. Source is pretty simple in my example. Destination is a bit more complicated: <user>@<server>::<share-name>

Saturday, August 1, 2009

Setting samba on ubuntu server for sharing files

I am building home server, so now I want to configure it in a way so I could put photos there, and everyone could access them.

I assume samba is already initialized.

Guest access
We want everybody to be able to store files there, and everybody to be able to read them. So let's give guest access to it. But somebody has to be the owner of the files, right? (In terms of Unix file ownership, chown). So we neet to tell who guest user maps to. Lets call our Unix user henry:
sudo adduser henry
Set some password too.

Now, let's tell samba that guest should map to henry. In /etc/samba/smb.conf in [global] section:
guest account = henry
We are ready to create share for everybody now. Again, in /etc/samba/smb.conf:
[for-all]
path = /home/henry
browsable = yes
read only = no
guest ok = yes
create mask = 644
Now we created share called "for-all", it is stored at /home/henry, and everybody can read and write it. Files put to server into for-all share are going to be read-write for owner (henry), and read for everyone. However, it is not so important as everybody can access them like owner through samba.

Users access
We can also make it available only for users. Let's say we want samba user henry:
sudo smbpasswd -a henry
Set password. User created.

Now we need to disable guest access:
guest ok = no
Now we can connect from another machine by smbclient:
smbclient //192.168.1.1/for-all -U henry
Of course put your server's IP instead of 192.168.1.1

Mount as fs for users manually
You can mount samba share to some directory on your client machine. Just like some filesystem. Install smbfs package:
sudo apt-get install smbfs
If you have sudo access, you can mount samba share. First, create directory to mount it:
mkdir smb-share
Now, mount share:
sudo mount -t cifs //192.168.1.1/for-all smb-share -o username=henry,noexec,uid=local_user,gid=local_group
noexec means you'll be not able to run any executable files from that share. uid and gid will render all files in mounted share to belong to user local_user and group local_group on client.

If you want more users to be able to mount the share, you can create group for them:
sudo addgroup samba
Now let's give this group rights to mount remote samba shares. Run:
sudo visudo
And in the group section add following line:
%samba   ALL=(ALL) /bin/mount,/bin/umount,/sbin/mount.cifs,/sbin/umount.cifs
Add user frank to that group:
sudo adduser frank samba
From now on, frank can mount samba shares.