bkruse: branch group/new_exp r1810 - in /team/group/new_exp: ./ build_tools/ ...

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Mon Nov 19 14:18:33 CST 2007


Author: bkruse
Date: Mon Nov 19 14:18:33 2007
New Revision: 1810

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=1810
Log:
This is exciting.

Editing the makefile, added zapscan and ztscan
and made them install to a NON hardcoded directory
(as directed by the Makefile)

Also made astman.js do an "include" to astman_vars.js
which are dynamically generated from the Makefile.

2 big steps for making the GUI platform independent
and never a hassle :)


Added:
    team/group/new_exp/build_tools/
    team/group/new_exp/build_tools/make_astman_vars_js   (with props)
    team/group/new_exp/build_tools/make_defaults_h   (with props)
    team/group/new_exp/tools/
      - copied from r1807, branches/asterisknow/tools/
Modified:
    team/group/new_exp/Makefile
    team/group/new_exp/scripts/astman.js
    team/group/new_exp/todo.txt
    team/group/new_exp/tools/Makefile
    team/group/new_exp/tools/zapscan
    team/group/new_exp/tools/zapscan.c

Modified: team/group/new_exp/Makefile
URL: http://svn.digium.com/view/asterisk-gui/team/group/new_exp/Makefile?view=diff&rev=1810&r1=1809&r2=1810
==============================================================================
--- team/group/new_exp/Makefile (original)
+++ team/group/new_exp/Makefile Mon Nov 19 14:18:33 2007
@@ -148,10 +148,11 @@
 
 astman_vars.js: makeopts
 	@build_tools/make_astman_vars_js > $@.tmp
-	@if cmp -s $@.tmp config/scripts/$@ ; then : ; else \
-		mv $@.tmp config/scripts/$@ ; \
+	@if cmp -s $@.tmp scripts/$@ ; then : ; else \
+		mv $@.tmp scripts/$@ ; \
 	fi
 	@rm -f $@.tmp
+
 
 checkconfig:
 	@echo " --- Checking Asterisk configuration to see if it will support the GUI ---"
@@ -245,7 +246,9 @@
 	mkdir -p $(CONFIGDIR)/images
 	mkdir -p $(CONFIGDIR)/stylesheets
 	mkdir -p $(CONFIGDIR)/scripts
-	@for x in config/images/*; do \
+	@cat scripts/astman.js >> scripts/astman_vars.js
+	$(INSTALL) -m 644 scripts/astman_vars.js $(CONFIGDIR)/scripts/astman.hs
+	@for x in images/*; do \
 		echo "$$x  -->  $(CONFIGDIR)/images/" ; \
 		$(INSTALL) -m 644 $$x $(CONFIGDIR)/images/ ; \
 	done
@@ -253,11 +256,11 @@
 		echo "$$x  -->  $(CONFIGDIR)/scripts/" ; \
 		$(INSTALL) -m 644 $$x $(CONFIGDIR)/scripts/ ; \
 	done
-	@for x in config/stylesheets/*; do \
+	@for x in stylesheets/*; do \
 		echo "$$x  -->  $(CONFIGDIR)/stylesheets/" ; \
 		$(INSTALL) -m 644 $$x $(CONFIGDIR)/stylesheets/ ; \
 	done
-	@for x in config/*.html; do \
+	@for x in *.html; do \
 		echo "$$x  -->  $(CONFIGDIR)" ; \
 		$(INSTALL) -m 644 $$x $(CONFIGDIR)/ ; \
 	done
@@ -292,7 +295,6 @@
 
 clean: $(SUBDIRS_CLEAN)
 	rm -f defaults.h
-	rm -f config/scripts/astman_vars.js
 
 distclean: clean
 	-rm -f makeopts config.log config.status

Added: team/group/new_exp/build_tools/make_astman_vars_js
URL: http://svn.digium.com/view/asterisk-gui/team/group/new_exp/build_tools/make_astman_vars_js?view=auto&rev=1810
==============================================================================
--- team/group/new_exp/build_tools/make_astman_vars_js (added)
+++ team/group/new_exp/build_tools/make_astman_vars_js Mon Nov 19 14:18:33 2007
@@ -1,0 +1,43 @@
+#!/bin/sh
+cat << END
+/*
+ * Asterisk GUI -- GUI for the Asterisk open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2007, Digium, Inc.
+ *
+ * Mark Spencer <markster at digium.com>
+ * Pari Nannapaneni <pari at digium.com>
+ * Brandon Kruse <bkruse at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ *
+ */
+
+/* Dynamic Variables From The Makefile */
+var dynamic_guiappname =  "Asterisk GUI";
+var dynamic_scriptsFolder = "${INSTALL_PATH}${ASTVARLIBDIR}/scripts/"; /* Directory for gui scripts (graphs.sh, for example) */
+var dynamic_ConfigBkpPath = "${INSTALL_PATH}${ASTVARLIBDIR}/sounds/backups/";
+var dynamic_Sounds_path = "${INSTALL_PATH}${ASTDATADIR}/sounds";
+var dynamic_menusRecord_path = dynamic_Sounds_path + "record/";
+var dynamic_guiSysInfo = "sh " + dynamic_scriptsFolder + "gui_sysinfo";
+var dynamic_guiSysInfo_output = "./sysinfo_output.html";
+var dynamic_guiZapscan = "${ASTSBINDIR}/zapscan.bin";
+var dynamic_guiZtscan = "${ASTSBINDIR}/ztscan";
+var dynamic_guiEditZap = "sh " + dynamic_scriptsFolder + "editzap.sh";
+var dynamic_rawmanPath = "../../rawman";
+var dynamic_guiConfigFile = "guipreferences.conf"; // will be created in dynamic_configfolder, if the file does not exist
+var dynamic_configfolder = "${INSTALL_PATH}${ASTETCDIR}";
+var dynamic_guiListFiles = "sh " + dynamic_scriptsFolder + "listfiles" ;
+var dynamic_zaptelConfig = "/etc/zaptel.conf";
+/* End Dynamic Variables */
+
+END
+

