Skip to content. | Skip to navigation

Personal tools

Navigation

You are here: Home / Wiki / Servicesfaq

Servicesfaq

Services FAQ

Services FAQ

It can sometimes be tricky to get your command line scripts running on a node even if you have a well-formed RSpec. Below are some common problems and solutions:

How do I specify a command to run at startup on my node?

In the Flack client, you can click the blue 'i' button for information about a node and enter a command line on that form.

If you are constructing your own request from hand, see the example at RSpecRequestTarballExample.

When does my command run?

Your command runs after any tarball is installed at node start time. Commands are run in the order they are found in the RSpec.

How do I know that my command has actually run? How do I see the output of my command?

To see the output of your command and verify that it was actually run, you must first log into a node in your sliver. The log is lost when your sliver is deleted.

After logging into your sliver, there are two possible locations for the log file. If your sliver (node) is an OpenVZ container, then:

cat /var/emulab/logs/runlog*

For other sliver types, you can run the following command to list all of the runlogs for your sliver at the current ComponentManager:

ls /proj/GeniSlices/logs/runlog-`sed -r 's/.*(slice[0-9]+).*/\1/' /var/emulab/boot/nickname`*

There is one per node in your sliver. In order to view it, you will need to run less/cat/tail -f/etc. on:

/proj/GeniSlices/logs/<name-of-log-file>

I can't write a file/run a command/etc.

Startup commands are run using a user created specifically for the purpose. This means that there are many parts of the filesystem, including the home directory created for you by the CM, that they can't necessarily write to. Luckily, the special user created for you to run commands is a sudoer. This means that if you need to run superuser commands like tcpdump, you can use 'sudo' to run those commands.

sudo tcpdump -i eth0

If you want to change some bit of state in /dev (like ip forwarding), you need to make sure that any redirects also have root powers:

sudo sh -c 'echo 0 > /path/to/whatever'

And of course your whole startup command can be run as root if you like:

<execute shell="sh" command="sudo /local/myscript.sh"/>

If you don't want to run as root but instead want to run as your own user account you can still accomplish this with the power of sudo:

<execute shell="sh" command="sudo su youruser -c 'my-script.sh arg'"/>

How do I know which node I'm running on?

Sometimes it is important to a script to be able to discover which node it is running on. If it is a ProtoGENI Emulab node, this can be done by looking in the file:

/var/emulab/boot/nickname

It will look something like:

my-node.slice7400.GeniSlices

The part before the first dot (my-node in this case) is the client_id of the current node.

The second part of that triple can get you access to the local manifest for that CM. Here is a shell command which will show the manifest for a node:

less /proj/GeniSlices/exp/`sed -r 's/.*(slice[0-9]+).*/\1/' /var/emulab/boot/nickname`/tbdata/geni_manifest