Sha256: aa132c4fe6f0f7f47dabe8dc5cc0c7f668815bcd2359d1e010cfff11b9e1b362

Contents?: true

Size: 1.38 KB

Versions: 36

Compression:

Stored size: 1.38 KB

Contents

#!/bin/bash

DefaultPort=1314

# verify the arguments
if [[ "$1" == "" ]] || [[ "$2" == "" ]]; then
	echo "Usage: install_module <address> [port] <module-name> ..."
	exit 1
fi

# set the agent's address
address=$1
shift

# set the agent's port number
re='^[0-9]+$'
if [[ $1 =~ $re ]]; then
	port=$1
	shift
else
	port=$DefaultPort
fi

# set a template command for sending the modules
cmd="curl -s -i -X PUT $address:$port/modules"

# setup directory for temporary files
dir="/tmp/"$(date +%s%N)"$RANDOM"
mkdir -p $dir

# for every module in the arguments:
# - archive the module's files to a temporary file
# - update the sending command by adding the module
# if the module is not exist then the program will
# set missing_module flag and then break from the loop
missing_module=0
for module in "$@" ; do
	if [[ -d "$module" ]]; then
		tar cvzhf $dir/$module.tgz $module 1>/dev/null
		cmd="$cmd -F $module=@$dir/$module.tgz"
	else
		echo "Module $module is not exist!"
		missing_module=`expr $missing_module + 1`
	fi
done

if [[ $missing_module == 0 ]]; then
	# execute the sending command there is no missing module
	result=`$cmd`
	re='.*HTTP/1\.1 200 OK.*'
	if ! [[ $result =~ $re ]]; then
		missing_module=`expr $missing_module + 1`
	fi
fi

# delete directory that holds temporary files
rm -rf $dir

if [[ $missing_module == 0 ]]; then
	echo "status: ok"
else
	echo "status: failed"
fi

exit $missing_module

Version data entries

36 entries across 35 versions & 2 rubygems

Version Path
sfpagent-0.4.15 bin/install_module
sfpagent-0.4.14 bin/install_module
sfpagent-0.4.13 bin/install_module
sfpagent-0.4.12 bin/install_module
sfpagent-0.4.11 bin/install_module
sfpagent-0.4.10 bin/install_module
sfpagent-0.4.9 bin/install_module
sfpagent-0.4.8 bin/install_module
sfpagent-0.4.7 bin/install_module
sfpagent-0.4.6 bin/install_module
sfpagent-0.4.5 bin/install_module
sfpagent-0.4.4 bin/install_module
sfpagent-0.4.3 bin/install_module
sfpagent-0.4.2 bin/install_module
sfpagent-0.4.1 bin/install_module
sfpagent-0.4.0 bin/install_module
sfpagent-0.3.10 bin/install_module
nuri-0.5.1 modules/install_module
nuri-0.5.1 bin/install_module
sfpagent-0.3.9 bin/install_module