From eda28f4efd0fe56820925fb4c58661516349b767 Mon Sep 17 00:00:00 2001 From: Mafoo Date: Thu, 29 Sep 2016 17:57:50 +0100 Subject: [PATCH] Added Branch support (#44) moved command line argument processing to a separate script so it can be shared added --use-system-master to allow user to use master branch instead of detected master --- debian/install.sh | 39 +----------------- debian/resources/arguments.sh | 46 ++++++++++++++++++++++ debian/resources/fusionpbx.sh | 20 +++++++++- debian/resources/switch/package-release.sh | 7 +++- 4 files changed, 70 insertions(+), 42 deletions(-) create mode 100755 debian/resources/arguments.sh diff --git a/debian/install.sh b/debian/install.sh index eefe033..abab579 100755 --- a/debian/install.sh +++ b/debian/install.sh @@ -3,44 +3,7 @@ #move to script directory so all relative paths work cd "$(dirname "$0")" -. resources/colors.sh - -#Process command line options -ARGS=$(getopt -n 'install.sh' -o h -l help,use-switch-source,use-switch-package-all,use-switch-master,use-switch-package-unofficial-arm,no-cpu-check -- "$@") - -if [ $? -ne 0 ]; then - error "Failed parsing options." - exit 1 -fi - -export USE_SWITCH_SOURCE=false -export USE_SWITCH_PACKAGE_ALL=false -export USE_SWITCH_PACKAGE_UNOFFICIAL_ARM=false -export USE_SWITCH_MASTER=false -export CPU_CHECK=true -HELP=false - -while true; do - case "$1" in - --use-switch-source ) export USE_SWITCH_SOURCE=true; shift ;; - --use-switch-package-all ) export USE_SWITCH_PACKAGE_ALL=true; shift ;; - --use-switch-master ) export USE_SWITCH_MASTER=true; shift ;; - --no-cpu-check ) export CPU_CHECK=false; shift ;; - -h | --help ) HELP=true; shift ;; - -- ) shift; break ;; - * ) break ;; - esac -done - -if [ $HELP = true ]; then - warning "Debian installer script" - warning " --use-switch-source will use freeswitch from source rather than ${green}(default:packages)" - warning " --use-switch-package-all if using packages use the meta-all package" - warning " --use-switch-package-unofficial-arm if your system is arm and you are using packages, use the unofficial arm repo" - warning " --use-switch-master will use master branch/packages instead of ${green}(default:stable)" - warning " --no-cpu-check disable the cpu check ${green}(default:check)" - exit; -fi +. resources/arguments.sh if [ $CPU_CHECK = true ] && [ $USE_SWITCH_SOURCE = false ]; then #check what the CPU and OS are diff --git a/debian/resources/arguments.sh b/debian/resources/arguments.sh new file mode 100755 index 0000000..4caeb95 --- /dev/null +++ b/debian/resources/arguments.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +. ./colors.sh + +#Process command line options only if we haven't been processed once +if [ -z "$CPU_CHECK" ]; then + export script_name=`basename "$0"` + ARGS=$(getopt -n '$script_name' -o h -l help,use-switch-source,use-switch-package-all,use-switch-master,use-switch-package-unofficial-arm,use-system-master,no-cpu-check -- "$@") + + if [ $? -ne 0 ]; then + error "Failed parsing options." + exit 1 + fi + + export USE_SWITCH_SOURCE=false + export USE_SWITCH_PACKAGE_ALL=false + export USE_SWITCH_PACKAGE_UNOFFICIAL_ARM=false + export USE_SWITCH_MASTER=false + export USE_SYSTEM_MASTER=false + export CPU_CHECK=true + HELP=false + + while true; do + case "$1" in + --use-switch-source ) export USE_SWITCH_SOURCE=true; shift ;; + --use-switch-package-all ) export USE_SWITCH_PACKAGE_ALL=true; shift ;; + --use-switch-master ) export USE_SWITCH_MASTER=true; shift ;; + --use-system-master ) export USE_SYSTEM_MASTER=true; shift ;; + --no-cpu-check ) export CPU_CHECK=false; shift ;; + -h | --help ) HELP=true; shift ;; + -- ) shift; break ;; + * ) break ;; + esac + done + + if [ $HELP = true ]; then + warning "Debian installer script" + warning " --use-switch-source will use freeswitch from source rather than ${green}(default:packages)" + warning " --use-switch-package-all if using packages use the meta-all package" + warning " --use-switch-package-unofficial-arm if your system is arm and you are using packages, use the unofficial arm repo" + warning " --use-switch-master will use master branch/packages for the switch instead of ${green}(default:stable)" + warning " --use-system-master will use master branch/packages for the system instead of ${green}(default:stable)" + warning " --no-cpu-check disable the cpu check ${green}(default:check)" + exit; + fi +fi \ No newline at end of file diff --git a/debian/resources/fusionpbx.sh b/debian/resources/fusionpbx.sh index 9a73aa3..df731ff 100755 --- a/debian/resources/fusionpbx.sh +++ b/debian/resources/fusionpbx.sh @@ -1,13 +1,29 @@ #!/bin/sh +#move to script directory so all relative paths work +cd "$(dirname "$0")" + +. ./arguments.sh + #send a message -echo "Install FusionPBX" +verbose "Installing FusionPBX" #install dependencies apt-get install -y --force-yes vim git dbus haveged ssl-cert apt-get install -y --force-yes ghostscript libtiff5-dev libtiff-tools +if [ $USE_SYSTEM_MASTER = false ]; then + FUSION_MAJOR=$(git ls-remote --heads https://github.com/fusionpbx/fusionpbx.git | cut -d/ -f 3 | grep -P '^\d+\.\d+' | sort | tail -n 1 | cut -d. -f1) + FUSION_MINOR=$(git ls-remote --tags https://github.com/fusionpbx/fusionpbx.git $FUSION_MAJOR.* | cut -d/ -f3 | grep -P '^\d+\.\d+' | sort | tail -n 1 | cut -d. -f2) + FUSION_VERSION=$FUSION_MAJOR.$FUSION_MINOR + verbose "Using version $FUSION_VERSION" + BRANCH="-b $FUSION_VERSION" +else + verbose "Using master" + BRANCH="" +fi + #get the source code -git clone https://github.com/fusionpbx/fusionpbx.git /var/www/fusionpbx +git clone $BRANCH https://github.com/fusionpbx/fusionpbx.git /var/www/fusionpbx chown -R www-data:www-data /var/www/fusionpbx chmod -R 755 /var/www/fusionpbx/secure diff --git a/debian/resources/switch/package-release.sh b/debian/resources/switch/package-release.sh index 2e056da..18bd3b0 100755 --- a/debian/resources/switch/package-release.sh +++ b/debian/resources/switch/package-release.sh @@ -1,6 +1,9 @@ #!/bin/sh -#initialize variable encase we are called directly -[ -z $USE_SWITCH_PACKAGE_UNOFFICIAL_ARM ] && USE_SWITCH_PACKAGE_UNOFFICIAL_ARM=false + +#move to script directory so all relative paths work +cd "$(dirname "$0")" + +. ./arguments.sh apt-get update && apt-get install -y --force-yes curl memcached haveged arch=$(uname -m)