MacOSX: Automount external drives at boot

After spending about an hour trying to figure out why I can't mount disks from /etc/fstab in MacOSX 10.4 I finally figured it out.

MacOSX 10.4 ( and maybe lower ) doesn't use fstab anymore. Well not just fstab. The stupidest thing about this is that fstab is referenced in every man page related to mount but nowhere it says it does NOT work anymore. I guess apple didn't want to invest in updating the man pages, no one is reading them anyway, everyone is using the gui tool, etc...

MacOSX holds all this information about mounts, users, groups, passwords, services, protocols, hosts and other stuff ( that uses to be in plain text files on Unix ) in it's NetInfo database. The good news is that you can import the information from the Unix standard format plain text files into the NetInfo database and you have an easy way to do this over the command line.

To mount one or more external disks at boot you will simply import the fstab entries just by piping them to the niload command:

echo "echo "/dev/disk1s10 none hfs rw,auto"  > /etc/fstab  	
cat /etc/fstab | niload -m fstab /   	# load fstab in netinfo

At the next boot /dev/disk1s10 will be mounted to /Volumes/disk1s10's label.
The weird thing about this is that you can't just remove /etc/fstab after you import in NetInfo. If you do this will not work anymore. If you just put the info in fstab but not inport it with niload it will not work. You need to both have a valid /etc/fstab and import it in order for this to work.

xml sitemap for pligg update v0.6

Update: There is be a new version of this module. Click here to get it.

Last year I have released a pligg module that creates XML sitemaps for better SEO. The module was tested and working on pligg 0.9.7. Since that time pligg was updated two times and is now at 0.9.9.

In pligg 0.9.8 they removed the clear_cache function that the my module's install code was using to clear the configuration cache. Because of this it was impossible to install the module.

