summaryrefslogtreecommitdiff
path: root/build_tools
diff options
context:
space:
mode:
authorkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-05-17 19:06:34 +0000
committerkpfleming <kpfleming@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-05-17 19:06:34 +0000
commitc9f7297b684b0daba5d1a939ba13c98de97eff8f (patch)
tree98e572a5473dc9f32a60bf4db565da4ed076b8e8 /build_tools
parentb3c1476d129d058703d75fce49097f075cb7fb93 (diff)
Merged revisions 1064-1065 via svnmerge from
https://origsvn.digium.com/svn/zaptel/branches/1.2 ........ r1064 | kpfleming | 2006-05-17 11:49:46 -0500 (Wed, 17 May 2006) | 2 lines move udev rules creating into a script, and generate it properly based on the installed udev version ........ r1065 | kpfleming | 2006-05-17 13:50:38 -0500 (Wed, 17 May 2006) | 2 lines move module-rules building into a script, and remove some old unnecessary steps ........ git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1067 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'build_tools')
-rwxr-xr-xbuild_tools/genmodconf100
-rwxr-xr-xbuild_tools/genudevrules30
2 files changed, 130 insertions, 0 deletions
diff --git a/build_tools/genmodconf b/build_tools/genmodconf
new file mode 100755
index 0000000..cafc869
--- /dev/null
+++ b/build_tools/genmodconf
@@ -0,0 +1,100 @@
+#!/bin/sh
+
+# this script makes an attempt to build a proper set of rules
+# for loading the Zaptel modules and automatically running ztcfg
+#
+# it accepts three parameters:
+# the kernel major version being targeted (either linux24 or linux26)
+# the root prefix to be used for finding/creating the files
+# the list of module names being installed
+#
+# the process is as follows:
+#
+# for linux24, the file can be located either at /etc/modules.conf (combined
+# with all other rules) or in /etc/modutils/zaptel (only the Zaptel rules)
+#
+# for linux26, the file can be located at /etc/modprobe.conf (combined with all
+# other rules), /etc/modprobe.d/zaptel (Zaptel only) or /etc/modules.d/zaptel
+# (Zaptel only)
+#
+# when the file is Zaptel rules only, then we don't preserve the existing
+# contents of the file; the system administrator can put desired options and
+# overrides in a separate file with a name that appears earlier in the sort
+# order, so there is no need to edit the file produced by this script
+#
+# when the file is combined with all other rules, then we make a backup
+# of it and remove all the old Zaptel rules we can find, replacing them with
+# new ones
+#
+# in addition, for linux26, versions of module-init-tools 3.2.0 and later
+# have the ability to pass module parameters specified on the modprobe command
+# line to commands in 'install' rules, thus keeping them from being lost, so
+# we try to determine what version is installed and take advantage of that
+
+if [ "${1}" == "linux24" ]; then
+ if [ -d ${2}/etc/modutils ]; then
+ target=${2}/etc/modutils/zaptel
+ elif [ -f ${2}/etc/modules.conf ]; then
+ target=${2}/etc/modules.conf
+ backup=1
+ else
+ echo No suitable location for module rules can be found... exiting.
+ exit 1
+ fi
+elif [ "${1}" == "linux26" ]; then
+ toolver=`/sbin/modprobe --version | awk '{print $$3;}' | cut -d. -f2`
+ if [ ${toolver} -ge 2 ]; then
+ cmdopts=\$CMDLINE_OPTS
+ fi
+ if [ -d ${2}/etc/modprobe.d ]; then
+ target=${2}/etc/modprobe.d/zaptel
+ elif [ -d ${2}/etc/modules.d ]; then
+ target=${2}/etc/modules.d/zaptel
+ elif [ -f ${2}/etc/modprobe.conf ]; then
+ target=${2}/etc/modprobe.conf
+ backup=1
+ elif [ -f ${2}/etc/conf.modules ]; then
+ target=${2}/etc/conf.modules
+ backup=1
+ else
+ echo No suitable location for module rules can be found... exiting.
+ exit 1
+ fi
+else
+ echo Unknown kernel build version requested... exiting.
+ exit 1
+fi
+
+if [ -n "${backup}" ]; then
+ if [ -f ${target} ]; then
+ mv ${target} ${target}.bak
+ cat ${target}.bak | grep -v "alias char-major-250" | grep -v "alias char-major-196" > ${target}
+ fi
+else
+ rm -f ${target}
+ echo "# automatically generated file; do not edit" > ${target}
+fi
+
+echo Building ${target}...
+
+if [ "${1}" == "linux24" ]; then
+ for mod in ${3}; do
+ if ! grep -q "post-install ${mod} " ${target}; then
+ echo "post-install ${mod} /sbin/ztcfg" >> ${target}
+ fi
+ done
+elif [ "${1}" == "linux26" ]; then
+ for mod in ${3}; do
+ if ! grep -q "install ${mod} " ${target}; then
+ echo "install ${mod} /sbin/modprobe --ignore-install ${mod} ${cmdopts} && /sbin/ztcfg" >> ${target}
+ fi
+ done
+fi
+
+if ! grep -q "alias wcfxs" ${target}; then
+ echo "alias wcfxs wctdm" >> ${target};
+fi;
+if ! grep -q "alias wct2xxp" ${target}; then
+ echo "alias wct2xxp wct4xxp" >> ${target};
+fi;
+
diff --git a/build_tools/genudevrules b/build_tools/genudevrules
new file mode 100755
index 0000000..a536f75
--- /dev/null
+++ b/build_tools/genudevrules
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+ver=`udevinfo -V | cut -f3 -d" "`
+
+if [ -z "${ver}" ]; then
+ echo Cannot determine the version of udev installed this system... exiting.
+ exit 1
+fi
+
+# udev versions prior to 055 use a single '=' for matching key values
+# udev versions 055 and later support '==' for that purpose, and versions
+# beyond 092 will probably make it mandatory
+#
+# very old versions of udev required naming rules and permissions rules to be
+# in separate files, but it's not clear at what version number that changed
+
+if [ ${ver} -gt 54 ]; then
+ match="=="
+else
+ match="="
+fi
+
+cat <<EOF
+# zaptel devices with ownership/permissions for running as non-root
+KERNEL${match}"zapctl", NAME="zap/ctl", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+KERNEL${match}"zaptimer", NAME="zap/timer", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+KERNEL${match}"zapchannel", NAME="zap/channel", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+KERNEL${match}"zappseudo", NAME="zap/pseudo", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+KERNEL${match}"zap[0-9]*", NAME="zap/%n", OWNER="asterisk", GROUP="asterisk", MODE="0660"
+EOF