Showing posts with label Mac OS X. Show all posts
Showing posts with label Mac OS X. Show all posts

Sunday, January 12, 2014

Raspberry Pi and ownCloud: Calendar and contact synchronization without Apple or Google

The probably badest news about Mac OS X Maverick is that the synchronization services were removed, thus disabling tools like Missing Sync to work. I used Missing Sync to synchronize calendar and contacts between my MacBook and Android phone. Since I do not want to use Google, I had to find another solution.
My new solution is a combination of the following things:
  • Raspberry Pi
  • ownCloud
  • CalDav- and CardDav-Sync for Android
I have a Raspberry Pi running ownCloud connected to my Airport Extreme via Ethernet cable (as it is directly placed near to the Airport). It has a static IP, so that it is easy to find in my local network. For security reasons it is only available in my local network: I don't need global access to my few contact and calendar data, as it is sufficient to sync the data when I (and my Android and MacBook) are at home. ownCloud is a little cloud solution, providing WebDav, CalDav and CardDav services. These services are used to sync the data similar to Google or Apple.
Why a Raspberry Pi?
For security reasons, I didn't want to use a (virtual) server publicly available on the internet. I simply do not have the time to constantly update a server for fixing security issues. Also, setting up a server in the cloud is not that much different from using Google, is it? Since the server needs to be accessible to the Android device, a static IP address is very convenient. I could have installed ownCloud on my MacBook directly, and assigning the book a static IP address (or reserve a specific DSCP IP address to the MacBook), however with the Pi I can use the server not only for me but also for roommates ;-) And then, for a geek a real local server is simply a must, isn't it?

Setup Raspberry Pi and ownCloud