The quick fix was just to edit xml_sitemaps_install.php and remove a line (#5) that called clear_cache() and then you could install it without any problems. This workaround was already known and discussed in the comments
Someone in the pligg community released a new version of this module that is basically just my module with that clear_cache function call removed and another 1 bug that was also discussed in the comments and was easy to fix. They bumped the version number to 0.5 which in my opinion was really not necessary since it was such a small fix.
They have also added a .htaccess file to the archive, again not necessary since my initial post already had the details ( .htaccess code ) about how to set it up and the module was also showing that in the configuration section.
One other thing I didn't like about their release was that they didn't make the module available for download without having to register on their forum.

So here I release a new version ( 0.6 ) of this module with more bugs fixed and now the module will have a page of it's own so that it will be easier to track new versions .

What changed:

  • use safe category names
  • generate links according to URLMethod configuration
  • modified use of date() function to work on php4

This module was tested on pligg 0.9.9.

Go to xml sitemap pligg module page for download

change hostname on MacOSX

here's a quick tip about how you can change the hostname on your MacOSX and keep it changed after a reboot:

  1.  

Of course you have to type that as root.

It seems there is also possible to set in it /etc/hostconfig but that file on it's own will not work. You have to load it in netinfo somehow but I don't know how to do that.

I think I like the /etc/hostconfig approach more then the scutil (even if it has to be loaded in netinfo ) because it's somehow closer to how most unix/linux systems do it.
Anyone knows how this can be done ?

Permissions on HFS+ volumes

This post will show you how to enable or disable permissions on a HFS+ volume and also how to check if a volume had the permissions enabled or not.

By default when you create a HFS+ filesystem it will have the permissions/owners disabled. I'm using a macmini for backing up files from a linux system and if I want the backup to be fully consistent with the source I need filesystem permissions.

Another problem is that using rsync between a permission based and a non permission based filesystem is useless because all files will always be out of sync.

Check permissions

  1.  

it will "Permissions on '/Volumes/YourVolume' are enabled ( or disabled ) of just "No entry found for '/Volumes/YourVolume'" which means the permissions are disabled.

Enable Permissions

  1.  

Disable Permissions

Since permissions are disabled by default I don't see many wanting to disable permissions but here's how you can do it anyway:

  1.  

I guess this is really useful only when you want to distribute a dmg image which currently has permissions enabled.
Distributing images with permissions enabled doesn't make much sense because the user that will open the image may have a different id then the user id that owns the files in the image so he may not be able to access the files inside the image.

How to create a dmg image

In a previous post I showed you how to mount a .dmg image from the command line.

Have you ever wondered how you can create such an image? Continue reading if you want to know.

Let's assume you want to create an image with a size of 10Mb that is formatted with a case sensitive HFS+ filesystem, with a Volume name Test stored in a file with the name Test.dmg.
Here is the command line you have to type in the shell:

  1.  

If you want to put files on it you have to attach it first:

  1.  

Or you could just add -attach to the list of parameters of the hdiutil command and it will also attach it after it creates it:

  1.  

Now you can copy your files to /Volumes/Test and when you're done you can detach the image in case you want to transfer/copy/move it:

  1.  

If you want a quick way to create an image from the contents of a folder you can use something like this:

  1.  

With that you can also specify a format for the image like compressed or read-only images.
Note that in this case I have not used that -size specifier anymore because the image will be as large as the contents of the source folder.

hdutil create --help for more details about image formats encryption and other goodies 🙂

Webmin pptp user synchronization

Webmin has this great feature that it can add users in several modules when a system user is added ( of course only when added from webmin ).

This feature can really be useful if you want for example to automatically add a system user to samba, mysql or other modules.

In order for this to work each modules that wants such a synchronization had to implement some standard functions and put them in a special file inside their module directory. Then when a system user is added, removed or updated the Useradmin module will look for a file named useradmin_update.pl in all modules installed in webmin. When it finds the file it will execute a function in the useradmin_update.pl corresponding to the action in useradmin module.

The pptp-server is a webmin module that is used for administrating a Point to Point Tunneling Protocol server , an easy way for creating VPNs to be used by windows or Linux machines. What I wanted was that when I added a system user webmin would also create a samba user and a pptp user so that the user could access the files over ftp or samba but over a more secure link so I wrote an useradmin_update.pl script for pptp

How to set it up?

get the script: useradmin_update.pl and place it into you pptp-server module folder on gentoo this is /usr/libexec/webmin/pptp-server a simple locate pptp-server should show you where it is.

Make sure you chmod 755 useradmin_update.pl

add the following lines to config.info in pptp-server :

sync_add=Add a pptp vpn server user when a Unix user is added,1,1-Yes,0-No
sync_change=Change the pptp vpn server user when a Unix user is changed,1,1-Yes,0-No
sync_delete=Delete the pptp vpn server user when a Unix user is deleted,1,1-Yes,0-No

remove the module.infos.cache file ( usually /etc/webmin/module.infos.cache ) and then restart webmin.
Now login to webmin as admin or root and go to Networking -> PPTP VPN Server -> Module config and check those 3 sync options .

To test it add a user using the webmin-> System -> Users and Groups admin then go to Webmin -> Networking -> PPTP VPN Server -> PPP Accounts and you should see the user there.

Proftpd: listen on single ip

I don't use ftp, I always use sftp/scp/rsync over ssh or even a fuse remote filesystem for transferring files but wordpress 2.5 comes with this nice feature to upgrade plugins automatically from the web admin interface that needs ftp.

the problem is I don't want to enable the ftp service and make it available to the rest of the world just for that.

So what are my options?

  1. I know I could just add a firewall rule and just not allow anyone else except for localhost to connect
  2. set proftpd to listent only on localhost ( 127.0.0.1)

The #1 depends on what firewall you have so I'm not going to discuss it here. You also may not want to do that because of some other reasons you might have.

#2 needs the following two options in proftpd.conf:

DefaultAddress 127.0.0.1
SocketBindTight                 on

Now restart proftpd and you're done.

MacOSX: adduser

I really needed an adduser like program on MacOSX  and after a few searches on the internet I found a script that works like the linux adduser program.

I remember I had to modify it to use bash ( my preferred shell ) as the default shell and I make it use the right path when copying the user template. I can't remember exactly where I found it so if you have seen this someplace else feel free to let me know and I'll be happy to give credit.

Here it is :

  1.  

Upgraded wordpress to 2.5

I have finally upgraded wordpress to 2.5.

The old version was 2.3.1 ( yeah that old ) and the upgrade was pretty smooth.  I didn't use plugins like instant upgrade for this upgrade but I'm thinking of using for the next upgrades.

How did I do it?

I have my own method for this. It's very similar to what they descibe in the official upgrade docs but a bit modified.

Here are the 7 steps I followed:

  1. backup the database using the backup plugin
  2. remember ( write a list of) active plugins then deactivate all ( so if any plugin will not work in the new version you can still access the blog and the admin interface )
  3. make a backup of all files ( assuming current install is in public_html ):
    1.  
  4. download and extract the new version ( it will create a wordpress folder so make sure you don't already have one cause it will overwrite the files in it ) :
    1.  
  5. use rsync to copy the new files over the old files ( note the exclusion of wp-content to preserve the modifications you might have done to themes and plugins ) :
    1.  
  6. call the upgrade.php script, go to : http://your_own_blog.tld/upgrade.php
  7. reactivate the plugins you had active before the upgrade

The whole thing took about 10 minutes and there were no problems encountered except for a few plugins that could not be reactivated because they were incompatible with the new version.

What I like about it?

I like the new interface,it seems friendlier, faster, more slick and  I was getting  bored of the old one.

I don't care much about the dashboard, but I love the way the WYSIWYG editor works.

I think the feature that I love the most is the automatic plugin upgrade but this is also the one that I think it needs more work ( of course there may be others that I did not notice yet )

what id didn't like?

Here are three problems I found with the automatic plugin upgrade:

  1. the first time I tired it id didn't seem to care that I selected "No" for the "Use SSL" option and it just told me it could not connect.
    This was because my ftp server did not have ssl enabled but it was impossible to know this was the cause because it was clear to me from the web interface that it was not using SSL until I went in the code and just run a print_r on the $credentials variable .
    I'm not sure why this happened, I guess a bug. I had to go into the database and manually edit the ftp_credentials option and set ssl to 0 and then the plugin upgrade worked.
  2. It doesn't remember the value of the "Use SSL" option. After I go in to upgrade another plugin the option is set to "yes" even thou in the database it is 0.
  3. it removes the old plugin first and then tries to install the other. If the new version install doesn't work for some reason you are left with no plugin and you will have to go in and install manually the old way. I think a bettwe approach would be to first deactivate the old plugin, make a backup copy, try to install the new one and if it doesn't work restore the old plugin.

Conclusions

Overall wp 2.5 brings good improvements and great new features but as with any new major version increase there are a few minor details not taken good care of. Waiting to see what the 2.5.1 version wil bring on he bug fixing side.

Have you upgraded yet?  what are your thoughts on the 2.5 version ?

Firefox 3 beta 5 released

Mozilla released the 5'th beta of the Firefox 3 browser a few hours ago.

The new beta brings enhancements in the bookmark organizer, operating system integration and most important to me the speed in the javascript engine that so many sites depends on these days.

There are just 750 improvements since the last beta version, 250 fewer then the number of improvements between beta 3 and beta 4.

I think this will probably be  the last beta version before a release candidate even thou the "known issues" list is a bit larger then the one of the previous beta.

Here are the release notes and here is the download page for those of you that want to give it a try.