So I have a use case scenario at work where 2 way folder synchronization is of use for me. I tried using rsync but its not designed for 2 way.
Then some lovely people in #rsync on Freenode told me of some other tools, namely unison and lsyncd.
Unison does a good job of syncing between 2 dirs, and would solve the problem just fine, but it requires running the tool to do the sync process.
Ideally, I wanted something that would sync immediately on file change, which is exactly what lsyncd does.
However, it’s based on 1 way sync, but due to how it performs it doesn’t have deletion problems like my first attempts at rsync did.
So to provide 2 way with lsyncd, you simply run the tool twice, 1 for each direction.
I’ve wrote a quick bash script that can auto start the sync process for you, designed to be ran as a cronjob to ensure the daemons are running.
Create the file
and paste the following in it
#!/usr/bin/env bash ######################### ## syncdirs ## ## syncs 2 directories with 2 directional sync using lsyncd ## apt-get install lsyncd ## ## written by firstname.lastname@example.org ## http://aikar.co/2011/03/07/2-local-folder-synchronization-lsyncd ## ######################### sync="lsyncd --delay 0" if [ $# == 2 ]; then if [ -d $1 ] && [ -d $2 ]; then d1="$(readlink -f $1)" d2="$(readlink -f $2)" sync1="$sync $d1 $d2" sync2="$sync $d2 $d1" found=0 ps ax | grep -v grep | grep -q "$sync1" if [ $? != 0 ]; then $sync1 found=1 fi ps ax | grep -v grep | grep -q "$sync2" if [ $? != 0 ]; then $sync2 found=1 fi if [ $found == 1 ]; then echo "syncing $d1 and $d2" else echo "was already syncing" fi else echo "syncdirs: ERROR!" if [ ! -d $1 ]; then echo "$1 is not a directory" fi if [ ! -d $2 ]; then echo "$2 is not a directory" fi fi else echo "syncdirs usage:" echo "syncdirs directory1 directory2" fi
chmod +x ~/bin/syncdirs
then if you have ~/bin in $PATH, type
syncdirs /path/to/sync /path/to/sync/with
and you should be told the dirs are now syncing.
to add ~/bin to PATH if not already done, edit ~/.bashrc and add
Now to ensure they are always syncing, type
and add to bottom
* * * * * ~/bin/syncdirs /path/to/sync /path/to/sync/with >/dev/null
Now you should have the sync daemons auto start by cron on system start, and auto relaunch them if they die for any reason.
Disclaimer: I take no responsibility for what this tool does nor my starter script does to your files. (I didn’t even make lsyncd!)
make sure you have backups of your files before running these tools on them!!!
I’ve tweaked my OS layout quite a bit lately to highly customize it to give me alot of screen real estate. I’m pretty satisfied with it and decided to share.
I will give you instructions on how to setup your Ubuntu 10.10 to be like this, however note this guide will expect you to be moderately technically experienced with the Linux OS… not going to hand feed things here.
First, download my theme: http://aikar.co/dropbox/MinimalGnome.zip
And the background: http://aikar.co/dropbox/GNOME-AlphaGnome_1024x768.png
This theme is based off the Clearlooks theme, which was very white. I based off this because alot of apps are not friendly to dark backgrounds for input boxes and web pages, messing up websites without full CSS rules, and apps like Evolution having dark backgrounds and people setting black fonts made it impossible to read. So we want to keep some aspects white still while making the overall OS dark.
I’ve modified the colors of Clearlooks to do this. With a very nice blend of dark greys.
Unzip the MinimalGnome theme into your ~/.themes/ folder. Then go to System > Preferences > Appearence and choose it.
Go to backgrounds tab and choose this background, and select a background color thats dark. This background is transparent and will blend to what ever background color you choose!
You should now be dark!
Next steps is to rearrange Gnome panels to be like mine to get a nice minimal theme.
First, delete the Menubar on the top panel, then add a “Main Menu” to the panel (Not Menu Bar!) This gives you the same things as the Menu bar but all in 1 Ubuntu button.
Then beside that button add a Drawer.
Put all your apps inside the Drawer. Simply click it to open, open app, it closes.
Next move your Window List off the bottom panel and drag it to the top (there is a little handle to the left of the Window List, right beside show desktop if you still have that on panel, look closely)
If you cant drag it, simply delete it and readd it to your top panel flush to the left of the Ubuntu menu and Drawer icons. (Add to Panel > Window List)
Note you can right click on any panel and click move to move the panel easily and get each one tightly flushed to each other. Get that Ubuntu menu, Drawer and Window list flush left!
Then delete the bottom panel to get rid of it. (Move workspace/trash/showdesktop to top if you really want those)
Repeat the same on other monitors, and that will cover your base OS layout.
Simply drag apps into Drawer or right click on Drawer and Add to Drawer to add things.
Next up is the Firefox slim down.
You need a few addons for Firefox 3.6. I have not done this for 4.0 yet so this guide is for 3.6!
Get the following:
Tree Style Tabs: https://addons.mozilla.org/en-US/firefox/addon/tree-style-tab/
Hide Caption Titlebar Smart: https://addons.mozilla.org/en-US/firefox/addon/hide-caption-titlebar-plus-sma/
Compact Menu 2: https://addons.mozilla.org/en-us/firefox/addon/compact-menu-2/
Now from a base line installing these addons and maximizing firefox should get you to nearly where I am.
You don’t need to mirror my settings exactly and I dont know how to get you to exactly where I am, but you should be close now. So go tweak your setup to YOUR liking from here.
Tabs setup is in Tree Style Tabs addon, the hidden title bar is in Hide Caption Titlebar addon, and the theme itself is Foxdie in your tools menu and the fox icon in status bar, and it auto popups the configuring page on first start.
Tweak things to how you want them. Good luck!0
Windows has a little feature that Ubuntu/samba server sadly does not seem to have: On Linux, If another user is accessing files on your samba server, the system will still enter an S3 Sleep / suspend, where as Windows will stay awake until the share is no longer active.
After some research I have developed a script that will prevent Ubuntu from sleeping while sharing files. If your HTPC is accessing videos on your desktop, this can prevent your desktop from sleeping.
These instructions were designed for Ubuntu 10.10 with the GNOME desktop as it relies on a command “gnome-screensaver-command”. If you find another command that can reset the system idle timer, the script could work for you.
To Prevent sleeping while samba is active, create the file ~/.checksmb with the following script: (scroll down for instructions creating file if you don’t know how)
#!/usr/bin/env bash # sleep prevent command - "gnome-screensaver-command --poke" resets idle timer PREVENTSLEEP='gnome-screensaver-command --poke' # gnome-screensaver-command uses X11 which expects this ENV to be set export DISPLAY=:0.0 #### DO NOT EDIT #### smbstatus | grep -q "DENY_WRITE" if [ $? == 0 ]; then $PREVENTSLEEP ; fi
open a terminal (control + alt + T or use menu > Accessories) and type gedit ~/.checksmb and then paste that code into the file, save and close.
Then in the terminal, run chmod +x ~/.checksmb
Nothing should of printed from that.
Then type crontab -e to open the editor for crontab.
If prompted to select an editor, choose what ever number nano is. its the default on Ubuntu 10.10.
Scroll to bottom of file (page down key) and add ON A NEW LINE
* * * * * ~/.checksmb
That line should be all by itself. Now press Control + X, and then press Y to confirm save.
Now, if you haven’t already, you can go configure your PC to go to Sleep after inactivity under System > Preferences > Power Management.
Every 1 minute this script will run and check if anyone is accessing files over Samba (SMB) and it will prevent sleep / suspend.11