ganglia-web/0001-added-of-download_js.patch
Christian Goll 76b4ba8715 Accepting request 755206 from home:mslacken:branches:network:cluster
- updated to version 3.7.4  
- added patches for a global user config under /etc/ganglia/conf.d/ 
  and added download_js.sh which can download the external java 
  script libararies.
  * new file: 0001-added-of-download_js.patch which adds download_js.sh
  * new file: 0002-looking-for-systemwide-user-config.patch which 
    makes ganglia-web to serach for config in /etc/ganglia/conf.d/

OBS-URL: https://build.opensuse.org/request/show/755206
OBS-URL: https://build.opensuse.org/package/show/network:cluster/ganglia-web?expand=0&rev=16
2019-12-10 15:58:59 +00:00

146 lines
3.3 KiB
Diff

From 3d5c9c2e308123a9d37e7cbab33b854a304bb381 Mon Sep 17 00:00:00 2001
From: Christian Goll <cgoll@suse.de>
Date: Fri, 6 Dec 2019 16:42:28 +0100
Subject: [PATCH 1/2] added of download_js
---
download_js.sh | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 126 insertions(+)
create mode 100755 download_js.sh
diff --git a/download_js.sh b/download_js.sh
new file mode 100755
index 0000000..67e26fd
--- /dev/null
+++ b/download_js.sh
@@ -0,0 +1,126 @@
+#!/bin/bash
+CONFFILE="/srv/www/htdocs/ganglia-web/conf_default.php"
+SAVEDIR='/srv/www/htdocs/ganglia-web'
+PHPCONFDIR='/etc/apache2/conf.d/'
+PHPCONFNAME='conf.php'
+TARBALL='/tmp/ajax_ganglia.tar.gz'
+RESCRIPT='/tmp/download_js.sh'
+SUFFIX='ajax_libs'
+TMPDIR='/tmp'
+
+function get_conf() {
+declare -f -F conf_stor > /dev/null
+if [ $? -eq 0 ] ; then
+ conf_stor
+else
+ cat ${CONFFILE}
+fi
+}
+
+function usage() {
+cat <<EOF
+ $0 parses ${CONFFILE}
+ for external java script libraries and downloads or recreate the script
+ so that it can download them on another computer.
+ Options are:
+ -h: prints this help
+ -d: download the libraries to
+ $SAVEDIR
+ and modify/write
+ ${PHPCONFDIR}/${PHPCONFNAME}
+ so that downloaded libraries are preferred
+ -t: download the libraries and store them in
+ $TARBALL
+ -r: recreate this script by parsing
+ $CONFFILE
+ and store the download locations of the java script libraries
+ direclty in the recreated script, which
+ will stored in
+ $RESCRIPT
+EOF
+}
+tarball=0
+recreate=0
+download_libs=0
+usage_set=1
+
+while getopts "h?trd" opt; do
+ case "$opt" in
+ h|\?)
+ usage_set=1
+ ;;
+ t)
+ usage_set=0
+ tarball=1
+ recreate=0
+ ;;
+ r)
+ usage_set=0
+ recreate=1
+ ;;
+ d)
+ usage_set=0
+ download_libs=1
+ recreate=0
+ ;;
+ esac
+done
+
+if [ $usage_set -eq 1 ] ; then
+ usage
+ exit 0
+fi
+
+if [ $recreate -eq 1 ] ; then
+ declare -f -F conf_stor > /dev/null
+ if [ $? -eq 0 ] ; then
+ echo "This script was recreated so could not recreate it."
+ exit 1
+ fi
+ cat << EOF > $RESCRIPT
+#!/bin/bash
+# this file was recreated on $(uname -n) at $(date)
+function conf_stor() {
+cat <<ENDCONF
+EOF
+ grep 'https://cdnjs' $CONFFILE | sed 's@\$@\\\$@' >> $RESCRIPT
+ cat << EOF >> $RESCRIPT
+
+ENDCONF
+}
+EOF
+ cat $0 | sed -e 's@#!/bin/bash@@' \
+ -e 's@usage_set=1@usage_set=0@' \
+ -e 's@tarball=0@tarball=1@' >> $RESCRIPT
+ echo "wrote $RESCRIPT"
+ exit 0
+fi
+
+
+which curl &> /dev/null || echo "need curl to download ajax libraries"
+which curl &> /dev/null || exit 1
+
+if [ $tarball -eq 1 ] ; then
+ test -d ${TMPDIR}/${SUFFIX} || mkdir -vp ${TMPDIR}/${SUFFIX}
+ PHPCONFFILELOC=${TMPDIR}/${SUFFIX}/${PHPCONFNAME}
+ cd ${TMPDIR}
+else
+ test -d ${SAVEDIR}/${SUFFIX} || mkdir -vp ${SAVEDIR}/${SUFFIX}
+ PHPCONFFILELOC=${PHPCONFDIR}/${PHPCONFNAME}
+ cd ${SAVEDIR}
+fi
+
+for lib_line in $(get_conf | grep -e '^$conf.* = \"https://cdnjs' | tr ' ' '@') ; do
+ conf_line=$(echo $lib_line | cut -f 1 -d '@')
+ url=$(echo $lib_line | cut -f 3 -d '@' |tr -d '"' | tr -d ';')
+ file_name=$(basename $url)
+ echo -n "getting ${file_name}: "
+ curl -# $url -o ${SUFFIX}/$file_name
+ echo "$conf_line = \"${SAVEDIR}/${SUFFIX}/${file_name}\";" >> ${PHPCONFFILELOC}
+done
+if [ $tarball -eq 1 ] ; then
+ tar czf ${TARBALL} ${SUFFIX}
+ echo "created ${TARBALL} , which also contains ${PHPCONFNAME}"
+fi
+cd - > /dev/null
+
--
2.16.4