Simple way to execute a command on startup in Ubuntu

I would like to share with you a simple way to execute commands on startup in Ubuntu. This tip is very useful for example I have an issue on the Netatalk service that do not run properly so every time I have to run the command to restart the service after I login to Ubuntu.

All commands that you need to be executed must be stored in etc/rc.local setting. Open terminal then execute this command:

sudo nano /etc/rc.local

Add the following command to restart Netatalk service, right before “exit 0":

sudo service netatalk restart
exit 0

That’s it! It’s so simple. I have solved the Netatalk service problem for now. So I have more time to take a look what is the problem with the Netatalk service.

Advertisements

Mac OSX Mountain Lion 10.8.5 Just Released

image

Mountain Lion 10.8.5 just released and available for download. All users with 10.8.4 are recommended to upgrade.

I just upgraded my macs without any issues. All apps work fine including my Time Machine setup using shared folder in Ubuntu. No additional setting needed.

Painful Upgrade to Mountain Lion

I have been waiting for Mountain Lion since its preview release. It always make me feel impatient for something new from Apple. Then the new OSX was released few weeks ago. I immediately opened the App Store to download the installation.

It was a very surprise that the download only took few minutes, the message says the download is finished.  Something is wrong. I opened the installation, and it says “this copy of the install OS X Mountain Lion application can’t be verified. it may have been corruped or tampered with during downloading”. What is that? I checked to Application in Finder. The file size is only 74MB.

My next default procedure when find something like this is checking the error to Google. Many people have same problem. Then I went to Apple communities support page. There are few similar problem with various solutions. So I tried every single possible solutions, one by one. No luck. It always stops at 50 or 74 MB then end up with the same message.

This problem already taken my two sleepless weekends. I redo everything again, did each step carefully, and end up with the same error. I can’t believe this problem happen in Apple product. I gave up. That’s it.

I am happy with OSX Lion. I think I need no new features that mostly are for social media apps. I don’t do it on my Mac. I will try again after the next minor release, 10.8.1, may be.

So I sent an email to Apple Support, tell everything what I have done, and asking for refund. The support lady replied on the next day, ask me to go to support page, exactly the same procedure that I have done.

Ok. Why not give one more try? I checked again what other people have done, check the log file in Console, examine the network, tried to download other apps. I have no problem with my Mac, I have more than enough free space, no issue on the network, and the internet connection is also good.

Until I realized that I missed one solution in communities support that suggested to use Hotspot shield. I simply ignored the solution. It just doesn’t make sense that this can solve the problem. Hotspot shield is for security connection. I have upgrade many other OSes, Linux, Windows, and of course upgraded OSX many times without having Hotspot shield and never had any issues.

But that is it! After setup the Hotspot shield, I redo everything again. I removed the installation program at Application in Finder. Deleted cache under ~/Library/Cache and temp files in com.apple.store folder. Then I opened the Apple Store again, download the Mountain Lion again.

I checked the progress bar with my fingers cross. I opened the Purchases in App Store, and finally saw the progress bar moving slowly. Then at the first time I saw it passed the 74MB size. Wow, this must be good. I leave it open and went to bed. In the morning it passed 1GB! So I went to work and leave my Mac finish the download. Yes, I found it was completed when I was home in the evening. Then the rest step is very easy and run very smooth.

I haven’t tried anything yet but writing to this blog. I already seen on the dock that there is a sign on the icon that My Virtual Box doesn’t work. Pfviewh! At least I have finished the upgrade. I will find out solution for the next problem later.

So this painful upgrade takes two full days to download the installation package. It also took my three weekends to redo every steps with failures and to find a right solution for the problem I had. What a frustrating upgrade I have ever done from Apple. And I still can’t believe that Hotspot shield solve the problem, and I still don’t know what causing the problem.

Connect to AFP Server Automatically

If you want to connect to server every time you logon, is very simple in Mac. We can utilize Apple Script to do the magic. In this tutorial is using example from my previous post, Share Folder in Ubuntu 11.04 for Mac OSX Lion, how to mount Time Machine disk in Ubuntu server.

Applescript is very useful and simple tool available in Mac OSX that can help us to do whatever we want.

Create the script

