Drobo

Creating simple services.sh

This question is so simple, I’m almost embarrassed to ask. After installing a few DroboApps, I noticed that they don’t always install binaries in places where the PATH environment variable can find them (for instance, apachectl is not accessible by default). I decided to create a drop-dead simple “App” called “bin” - and all it does is add its own directory to the PATH. That way I have a home for binaries and other things without polluting the root filesystem. Simple, right?

Sadly, the service doesn’t seem to work (I based it on the simple Dropbear service). OpenSSH handles this perfectly (thanks Ricardo!), so I know it’s perfectly doable. If I export the variable manually it works like a charm, so it seems something is just wrong with this file.

By the way, if there is a “Right Way” to do this that I’m missing, by all means correct me.

[code]#!/bin/sh

Set up personal customizations

. /etc/service.subr

prog_dir=dirname \realpath $0``

name=“bin” # service name
version=“0.1” # program version

start()
{
export PATH=$PATH:${prog_dir}
}

case “$1” in
start)
start_service
;;
stop)
stop_service
;;
restart)
stop_service
sleep 3
start_service
;;
status)
status
;;
*)
echo “Usage: $0 [start|stop|restart|status]”
exit 1
;;
esac[/code]

Thanks for the compliments, but I was just lucky. OpenSSH automatically fixes the path for incoming sessions, so it is not my doing.

The problem, you see, is that although you ‘fixed’ the path this change does not carry to your SSH sessions because they live under different contexts.

In other words: there is one process in your Drobo that has this path you created - the process that started all DroboApps. However, the processes that are created by OpenSSH are not the same, and only inherit the path that was set when OpenSSH was started.

The proper way of defining the path is to do it in the user’s shell configuration files (e.g.: ~/.bashrc). However, this is not really easy to do on the FS since, as we well know, user management is messed up.

That’s how I do it on my Mac, of course, but I wasn’t sure a bashrc would be used by busybox/ash. Kind of a shame my other solution didn’t work, as it would an an all-users instant/presto kind of thing.

Well, you could always symlink the programs you want in some folder that always is in the path, such as /usr/bin.

Not the prettiest solution, but it would work.

I’m trying to avoid touching anything on the root of the filesystem. /mnt/DroboFS is about as far as I want to go (and since it’s the root home directory, I don’t have any choice in the matter - or else I’d keep everything up on a share).

I finally determined that ash will support /etc/profile and ~/.profile. It’s just sitting at “/mnt/DroboFS/.profile”, but does the trick. Nice thing is if I ever do build bash, it will pick that up as well.