#!/bin/sh

po_domain="alterator-alterator-asterisk-limits"
alterator_api_version=1

. alterator-sh-functions

on_message() {
  . /etc/sysconfig/asterisk
  case "$in_action" in
    read) 
		write_string_param max_files 	$MAX_FILES
		write_string_param max_threads	$MAX_THREADS
		write_bool_param dump_core  	$DUMP_CORE
		;; #insert your code for read action here
    write) 
		if [ "$in_dump_core" = "#t" ]; then
			DUMP_CORE=yes
		else
			DUMP_CORE=no
		fi
cat > /etc/sysconfig/asterisk << __EOF__
# dump core if asterisk crashes
DUMP_CORE=$DUMP_CORE

# one call is at least 2-4 file descriptors
MAX_FILES=$in_max_files

# one call == one thread, and Asterisk needs some additional
# threads
MAX_THREADS=$in_max_threads
__EOF__
	
		;; #insert your code for write action here

	type)
		write_type_item max_files   uint
		write_type_item max_threads uint
		;;
    list)  ;; #insert your code for list action here
  esac
}

message_loop
