#!/bin/sh

alterator_api_version=1

. alterator-sh-functions

on_message()
{
	case "$in_action" in
		execute)
		    [ -n "$in_wd" ] || in_wd="/root"

		    # Set language
		    [ -n "$in_language" ] && export LANG="${in_language%%;*}.UTF-8"

		    # Reset TERM environment variable to prevent run of interactive program
		    export TERM=

		    # Execute command
		    [ -n "$in_command" ] && in_command="$(cd "$in_wd" 2>&1; $in_command 2>&1;wd=`pwd`)"

		    # Return result of chane directory and execute command
		    write_string_param wd "$in_wd"
		    write_string_param output "$wd$in_command"
   		    
   		    # Clean command line
   		    write_string_param command ""
		    ;;
	esac
}

message_loop