Propchange: team/group/new_exp/build_tools/make_astman_vars_js
------------------------------------------------------------------------------
    svn:executable = *

Added: team/group/new_exp/build_tools/make_defaults_h
URL: http://svn.digium.com/view/asterisk-gui/team/group/new_exp/build_tools/make_defaults_h?view=auto&rev=1810
==============================================================================
--- team/group/new_exp/build_tools/make_defaults_h (added)
+++ team/group/new_exp/build_tools/make_defaults_h Mon Nov 19 14:18:33 2007
@@ -1,0 +1,27 @@
+#!/bin/sh
+cat << END
+/*
+ * defaults.h 
+ * Automatically generated
+ */
+#define AST_CONFIG_DIR "${INSTALL_PATH}${ASTETCDIR}"
+#define AST_RUN_DIR    "${INSTALL_PATH}${ASTVARRUNDIR}"
+#define AST_SOCKET     "${INSTALL_PATH}${ASTVARRUNDIR}/asterisk.ctl"
+#define AST_PID        "${INSTALL_PATH}${ASTVARRUNDIR}/asterisk.pid"
+#define AST_MODULE_DIR "${INSTALL_PATH}${MODULES_DIR}"
+#define AST_SPOOL_DIR  "${INSTALL_PATH}${ASTSPOOLDIR}"
+#define AST_VAR_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}"
+#define AST_DATA_DIR   "${INSTALL_PATH}${ASTDATADIR}"
+#define AST_LOG_DIR    "${INSTALL_PATH}${ASTLOGDIR}"
+#define AST_AGI_DIR    "${INSTALL_PATH}${AGI_DIR}"
+#define AST_KEY_DIR    "${INSTALL_PATH}${ASTDATADIR}/keys"
+#define AST_DB         "${INSTALL_PATH}${ASTVARLIBDIR}/astdb"
+#define AST_TMP_DIR    "${INSTALL_PATH}${ASTSPOOLDIR}/tmp"
+
+#define AST_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
+
+#define AST_SOUNDS     "${INSTALL_PATH}${ASTDATADIR}/sounds"
+#define AST_IMAGES     "${INSTALL_PATH}${ASTDATADIR}/images"
+
+END
+

Propchange: team/group/new_exp/build_tools/make_defaults_h
------------------------------------------------------------------------------
    svn:executable = *

