apache

Bash - Get Name of Parent Directory

  • Posted on: 2 March 2016
  • By: davis

For the path /foo/bar/, if the current directory is bar, and we want to get the name of the parent directory (i.e. foo)

path="$( cd "$( dirname $0 )" && cd -P "$( dirname "$SOURCE" )" && pwd )"
parentName=$(basename -- "$(dirname -- "$path")")
echo $parentName # will return parent directory's name

This resolves symbolic links (sidestepping the error where it returns "." for the parent dir). Give it a try.

Alternative to Cron for NearlyFreeSpeech Users

  • Posted on: 16 February 2016
  • By: davis

I use the server host NearlyFreeSpeech for all of my personal website-related things nowadays. They are extremely cheap, and their community-driven support is great.

Unfortunately, they don't have crontab enabled. Here's a workaround for enabling cron-like functionality on a NearlyFreeSpeech hosting instance.

In my case, I needed to curl multiple public-facing URL's in order to refresh some vital information. I wanted to do that on a schedule.

Clean URLs On Drupal and NearlyFreeSpeech

  • Posted on: 20 July 2015
  • By: davis

Finally got this working. I couldn't enable clean URLs on NearlyFreeSpeech's hosting. If you're like me and can't go anywhere in your Drupal installation but your homepage, read on.

Here's what you need to do:

In your Drupal site root, you're going to need to download and edit the .htaccess file. Open it with Notepad++

Comment out the Order Directive using the "#" symbol

Switching From Rackspace to NearlyFreeSpeech

  • Posted on: 13 July 2015
  • By: davis

I had some growing pains switching from Rackspace to NearlyFreeSpeech today. I needed to port four Wordpress sites and a Drupal installation. I encountered quite a few stumbling blocks along the way, mostly due to the way NearlyFreeSpeech configures their permissions.

To get new Wordpress installations working on NearlyFreeSpeech:

SSH into your server with Putty. You will be dropped in /home/public by default. Wordpress files need to belong to the "web" group. Use the following commands