#!/bin/bash

MODULE=$1

if [[ ! -z $MODULE ]]; then
	URL="http://setup.2x.mikbill.pro/selinux/roles/selinux/files/$MODULE.pp";
	WGET=$(which wget)
	SEMODULE=$(which semodule)

	$WGET -O $MODULE.pp -q --no-check-certificate $URL
	if [ $? -ne 0 ]; then
        	if [ -f $MODULE.pp ]; then
            		rm -f $MODULE.pp
        	fi

        	echo "Download  FAILED! please check DNS and connection to $URL"
	else
		$SEMODULE -r $MODULE > /dev/null
		$SEMODULE -i $MODULE.pp
		echo "done!"
    	fi
else
	echo "useage: ./update_module.sh MODULE_NAME"
fi
