#!/bin/bash

# Copyright (C) 2015-2018, Ward Mundy & Associates LLC. Licensed for use under GPL2.

# Use this little script to convert Contributor-produced GPL modules from GitHub for examination

# You can perform an install or update in one easy step using gpl-install-contrib script instead.

if [ -z "$1" ]; then
 clear
 echo "Usage instructions:"
 echo "ERROR: Name of Contributor-producted GPL module is required."
 echo "SYNTAX: ./gpl-download-contrib packagename"
 echo " "
 exit 1
fi


cd /root
rm -rf $1.tar.gz
rm -rf $1
mkdir $1
cd $1
curl -L -O https://github.com/FreePBX-ContributedModules/$1/archive/release/13.0.zip
unzip 13.0.zip
clear
rm -f *.zip && mv $1-release-13.0 $1
# fake the module signature
cd $1
touch module.sig
chmod 775 module.sig
cd ..
#
tar -cf $1.tar $1 && gzip $1.tar && rm -rf $1
mv $1.tar.gz ../. && cd .. && rm -rf $1
ls $1.tar.gz

# Now we're ready to switch to the Module Admin utility in the GUI to install the GitHub update