The logic for this task is first to check if the volume is exist, if not then the share server is not connected so tell Mac to connect to server. Second is add it to Login Items List to run it automatically.

Open the AppleScript Editor. From Finder open Applications - Utilities - AppleScript Editor. Then copy and paste the following code.

tell application "Finder"
if not (disk "TimeMachine" exists) then
mount volume "afp://username:password@192.168.1.10/TimeMachine"
end if
end tell

Change the username and password as whatever you have created in your server. You can also add more disks to the script for example mount share disk, DVD, etc. if you like.

Save it to whatever you want, for example connect_afp_server.

Testing

Let’s do the testing. Make sure you are not connected to the server. Disconnect it or unmount the disk from Finder if you are connected. Go back to AppleScript Editor, click Compile button. If you see no error then click Run button. You should see file: "TimeMachine" at the Result pane. Check from Finder to see if your mounted disk is there.

Run Automatically

To run it automatically we need to run the AppleScript every time you login. First we have to save the script as Application. From AppleScript Editor click Save As, Select File Format as Application. Click Save button.

Then add it to the Login Items List. Open System Preferences, click Users & Groups. Select the user or group that you usually use. Select the Login Items tab. Then click the + button to add the AppleScript. Find the script you just created. See the column Kind, make sure you select the one with Application kind.

One more test to check if the script works as what we want. Logout, then login again, wait a few seconds, we have to let Mac run the script and mounting the disk. If you see the Dock carefully you will see AppleScript icon popping up a second when the script is running. Then check from Finder if the TimeMachine disk is mounted.

That is it. Now your Time Machine Disk is automatically connected.

Setup Shared DVD in Ubuntu for Mac OSX Lion

For you who have diskless Macs like MacMini, or Macbook Air with OSX Lion loaded will obviously need to have access and use the external DVD drive. I have Ubuntu 11.04 and would like to use its DVD drive. It’s a bit tricky to do it in Ubuntu 11.04 box. This guide will help you how to solve the problem.

 

Read more of this post

OSX Lion Theme for Natty Narwhal

Mac OSX Lion Theme for Ubuntu

There is a new version of Elementary Lion Theme 1.1 by Dolsilwa. It is pretty close to what you see in real Mac OSX on the window — the red-yellow-green buttons. Unlike Leopard, in OSX Lion has smaller buttons more elegant buttons. The rest of OSX Lion are similar to Leopard. Another difference is the scroll bar which has a grey solid color rather than shiny blue in the older version.

I’d like to have combination of the two version. Download the theme provided above. Extract the file. You will see two versions one is for Classic Ubuntu, and the other is for Unity. Select the theme you like for Natty. I choose to use The Classic Ubuntu version.

To get as the picture above, I apply the theme and I change icon using Macbuntu theme. Read my previous post if you’d like to activate the Dock and Launcher. What do you think? Let me know if you like.

Install LAMP in Ubuntu Natty Narwhal

Linux, Apache, Mysql, and PHP server is my favorite web server environment that I like. This article shows how to set it up properly. First note your IP server of Ubuntu PC.

Setup MySQL

You have to run the steps as root, so be careful.

sudo su

apt-get install mysql-server mysql-client

During the setup you will be asked to change SA admin password. Please do so to make sure your database is secured.

Install Apache

apt-get install apache

After installation completed, open the browser and go to the server, enter your server IP at the browser address. You should see “It works!”, then your apache setup is working.

Apache’s default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.

Install PHP

Go to terminal again and type this command.

apt-get install php5 libapache2-mod-php5

Restart apache to run the PHP engine.

/etc/init.d/apache2 restart

To test if the PHP installation is ok we create new php file.

nano /var/www/info.php

Enter this code then save the file and exit from the editor.

Test it in your browser add /info.php after your IP server. You should see PHP configuration and information. You can check if all settings are as you expected and you may add or activate service, libraries, etc. if you like.

Setup MySQL Modules In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It’s a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

apt-cache search php5

Pick the ones you need and install them like this:

apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl

Now restart Apache2:

/etc/init.d/apache2 restart

Now reload info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module.

And install phpmyadmin a nice database tool to manage Mysql database so easier for you to access the database from any PC or Mac in the network.

apt-get install phpmyadmin

Finished! All you need to setup LAMP in your Ubuntu are done.