1. Download Terragen package from terragen site and unzip it
unzip terragen-package.zip
Remember to copy and paste license file to folder with Terragen
2. Install required packages:
sudo apt-get update && sudo apt-get install freeglut3 && sudo apt-get install libjpeg62
3. Export terragen path
export TERRAGEN_PATH=~/
4.To open and render project.tgd and save result as test.tif file and exit terragen:
./terragen -p project.tgd -exit -r -o test.tif
5. I connect to my headless machine remotely, so I always run project within
screen:
If you don't have screen install it by typing:
sudo apt-get install screen
So let's start new screen session:
screen -S mysession
6. If you want to shutdown your machine after work has been finished simply create script:
logfile="/var/log/terragen.log"
! /bin/bash
case "$(pidof terragen | wc -w)" in
0) echo "Terragen not running, shutting down HP Workstation: $(date)" >> $logfile
/usr/bin/wget http://my-domain.com/terragen/stop.php
rm terragen-stop.php
sudo init 0
;;
1) echo "Terragen is running, all OK: $(date)" >> $logfile
echo "Terragen is running OK"
;;
esac
I used second line of zero status for sending me email with date about status so I know that it has been finished.
7. I like to pipe output from terragen to log file, so I always run project like this:
Create screen session named 'mysession':
screen -S mysession
Run terragen project with output to log file:
./terragen -p project.tgd -exit -r -o test.tif > terragen.log
Leave screen session:
Ctrl + a and ctr + d
And now you can exit terminal and process is still running on rendering machine.
If you want go back to session just, when you login again:
screen -D -r 'mysession'
This is very usefull because it helps me to view logs and rendering progress without logging to my machine, which is usually very overloaded.
I have my Terragen rendering machine in my room, and I don't have access to it from outside so I send my logs to another machine which is hosting my web page. If you don't have any server from where you can send emails or host your logs you can obtain very cheap VPS for 4-5$ per month or even less (BudgetVM should be fine).
Let's start on your rendering machine:
- create script which will be invoked every 3 minutes
sudo nano terragen-status.sh
Copy and paste this, and modify it to your needs:
#! /bin/bash
scp -P 6172 /home/user/Terragen/terragen.log root@my-remote-machine-address:/var/www/my-domain.com/terragen/
Save file and add privileges to file:
sudo chmod a+x terragen-status.sh
To make it works you would need to exchange ssh keys with the remote machine you're going to send your logs - this is a machine where you'll will be able to preview your logs for instance using your smartphone while walking with your dog.
You can exchange ssh keys by simply running:
ssh-keygen
Press enter after every prompt. Next you will have to send it to remote machine:
ssh-copy-id -i ~/.ssh/id_rsa.pub root@my-domain-ip -p 22
And starting from now your rendering machine will have free access to machine which we will use to display logs.
To invoke script every 3 minutes you need to create new cron operation:
crontab -e
And copy & paste this:
*/3 * * * * /home/user/scripts/terragen-status.sh > /dev/null 2>&1
Save and exit.
And You need to place some php file on you machine where you will read logs - I reversed log lines so latest operations are always at beginning.
So within your /var/www/my-domain.com/terragen/ directory on remote machine create index.php file with content:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HDRI environment maps and hdri skies</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=3.0, user-scalable=yes"/>
<meta name="HandheldFriendly" content="true" />
<meta name="apple-touch-fullscreen" content="YES" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="NOINDEX,NOFOLLOW" />
<title>Terragen rendering status check</title>
<style type="text/css">
body {background:#222;color:#666;}
</style>
</head>
<body>
<?php
$file = 'terragen.log';
if(file_exists($file))
{
$lines = file($file);
$lines = array_reverse($lines);
foreach($lines as $line)
{
echo $line . '<br />';
}
} else {
print_r('<h2 style="color:red">No log file found !</h2>');
}
?>
</body>
</html>
That should be all.
Learn more at
http://planetside.co.uk/wiki/index.php?title=Linux_Command_Line_Reference