Example Scripts for sending to Landscape clients

Initiate an SSH tunnel

You will need SSH key authentication between your client machine, and the remote machine you have access to in order for this to work.

ssh -R 2048:localhost:22 hostname.of.server

This creates a reverse tunnel on hostname.of.server at port 2048 which will tunnel back to the Landscape client machine.

To ssh in, you just need to be on hostname.of.server and use ssh -p 2048 localhost

Startup script to install Wordpress

This script can be used as a Cloud Instance startup script, i.e., use it in the page where you create new Cloud instances. It will install and configure a Wordpress blog at server.example.com/blog, where server.example.com is the hostname of the cloud instance where the script is being run.

Remember that you need to open the web port (80/tcp) to be able to access the Wordpress installation after it finishes. You may want to restrict the access to it, because the default installation will create an admin account on the first access it gets.

Here is the script:

export DEBIAN_FRONTEND="noninteractive"

function metadata_get() {
    echo "Obtaining metadata $1" >&2
    if [ "$?" -ne "0" ]; then
        echo "ERROR obtaining metadata $1"
        exit 1
    return 0

# wait for another possible update to be completed
while [ `ps -ef | grep /usr/share/smart/smart | grep -cv grep` -gt 0 ]; do 
  echo -n "."
  sleep 3

mkdir -p -m 0700 /root/.gnupg

$SMART update; RESULT=$?
# wait until it works
while [ $RESULT -eq 1 ]; do
  sleep 5; echo -n "*"
  $SMART update; RESULT=$?

$SMART install --yes wordpress mysql-server apache2-mpm-prefork php5 php5-mysql libapache2-mod-php5 curl

fqdn=$(metadata_get public-hostname)
echo "Got hostname=$fqdn"
cat > /etc/apache2/conf.d/wordpress <<EOF
Alias /blog /usr/share/wordpress
<Directory /usr/share/wordpress>
        Options FollowSymLinks
        AllowOverride Limit Options FileInfo
        DirectoryIndex index.php

/etc/init.d/mysql restart

bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress $fqdn

/etc/init.d/apache2 restart

Display a note in the desktop

The script below works on Ubuntu Desktop installations and can be used to display a note to the user. Just remember to run it as the same user as the one who is currently logged in on that desktop.

export DISPLAY=:0 
# display note for 30s
notify-send -t 30000 "Hello from the Landscape Webinar"

RunningScripts/ExampleScripts (last edited 2010-06-07 22:38:55 by ahasenack)