Modified: team/group/new_exp/scripts/astman.js
URL: http://svn.digium.com/view/asterisk-gui/team/group/new_exp/scripts/astman.js?view=diff&rev=1810&r1=1809&r2=1810
==============================================================================
--- team/group/new_exp/scripts/astman.js (original)
+++ team/group/new_exp/scripts/astman.js Mon Nov 19 14:18:33 2007
@@ -1,24 +1,3 @@
-/*
- * Asterisk GUI -- GUI for the Asterisk open source telephony toolkit.
- *
- * Copyright (C) 1999 - 2007, Digium, Inc.
- *
- * Mark Spencer <markster at digium.com>
- * Pari Nannapaneni <pari at digium.com>
- * Brandon Kruse <bkruse at digium.com>
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
- *
- */
-
 _$ = function(x){ return document.getElementById(x); } 
 
 String.prototype.beginsWith = function(a){
@@ -42,11 +21,11 @@
 var ASTGUI = {
 	// global varibles and GUI component functions
 	globals:{
-		appname :"Asterisk GUI",
+		appname : dynamic_guiappname,
 		lang : lg,
-		rawmanPath : "../../rawman",
+		rawmanPath : dynamic_rawmanPath,
 		msg_notLoggedIn: "Message: Authentication Required",
-		configfile : "guipreferences.conf", // will be created if the file does not exist 
+		configfile : dynamic_guiConfigFile, // will be created if the file does not exist 
 		pingInterval : 5000
 	},
 
@@ -57,24 +36,25 @@
 	},
 
 	paths: {
-		asteriskConfig: "/etc/asterisk/",
-		ConfigBkp: '/var/lib/asterisk/sounds/backups/',
-		Sounds: '/var/lib/asterisk/sounds/', 
-		menusRecord: '/var/lib/asterisk/sounds/record/',
-		scripts: '/var/lib/asterisk/scripts/', /* Directory for gui scripts (graphs.sh, for example) */	
+		asteriskConfig: dynamic_configfolder,
+		ConfigBkp: dynamic_ConfigBkpPath,
+		Sounds: dynamic_Sounds_path, 
+		menusRecord: dynamic_menusRecord_path,
+		scripts: dynamic_scriptsFolder, /* Directory for gui scripts (graphs.sh, for example) */	
 		output_SysInfo : "./sysinfo_output.html" // note that this one is not a file system path but a url
 	},
 
 	scripts: {
-		takeBackup : "sh /var/lib/asterisk/scripts/takebackup",
-		restoreBackup : "sh /var/lib/asterisk/scripts/restorebackup",
-		SysInfo : "gui_sysinfo",
-		ListFiles : "listfiles",
+		takeBackup : "sh " + dynamic_scriptsFolder + "takebackup",
+		restoreBackup : "sh " + dynamic_scriptsFolder + "restorebackup",
+		SysInfo : "sh " + dynamic_scriptsFolder + "gui_sysinfo",
+		ListFiles : "sh " + dynamic_scriptsFolder + "listfiles",
 		NetworkSettings : "networking.sh"
 	},
 
 	apps:{
-		Zapscan : "/sbin/zapscan.bin",
+		Zapscan : dynamic_guiZapScan,
+		Ztscan : dynamic_guiZtscan,
 		flashupdate : "flashupdate"
 	},
 

Modified: team/group/new_exp/todo.txt
URL: http://svn.digium.com/view/asterisk-gui/team/group/new_exp/todo.txt?view=diff&rev=1810&r1=1809&r2=1810
==============================================================================
--- team/group/new_exp/todo.txt (original)
+++ team/group/new_exp/todo.txt Mon Nov 19 14:18:33 2007
@@ -7,4 +7,6 @@
 
 Todo
 ----- 
-Rewrite the GUI (we will keep our status updates and proposed methods of fixing and new gui here)
+* Rewrite the GUI (we will keep our status updates and proposed methods of fixing and new gui here)
+
+* Let the Makefile put a "header" into astman.js that will have variables about the system. (config file directory for examples)

Modified: team/group/new_exp/tools/Makefile
URL: http://svn.digium.com/view/asterisk-gui/team/group/new_exp/tools/Makefile?view=diff&rev=1810&r1=1807&r2=1810
==============================================================================
--- team/group/new_exp/tools/Makefile (original)
+++ team/group/new_exp/tools/Makefile Mon Nov 19 14:18:33 2007
@@ -33,21 +33,19 @@
 ifeq ($(PBX_ZAPTEL),1)
 	mkdir -p $(ASTSBINDIR)
 	$(INSTALL) -m 755 zapscan.bin $(ASTSBINDIR)
-	$(INSTALL) -m 755 zapscan $(ASTSBINDIR)
+	if [ ! -f $(ASTSBINDIR)/zapscan ]; then \
+		cat zapscan | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ZAPTEL_ETC_DIR__|$(ZAPETCDIR)|;' > $(ASTSBINDIR)/zapscan;\
+		chmod 755 $(ASTSBINDIR)/zapscan;\
+	fi
 	$(INSTALL) -m 755 ztscan $(ASTSBINDIR)
-	$(INSTALL) -m 755 zapscan.bin /sbin/zapscan.bin
-	$(INSTALL) -m 755 zapscan /sbin/zapscan
-	$(INSTALL) -m 755 ztscan /sbin/ztscan
-
-	
 endif
 
 clean: 
 	rm -f zapscan.o
 	rm -f zapscan.bin
 	rm -f ztscan
-	rm -f /sbin/zapscan.bin
-	rm -f /sbin/zapscan
-	rm -f /sbin/ztscan
+	rm -f $(ASTSBINDIR)/zapscan.bin
+	rm -f $(ASTSBINDIR)/zapscan
+	rm -f $(ASTSBINDIR)/ztscan
 
 .PHONY: all install clean

Modified: team/group/new_exp/tools/zapscan
URL: http://svn.digium.com/view/asterisk-gui/team/group/new_exp/tools/zapscan?view=diff&rev=1810&r1=1807&r2=1810
==============================================================================
--- team/group/new_exp/tools/zapscan (original)
+++ team/group/new_exp/tools/zapscan Mon Nov 19 14:18:33 2007
@@ -1,10 +1,14 @@
 #!/bin/sh
-if [ -f /etc/zaptel.conf.zapscan ] && [ -f /etc/asterisk/zapata.conf.zapscan ]; then
-	rm -f /etc/zaptel.conf
-	rm -f /etc/asterisk/zapata.conf
-	( echo "# Created by zapscan -- edit zaptel.conf.zapscan instead" ; cat /etc/zaptel.conf.zapscan ) > /etc/zaptel.conf
-	( echo "; Created by zapscan -- edit zapata.conf.zapscan instead" ; cat /etc/asterisk/zapata.conf.zapscan ) > /etc/asterisk/zapata.conf
-	rm -f /etc/asterisk/zapscan.conf
+
+ASTETCDIR=__ASTERISK_ETC_DIR__
+ZAPETCDIR=__ZAPTEL_ETC_DIR__
+
+if [ -f $ZAPETCDIR/zaptel.conf.zapscan ] && [ -f $ASTETCDIR/zapata.conf.zapscan ]; then
+	rm -f $ZAPETCDIR/zaptel.conf
+	rm -f $ASTETCDIR/zapata.conf
+	( echo "# Created by zapscan -- edit zaptel.conf.zapscan instead" ; cat $ZAPETCDIR/zaptel.conf.zapscan ) > $ZAPETCDIR/zaptel.conf
+	( echo "; Created by zapscan -- edit zapata.conf.zapscan instead" ; cat $ASTETCDIR/zapata.conf.zapscan ) > $ASTETCDIR/zapata.conf
+	rm -f $ASTETCDIR/zapscan.conf
 	echo -n "Scanning for zaptel devices..."
 	if zapscan.bin; then
 		echo "OK"

Modified: team/group/new_exp/tools/zapscan.c
URL: http://svn.digium.com/view/asterisk-gui/team/group/new_exp/tools/zapscan.c?view=diff&rev=1810&r1=1807&r2=1810
==============================================================================
--- team/group/new_exp/tools/zapscan.c (original)
+++ team/group/new_exp/tools/zapscan.c Mon Nov 19 14:18:33 2007
@@ -31,23 +31,40 @@
 #include <sys/ioctl.h>
 #include <zaptel/zaptel.h>
 
+#include "../defaults.h"
+
 int main(int argc, char *argv[])
 {
+	char fd_filename[256] = "/dev/zap/ctl";
+	char zdc_filename[256] = "/etc/zaptel.conf";
+	char zsc_filename[256] = AST_CONFIG_DIR "/zapscan.conf";
+	char zap_filename[256] = AST_CONFIG_DIR "/zapata.conf";
+
 	int x;
 	int oldsig=-1;
-	int fd = open("/dev/zap/ctl", O_RDWR);
+	int fd = open(fd_filename, O_RDWR);
 	struct zt_params ztp;
-	FILE *zdc = fopen("/etc/zaptel.conf", "a");
-	FILE *zsc = fopen("/etc/asterisk/zapscan.conf", "w");
-	FILE *zap = fopen("/etc/asterisk/zapata.conf", "a");
+	FILE *zdc = fopen(zdc_filename, "a");
+	FILE *zsc = fopen(zsc_filename, "w");
+	FILE *zap = fopen(zap_filename, "a");
+
 	if (fd < 0) {
-		fprintf(stderr, "Failed to open /dev/zap/ctl: %s\n", strerror(errno));
+		fprintf(stderr, "Failed to open %s : %s\n", fd_filename, strerror(errno));
 		exit(1);
 	}
-	if (!zdc||!zsc||!zap) {
-		fprintf(stderr, "Failed to open zaptel.conf or zapscan.conf or zapata.conf");
+	if (!zdc) {
+		fprintf(stderr, "Failed to open %s : %s\n", zdc_filename,  strerror(errno));
 		exit(1);
 	}
+	if (!zsc) {
+		fprintf(stderr, "Failed to open %s : %s\n", zsc_filename,  strerror(errno));
+		exit(1);
+	}
+	if (!zap) {
+		fprintf(stderr, "Failed to open %s : %s\n", zap_filename,  strerror(errno));
+		exit(1);
+	}
+
 	for (x=1;;x++) {
 		memset(&ztp, 0, sizeof(ztp));
 		ztp.channo = x;




More information about the asterisk-gui-commits mailing list