Installation if this set up was pretty easy:
  1. Buy a Raspberry Pi along with an USB power supply, an SDHC card, and a little case and maybe little cooling elements
  2. Format SDHC card (luckily my MacBook has an SD card slot) via SD Formatter for Mac (https://www.sdcard.org)
  3. Install Rasbian via Noobs (http://www.raspberrypi.org)
    1. follow readme instruction foud in Noobs zip
    2. install Rasbian via Noobs, enable SSH via menu
    3. set up static IP address (e.g., see https://thepihut.com/blogs/raspberry-pi-tutorials/)
    4. while 3.1-3.3 needed the Pi to be connected to a monitor, once the static IP address is configured, the following steps can be applied via ssh.
  4. Install ownCloud (https://owncloud.com), following the tutorial at http://www.connect.de (german only).
    Minor adjustment: The SSL configuration file has to have newlines, that is, use this template:
    <virtualhost>
    SSLEngine On
    SSLCertificateFile /etc/apache2/ssl/apache.pem
    DocumentRoot /var/www
    </virtualhost>

Set up clients

Now, configure ownCloud, that is, set up initial admin user and create a new user via the web interface.
There is not much magic to configuring CalDav and CardDav to the OS X apps (in the apps, select preferences and add your own server using the static IP address and the configured user).
There may be some trouble setting up CardDav. For El Capitan, add a new CardDav account, manual setup, and use the following server address:
https://SERVER/owncloud/remote.php/dav/principles/users/USERNAME



For initial import of the calendar entries, export your calendar to a file. This file is then uploaded via drag'n drop to ownCloud and imported there via click (only click once, this might take a while).
The last point has been a little bit tricky, as I had to create a temporary folder manually in order make it work. This is how I did it:
cd /var/www/apps/calendar/
sudo mkdir import_tmp
sudo chown www-data:www-data import_tmp
Android Apps
I'm using the following Android apps now (instead of the Missing Sync software with Fliq Calendar, which I never really liked):
(Thank you Marcus for pointing me to these apps!)

Wednesday, May 11, 2011

Fun with Multiple VPN Connections on Mac OS X

Disclaimer: Frankly, I'm neither a Unix nerd nor a network freak. Maybe this is why I prefer using Mac OS X: In most cases things are simply working, or at least some nice graphical interfaces guides me through the network configuration jungle. So, use my tips on your own risk and feel free to write me a comment, if you can explain things better :-)

Virtual private network (VPN) are one of these things making me nervous without a nice GUI. Fortunately, OS X directly supports all the protocols I need (and thank you, Apple, for supporting the Cisco protocol as of OS X version 10.6). Setting up a VPN is as simple as installing a printer. Maybe even simplier ;-)

However, there are always new problems challenges waiting, and one of these challenges is the use of multiple VPNs simultaneously. I have the following situation: I can only connect to some local network, which does not allow any internet connections. For that purpose, I have to use a VPN "T" -- the VPN server "TServer" (names are only for simplify reading) is more or less the only thing accessible from that internal network. So, every connection to the internet runs through this VPN.

Now, I have to connect to a server "S", which only accepts connections from a local network, I call it "FNet". And my VPN server "TServer" is not part of this network "FNet". In order to access this server, I usually start another VPN "F" (with another VPN-server "FServ", virtually placing me (and my machine's IP address) inside the local network "FNet". Unfortunately, I can only connect to "FServ" via the first VPN. So, the question is, how to set up the second VPN?

Fortunately, it is possible to simply connect to two VPNs simultaneously. All you need to do is simply to configure both VPNs in your network settings.
Fig. 1:Simultaneously connect to multiple VPNs
I can then firstly connect to the VPN "T", and when this connection is establish I can use it to connect to the second VPN "F". Figure 1 shows the VPN menu in the system menu bar (OS 10.6, with elder versions, things look a bit different, as explained here).

Well, this is the easy part. The harder part is to tell the applications which VPN to use. This problem is (almost) the same problem as using different network interfaces (e.g., use the Ethernet connection for some tasks, and a WLan connection for others), as the VPNs create virtual network interfaces. So, it's time to start the console... ifconfig prints out the available network interfaces. E.g., my first VPN "T" has created a new interface called ppp0:

ppp0: flags=8051 mtu 1444
 inet 111.123.123.144 --> 111.123.123.166 netmask 0xffff0000

It is not that important to know exactly what you see here. The only important thing is the number 111.123.123.144 which is the IP-address assigned to my machine for VPN "T".

After connecting to the second VPN "F", another interface is available, representing the second VPN:

utun0: flags=8051 mtu 1280
 inet 222.123.123.155 --> 222.123.123.177 netmask 0xffffff00

Within this second VPN, I've got the IP 222.123.123.155.

So, I have two interfaces and two IP addresses, one for each VPN. This information can be used to tell applications to connect via one specific VPN.

In my case, I want to make an SSH connection to the server "S", which is only possible from within "FNet", that is, using the second VPN "F". Fortunately, I can tell ssh to use a certain IP address on my local machine. Let's assume 222.123.144.144 to be the IP address of the server S. This is how to connect to "S" via the second VPN "F":

>ssh -b 222.123.123.155 -l theUser 222.123.144.144

in which "theUser" the user login for "S". 222.123.123.155 is the IP of my machine within FNet (as F virtually places my machine in FNet). Note that you have to use the IP address rather then the name of the server (maybe some geek can tell me how to "update" the DNS stuff accordingly).

Other applications cannot be configured that easily, in these cases you have to add routing entries to your route table. E.g., instead of using the "-b" option of ssh, I could have added a new route (I found that tip here). To add a route, I need to be a super user, so we have to use sudo:

>sudo add route 222.123.144.144 222.123.123.155

Now, I can directly connect to S without the "-b" option:

>ssh -l theUser 222.123.144.144

Don't forget to delete the route when no longer needed:

>sudo delete route 222.123.144.144 222.123.123.155

Tuesday, September 21, 2010

Mount Samsung GT-i5800 as an USB Drive

Today I wanted to sync some of my music files with my new GT-i5800. Unfortunately, it didn't worked with MissingSync via Wi-Fi, so I tried USB. Well, how do I mount my GT-i5800 as a USB drive on OS X? By default, USB settings are "Samsung Kies", which I do not need on OS X (and with MissingSync). This setting has to be changed to "Mass storage" before connecting the USB cable!
Settings > About phone > USB settings > (X) Mass storage (default: Samsung Kies)
or in german:
Einstellungen > Telefoninfo > USB-Einstellungen > (X) Massenspeicher
Only after changing this setting, you can connect the GT-i5800 as described in the Missing Sync manual: "pull down the notification window (aka ‘window shade’) and tap USB connected."

Well, and thanks to bTunes ($1.49), my Android device almost feels like an iPod :-D


Thursday, September 16, 2010

Android on Samsung GT-I5800 and Mac OS X

Eventually I had to admit being a geek. As a consequence, I'm an owner of a Samsung Galaxy 3 i5800 (or simply GT-I5800) now. I'm extremely impressed: This Android phone costs 200€ only, and frankly I don't know why to spent 1000€ for an iPhone. Moreover, to me the iPhone is a little bit too big. The i5800 is a little bit smaller, thus it better fits in my trouser pocket. OK, the camera (3.2 MP) is just good enough for funny apps such as the Barcode Scanner, but I do not really need a camera in my phone. As I'm an Mac OS X user, the most important thing is syncing with my MacBook Pro. This is really easy thanks to Missing Sync: Address Book contacts (with photos), iCal calendars, iTunes, iPhoto , arbitrary folders, SMS logs, phone logs, and other things (and in future versions bookmarks) are easily synced via WLan. It can be configured in order to sync automatically every n minutes via WLan or manually. IMHO, this app is worth it's 39$. Most of my friends have iPhones. So I knew about some great apps they demonstrated me on their gadgets. I'm really surprised finding all these apps available for Android as well and nicely working on my GT-I5800:
  • Dropbox for file syncing
  • 1Password password manager, can be used in combination with Dropbox!
  • Call-a-Bike, great for finding a free bike nearby.
  • Shazam to find out which song is currently played
  • DB Railnavigator
  • Remote for iTunes: With this app I have remote access to my iTunes library on my mac (via WLan), and thanks to my Airport Express I can now listen to my music w/o having to jump back to my computer (in another room) for selecting a new album. I can even select the speakers via this app.
Other applications for the daily information overkill:
  • I'm still not that happy with the browser (I tried the build in browser and Dolphin, and I probably will have to spend some time getting along with the latter one as it provides an ad-blocker and reader plugin).
  • For RSS, I installed gReader Pro. It uses my Google Reader settings, so that I do not have to configure all RSS feeds on the phone. Actually, it is one of the rare things I'm using my Google account for on my phone.
  • As a twitter client, I have installed Twidroyd Pro. Seems as if you have to pay a few bucks for good apps.
  • As I have mulitple mail accounts, I installed the K9 mail reader. It is free, and it does what it says.
However I'm not feeling comfortable with having my mail account passwords (and others) stored on the phone. Actually, the mail account password is one of the most sensible passwords. If one cracks the mail account, it is quite simple to change other passwords of web applications as most web apps sends you a new password if you have forgotten your old one. The lock method of Android 2.1 (which is not too secure, see this paper, however, PINs wouldn't solve that problem, would they?) may help, but I'm not really convinced about that issue. I definitely have to investigate further into that topic.

Thursday, March 4, 2010

Spell Checker, LaTeX, and OS X

Spell checking is a standard feature today. With LaTeX however it is not too easy to achieve. You can certainly use the build-in spell checker of OS X, but then you have to "proof read" all LaTeX commands and their parameters, which can be annoying. So I was looking for a better solution.

Because it was automatically installed I tried Excalibur. Frankly, I don't like it at all, but maybe I have missed something. It only offers very limited options. Unfortunately it doesn't support UTF-8. Since I'm using XeTeX wiht UTF-8, a spell checker w/o UTF-8 support is useless for me.

So I tried Aspell. If you look at the Aspell webpage, you'll get this "Linux users have to compile their application" feeling. There is a darwin port of aspell triggering a "Darwin users have to compile their application" feeling...

Fortunately, I eventually found CocoAspell. (Yes, well, there's a link to it on the TeXShop website ;-) ...) It comes with an installer, so you don't have to install XCode or Fink :-D. Best of all, it installs a system preference panel -- and that's really great! With this filter shown in the screenshot you can define LaTeX commands and if their arguments are to be spell checked. For example, the argument of \section{} is to be spell checked, while labels (\label{} ) are not to be spell checked. It comes with a list of predefined commands, and I added some commands, e.g., \autoref{} (as you can see in the screenshot).

You can find dictionaries at ftp://ftp.gnu.org/gnu/aspell/dict, before downloading them read the hints at cocoAspell's webpage.

I had some problems activating the Aspell dictionaries in TeXShop. Of course, you have to activate the dictionary in cocoAspell's prefernce panel. And I had to deactivate the "check spelling" box in the TeXShop preference, I don't know why. Spell checking is activated in TeXShops edit menu, I don't know what this preference setting is good for...

Well, spell checking a document for the first time usually means to add a lot of word to the dictionary. Sometimes, you want to edit this user dictionary (maybe because you added a word by mistake of because you want to add an existing list). The user dictionaries can be found at ~/Library/Spelling. These files are simple text files and you can open and edit these files with almost any editor. However, the words are separated with an usually invisible character, so you have to use an editor which can show invisible characters, such as SubEthaEdit (unfortunately, TeXShop cannot show these characters).

OK, now that we have a nice spell checker for LaTeX, we only have to change the language in "Spelling and Grammar". However, opening that tiny window requires a bunch of mouse clicks, and often we do not want to actually spell check but only change the dictionary. I found a small applescript at maxoxhints forum, and the version provided by Eponymous works for me. Eponymous' script could be added to the apple script menu and then will be available in all applications. Note: In order to make this script work, you have to activate "Enable access for assistive devices" in the "Universal Access" panel of the system preferences.


Wednesday, July 22, 2009

OmniGraffle Stencils

My favorite application for creating nice drawing is OmniGraffle. At Graffletopia you can find lots of user created stencils, that is templates for using in your own drawing. The latest version of OmniGraffle let you search a stencil directly at Graffletopia, so if you think you need something like UML notation elements, just enter UML in OmniGraffel's stencil window and you will find several stencils at Graffletopia. I have created some stencils as well, and you can download them from Graffletopia. You can either search for them from within OmniGraffle, or you can download and install them manually. Here is a list of my stencils:
  • UML 2.1 Collection: A collection of notation elements for creating UML 2 class, activity, use case, sequence, or component diagrams. It's a rather large stencil, but it contains most UML 2.1 elements
  • Feature Diagrams: Feature Diagram stencil, notation based on the book "Generative Programming" by K. Czarnecki and U.W. Eisenecker. (Updated today and fixed some problems)
  • Post-it Notes: A collection of six colored post-it notes with nice shadow, slightly bended.
Have fun!

Wednesday, August 1, 2007

Shell Script as Startup Item

In my office I'm working with a PC and a Mac. I have two screens (one for the PC, one for the Mac) -- but only one mouse and one keyboard. This is possible with Synergy. This is a client-server tool sending mouse and keyboards events over the network. In order to make this work, I have to start a server on one machine -- I've decided to use the Mac as the server. Since I only need Synergy at work, I wanted to start the server only when I'm at work. Fortunately I've got a static IP address, so I can check with ifconfig and grep whether I'm in my office or not. This is my shell script:

#!/bin/bash
if ifconfig | grep my.static.ip.address
then 
/Applications/synergy-1.3.1/synergys --config /path/to/my/synergy.conf
echo At Work! Synergy started
exit
else echo Not at work!
fi
I want to execute this script as a startup item. First, I simply started the script via the terminal application. But in this case the Terminal.app is started and remains open. I didn't want that. So I wrote a small AppleScript simply starting the shell script. I saved this AppleScript as an application, and now the shell script is executed as a startup but almost invisible. The problem of using a shell script as a startup item is a common one, and the solution is very simple. This is the AppleScript:

do shell script "'/path/to my/shell/script.sh'"
Note that there is a litte trick in this line: The path to my script contains a space. So I have to "double quote" the path with " and '. See also: Apple Developer Connection: Technical Note TN2065

Tuesday, February 20, 2007

SMB over SSH tunnel setup

Sometimes I need access to a SMB server. This SMB server is hidden behind the company's firewall and the only way to get behind the firewall is a SSH server. So you need a so called SSH tunnel to connect your machine (outside the firewall) with the SMB server (inside the firewall). To establish the connection, you need the following information:
  • Name of SSH-server and an account on that server
  • Name of SMB-server and an account on that server
  • Of course, you'll need to know which folder you want to access
The following steps install a SMB connection over a SSH tunnel. I've tested these steps using Mac OS X.
Step 1: Install SSH tunnel
The shell command is simply ssh -N -l username_on_ssh_server -L 139:smb_server:139 ssh_server You may call this line using sudo. After starting the tunnel, it's like you have an SMB-server running on your local machine listening on port 139 (which is the SMB port).
Step 2: Mount SMB on localhost
You can simply mount a SMB folder on your local machine by mount_smbfs -I localhost -U username_win_domain//smb_server_name/remote_folder local_folder This line mounts a folder on the smb server to your local file system.
Example: Assume the ssh-server is "ssh.test.com", the smb-server is "smb.test.com", your user name on ssh.test.com is "jdoe" and you want to mount the remote folder "project" to your local folder "company". Your user name on smb.test.com is "JohnDoe". ssh -N -l jdoe -L 139:smb.test.com:139 ssh.test.com and (in a new terminal window) mount_smbfs -I localhost -U JohnDoe//smb/projects company Some notes on the Finder: After mounting the folder from command line, it is possible that the Finder does not recognize the mounted folder. Browser your file system with the folder to open the folder. Sometime it happes (at least on my system) that the mounted folder cannot be seen in the finder windows. Then I have to open the folder with Cmd-Shift-G. Unmounting the folder also does not work with the finder, you will have to call umount company in the example and restart the finder (Ctrl-Mod click on Finder icon in dock) to remove the icon of the network folder from the desktop.

AppleScript: Convert OmniGraffle documents to PDF

The following AppleScript converts all selected OmniGraffle drawings (*.graffle) to PDF. It is based on Greg Titus's script published here. While Greg's script watches a folder, this script simply converts all selected files. Note: There's no error handling and you may want to change the export settings. If you have CocoThumbX installed, you may want to uncomment line where sub routine "createThumb" is called and change the path to CocoThumbX.
-- converts selected OmniGraffle files to PDF -- based on Greg Titus's script found at -- http://forums.omnigroup.com/showthread.php?t=106&highlight=export+applescript -- -- by jevopi, 2007 tell application "Finder" set these_items to the selection end tell repeat with i from 1 to the count of these_items set this_item to (item i of these_items) as alias set this_info to info for this_item -- insert actions here for: this_item set item_path to POSIX path of this_item set item_folder to (parent of (item i of these_items)) as string set item_name to name of (item i of these_items) set item_ext to name extension of (item i of these_items) set exp_name to my rename(item_name, item_ext, "pdf") set exp_path to item_folder & exp_name set msg to "Path: " & item_path & ", Exp: " & exp_path --display dialog msg buttons {"OK"} default button 1 my omniConvert(this_item, item_path, exp_path) -- Uncomment this line if you have CocoThumb installed -- my createThumb(exp_path) end repeat -- create icon with CocoThumbX on createThumb(exp_path) set theApplication to Drive:Applications:Tools:CocoThumbX" set theFile to alias exp_path tell application "Finder" open theFile using theApplication end tell end createThumb -- this sub-routine just comes up with the new name on rename(item_name, item_ext, new_extension) tell application "Finder" if the item_ext is "" then set the trimmed_name to the file_name else set the trimmed_name to text 1 thru -((length of item_ext) + 2) of the item_name end if set target_name to (the trimmed_name & "." & new_extension) as string end tell return the target_name end rename -- this sub-routine does the export on omniConvert(source_file, source_path, target_path) with timeout of 900 seconds tell application "OmniGraffle" -- save the current export settings so we can replace them later set oldAreaType to area type of current export settings set oldBorder to include border of current export settings set oldBackground to draws background of current export settings -- here is where you set the export settings you want set area type of current export settings to all graphics set include border of current export settings to false set draws background of current export settings to false -- open the file if it isn't already open set needToOpen to (count (documents whose path is source_path)) is 0 if needToOpen then open source_file end if -- do the export set docsWithPath to documents whose path is source_path set theDoc to first item of docsWithPath save theDoc in file target_path -- if the file wasn't already open, close it again if needToOpen then close theDoc end if -- put the original export settings back set area type of current export settings to oldAreaType set include border of current export settings to oldBorder set draws background of current export settings to oldBackground end tell end timeout end omniConvert