diff options
author | Chris Severance | 2016-12-21 06:03:55 -0500 |
---|---|---|
committer | Chris Severance | 2016-12-21 06:03:55 -0500 |
commit | b100308d2ffecb335f3813ef399f240f28db71cf (patch) | |
tree | 05a9fc32bcd29b1c14da10d504daa63468510e6a | |
download | aur-b100308d2ffecb335f3813ef399f240f28db71cf.tar.gz |
Initial Import
-rw-r--r-- | .SRCINFO | 35 | ||||
-rw-r--r-- | PKGBUILD | 370 | ||||
-rw-r--r-- | dmupdate.py.usage.patch | 36 | ||||
-rw-r--r-- | nslink-install.sh | 52 | ||||
-rw-r--r-- | nslinktool.systemd.patch | 161 |
5 files changed, 654 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO new file mode 100644 index 000000000000..57272fcb9e8f --- /dev/null +++ b/.SRCINFO @@ -0,0 +1,35 @@ +# Generated by mksrcinfo v8 +# Wed Dec 21 10:55:21 UTC 2016 +pkgbase = nslink + pkgdesc = TTY driver and firmware update for Comtrol DeviceMaster, RTS, LT, PRO, 500, UP, RPSH-SI, RPSH, and Serial Hub console terminal device server + pkgver = 7.15 + pkgrel = 1 + url = http://www.comtrol.com/ + install = nslink-install.sh + arch = i686 + arch = x86_64 + license = GPL + depends = glibc + depends = openssl + depends = python2 + depends = sed + depends = groff + depends = tcl + depends = tk + depends = util-linux + depends = linux + depends = dkms + depends = linux-headers + options = !zipman + backup = etc/nslink.conf + source = http://downloads.comtrol.com/dev_mstr/rts/drivers/linux/devicemaster-linux-7.15.tar.gz + source = http://downloads.comtrol.com/dev_mstr/rts/utility/linux_firmware_uploader/DM-Firmware-Updater-1.06.tar.gz + source = dmupdate.py.usage.patch + source = nslinktool.systemd.patch + sha256sums = f166dc53d53c856a790b4c21f40f3f9df66684aa687fa84b502a795a8130dafc + sha256sums = d21c5eeefdbf08a202a230454f0bf702221686ba3e663eb41852719bb20b75fb + sha256sums = 5fb100b904cd9af08f8af57a95b3d7a336e09183e8449eaace4c65ecc7b9685a + sha256sums = 84e7cdfda9e077d904f8cc3e981b9e330d3851ee6edf4529fcbeac61cd53e029 + +pkgname = nslink + diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 000000000000..2accf29ecb5f --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,370 @@ +# Maintainer: Chris Severance aur.severach aATt spamgourmet dott com + +_opt_DKMS=1 # This can be toggled between installs +#_opt_defaultmode='666' # default: 660 + +# Todo: Implement defaultmode +# Todo: Test secure mode + +# Todo: python tools should be updated to python3 +# Todo: nslinkadmin ethdevname needs to be adjustable when launched from command line, not "eth0". +# Todo: nslinktool add systemd support +# Todo: nslinktool needs an eth selector +# Todo: nslinktool what does the "Load" button do? +# Todo: nslinktool Config Driver needs an up down button to reorder entries +# Todo: separate firmware updater +# Todo: Comtrol icons for nslinktool and the firmware updater +# Todo: The IP is backwards in /proc/driver/nslink/status + +# Uninstall cleanup: sudo rm -f /etc/nslink.conf* + +set -u +pkgname='nslink' +pkgver=7.15 +pkgrel=1 +pkgdesc='TTY driver and firmware update for Comtrol DeviceMaster, RTS, LT, PRO, 500, UP, RPSH-SI, RPSH, and Serial Hub console terminal device server' +# UP is not explicitly supported by NS-Link +_pkgdescshort="Comtrol DeviceMaster ${pkgname} TTY driver" +arch=('i686' 'x86_64') +url='http://www.comtrol.com/' +license=('GPL') +depends=('glibc' 'openssl' 'python2' 'sed' 'groff' 'tcl' 'tk' 'util-linux') +makedepends=() +backup=("etc/nslink.conf") +options=('!zipman') +install="${pkgname}-install.sh" +_verwatch=('http://downloads.comtrol.com/html/DM_PRO_RTS_SERIALHUB_drivers.htm' '.*/devicemaster-linux-\([0-9\.]\+\)\.tar\.gz' 'l') +_srcdir="devicemaster-linux-${pkgver}" +_srcdir2="DM-Firmware-Updater-1.06" +#source=("ftp://ftp.comtrol.com/dev_mstr/rts/drivers/linux/devicemaster-linux-${pkgver}.tar.gz") +source=("http://downloads.comtrol.com/dev_mstr/rts/drivers/linux/devicemaster-linux-${pkgver}.tar.gz") +#source+=('ftp://ftp.comtrol.com/dev_mstr/rts/utility/linux_firmware_uploader/DM-Firmware-Updater-1.06.tar.gz') +source+=('http://downloads.comtrol.com/dev_mstr/rts/utility/linux_firmware_uploader/DM-Firmware-Updater-1.06.tar.gz') +source+=('dmupdate.py.usage.patch' 'nslinktool.systemd.patch') +sha256sums=('f166dc53d53c856a790b4c21f40f3f9df66684aa687fa84b502a795a8130dafc' + 'd21c5eeefdbf08a202a230454f0bf702221686ba3e663eb41852719bb20b75fb' + '5fb100b904cd9af08f8af57a95b3d7a336e09183e8449eaace4c65ecc7b9685a' + '84e7cdfda9e077d904f8cc3e981b9e330d3851ee6edf4529fcbeac61cd53e029') + +if [ "${_opt_DKMS}" -ne 0 ]; then + depends+=('linux' 'dkms' 'linux-headers') +else + makedepends+=('linux-headers') +fi + +_opt_ethernet_data='eno_____________________________' +_opt_ethernet_keystring='<-<-<-ArchLinux_ethernet_keystring->->->' + +prepare() { + set -u + cd "${_srcdir}" + + # Fix permissions + find -type 'f' -perm '/111' -exec chmod 644 '{}' '+' + chmod 755 *.sh *.py 'nslinktool' + local _ver="$(sed -n -e 's:^#define\sSI_VERSION\s"\([^"]\+\).*$:\1:p' 'version.h')" + if [ "${pkgver}" != "${_ver}" ]; then + echo "Version mismatch ${pkgver} != ${_ver}" + set +u + false + fi + unset _ver + + # Minor fixes to Makefile + sed -i -e '# Fix a path' \ + -e 's:/lib/:/usr/lib/:g' \ + -e '# These lines look dangerous so well disable them' \ + -e 's:^ifneq "$(wildcard /usr/src/.*$:ifneq "ArchLinux" "ArchLinux":g' \ + -e '# We can force this one true' \ + -e 's:^ifneq "$(wildcard /usr/lib/.*$:ifneq "ArchLinux" "0":g' \ + 'Makefile' + + #cp -p 'install.sh' 'install.sh.Arch' # testmode for diff comparison + sed -i -e '# Fix some paths' \ + -e 's: /lib/: /usr/lib/:g' \ + -e 's: /sbin: /usr/bin:g' \ + -e 's:"/sbin:"/usr/bin:g' \ + -e 's:/usr/sbin:/usr/bin:g' \ + -e 's:/usr/local/man:/usr/share/man:g' \ + -e '# I suspect this folder for systemd is wrong even on RedHat' \ + -e 's:/etc/systemd/system:/usr/lib/systemd/system:g' \ + -e '# make package compatible' \ + -e 's:"/etc/:"${DESTDIR}/etc/:g' \ + -e 's: /etc/: "${DESTDIR}"/etc/:g' \ + -e 's:"/usr/:"${DESTDIR}/usr/:g' \ + -e 's: /usr/: "${DESTDIR}"/usr/:g' \ + -e '# Disable module management and message' \ + -e 's:^\s\+echo\s-n\s"Rebuilding:# &:g' \ + -e 's:^.*depmod -a:# &:g' \ + -e '# Disable systemd management' \ + -e 's:^\s\+systemctl:# &:g' \ + -e '# Get rid of the start messages lest someone believes them' \ + -e 's:^\s\+if\s\[\s"$WillStart"\s=\syes\s\]:return\n&:g' \ + 'install.sh' + if [ -s 'install.sh.Arch' ]; then + echo 'Disable testmode to build' + set +u + false + fi + + # Switch to python2 + sed -i -e '# Why using local on just this one?' \ + -e 's:/usr/local/bin/python:/usr/bin/python:g' \ + -e 's:/usr/bin/python:&2:g' \ + *.py 'nslinktool' + + # The command line tool is unusable without the proper ethernet card in it. + # There's a parameter but who would know! We'll add a searchable string + # that a launcher can modify. + sed -i -e 's:"eth0":"'"${_opt_ethernet_data}${_opt_ethernet_keystring}"'":g' 'nslinkadmin.c' + + # nslinktool has the same problem but it's a GUI app. The best we can + # do is start with the right network card. It really needs to become + # a dropdown. + local _neweth + local _neweths=($(ip addr | grep ' UP ' | cut -d':' -f2)) + if [ "${#_neweths[@]}" -ne 0 ]; then + _neweth="s:eth0:${_neweths[0]}:g" + else + _neweth='#' + fi + + # Fix nslinktool. We'll get rid of the tabs while we're here. + cp -p 'nslinktool' 'nslinktool.orig' + sed -e '# Fix paths and enable our fixed admin tool:g' \ + -e 's:/usr/sbin/nslinkadmin:/usr/bin/nslinkadmin.exec:g' \ + -e 's:/usr/local/man:/usr/share/man:g' \ + -e '# Cosmetic cleanup for simpler patch editing' \ + -e 's:\s\+$::g' \ + -e '# Ethernet fix from above' \ + -e "${_neweth}" \ + 'nslinktool.orig' | expand -i > 'nslinktool' + rm 'nslinktool.orig' + unset _neweth _neweths + + # Patch systemd code into the GUI tool + ##diff -c5 'nslinktool.orig' 'nslinktool' > '../../nslinktool.systemd.patch' + patch -c -b -p0 < "${srcdir}/nslinktool.systemd.patch" + + # Fix up the firmware downloaders + cd "${srcdir}/${_srcdir2}" + + # Fix permissions + find -type 'f' -perm '/111' -exec chmod 644 '{}' '+' + chmod 755 *.py + + sed -i -e '# Cosmetic cleanup for simpler patch editing' \ + -e 's:\s\+$::g' \ + -e '# Switch to python2' \ + -e 's:/usr/bin/python:&2:g' \ + *.py + + # Patch usage and help into command line tool + ##diff -c5 'dmupdate.py.orig' 'dmupdate.py' > '../../dmupdate.py.usage.patch' + patch -c -b -p0 < "${srcdir}/dmupdate.py.usage.patch" + + set +u +} + +build() { + set -u + cd "${_srcdir}" + make -j1 QUIET=0 + set +u +} + +package() { + set -u + cd "${_srcdir}" + + if [ "${_opt_DKMS}" -eq 0 ]; then + # I don't want Linux version info showing on AUR web. After a few months 'linux<0.0.0' makes it look like an out of date package. + local _kernelversionsmall="$(pacman -Q linux)" # this differs from uname -r. pacman: 4.0, uname: 4.0.0 + _kernelversionsmall="${_kernelversionsmall#* }" + _kernelversionsmall="${_kernelversionsmall%-*}" + # prevent the mksrcinfo bash emulator from getting these vars! + eval 'conf''licts=("linux>${_kernelversionsmall}" "linux<${_kernelversionsmall}")' + eval 'dep''ends+=("linux=${_kernelversionsmall}")' + fi + + # This installer expects the system folders to already exist + install -dm755 "${pkgdir}"{'/usr/bin','/etc',"/usr/lib/modules/$(uname -r)/misc",'/usr/lib/systemd/system'} + + DESTDIR="${pkgdir}" \ + INIT='systemd' \ + sh -e -u 'install.sh' "$(uname -r)" install + + # Fix paths in the service file + sed -i -e 's:/sbin/:/usr/bin/:g' "${pkgdir}/usr/lib/systemd/system/nslink.service" + + # Root only permissions on executables. Easier than hacking UID 0 into them. + find "${pkgdir}/usr/bin/" -type 'f' -perm /111 -exec chmod 744 '{}' '+' + + # Preserve an original copy of the config file + install -Dpm644 "${pkgdir}/etc/nslink.conf" "${pkgdir}/usr/share/nslink/nslink.conf.orig" + + # Desktop file for NS-Link + install -Dm644 <(cat << EOF +[Desktop Entry] +Name=Comtrol NS-Link Administration +GenericName=Device Server Manager +Comment=DeviceMaster NS-Link for Comtrol Device Servers +Exec=gksudo -k -u root nslinktool +Terminal=false +Type=Application +#Icon= +Categories=Application;Utilities; +MimeType=application/x-executable +EOF + ) "${pkgdir}/usr/share/applications/nslinktool.desktop" + + # Generate launcher + mv "${pkgdir}/usr/bin"/{'nslinkadmin','nslinkadmin.exec'} + install -Dm755 <(cat << EOF +#!/bin/bash +# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR +# http://aur.archlinux.org/ + +# A launcher to detect UP ethernet interfaces and sed the selected on into a temp executable. +# The executable has been compiled with a special string that we can replace. + +set -e +set -u + +neweths=(\$(ip addr | grep ' UP ' | cut -d':' -f2)) + +DEBUG=0 +if [ "\${DEBUG}" -ne 0 ]; then + if [ "\${EUID}" -eq 0 ]; then + echo 'Must not be root' + exit 1 + fi + adminbin='./nslinkadmin.exec' + admintmp="\${adminbin}.tmp" + cp -pn "\${adminbin}" "\${adminbin}.bak" + neweths+=(Arch Linux) +else + if [ "\${EUID}" -ne 0 ]; then + echo 'Must be root' + exit 1 + fi + adminbin='/usr/bin/nslinkadmin.exec' + admintmp="/tmp/nslinkadmin.tmp.\$$" +fi + +case "\${#neweths[@]}" in +0) + echo 'No network cards are available in the UP state. Try ip addr' + exit 2 + ;; +1) + neweth="\${neweths[0]}" + #echo "Auto selecting only NIC \${neweth}" # The next program shows this so we don't need to. + ;; +*) + echo 'Available UP network cards' + idx=0 + for neweth in "\${neweths[@]}"; do + idx=\$((idx+1)) + echo -n "\${idx}-\${neweth} " + done + echo '' + wantidx=-1 + while [ "\${wantidx}" -lt 0 ]; do + echo -n "Select network card or 0 to quit:" + read wantidx + if [ -z "\${wantidx}" ] || [[ ! "\${wantidx}" =~ ^[0-9]+$ ]] || [ "\${wantidx}" -lt 0 ] || [ "\${wantidx}" -gt "\${idx}" ]; then + wantidx=-1 + fi + if [ "\${wantidx}" -eq 0 ]; then + exit 0 + fi + done + neweth="\${neweths[\$((wantidx-1))]}" +esac + +if [ "\${DEBUG}" -ne 0 ]; then + set -x +fi + +# These values are compiled into the executable by the PKGBUILD and must not be changed here +neweth="\$(printf "%-${#_opt_ethernet_data}s" "\${neweth}")" +neweth="\${neweth// /\\\\x00}" # binary replace + +set +e +( +umask 077 +rm -f "\${admintmp}" +sed -e 's:${_opt_ethernet_data}${_opt_ethernet_keystring}:'"\${neweth}${_opt_ethernet_keystring}:" "\${adminbin}" > "\${admintmp}" +) +chmod 700 "\${admintmp}" + +rv=0 +if [ "\${DEBUG}" -eq 0 ] || [ "\$(stat -c '%s' "\${adminbin}")" -eq "\$(stat -c '%s' "\${adminbin}.bak")" ]; then + trap "{ rm -f "\${admintmp}"; exit 255; }" SIGINT + set +e + "\${admintmp}" "\$@" + rv="\$?" + if [ "\${DEBUG}" -eq 0 ]; then + rm "\${admintmp}" + fi +fi +exit "\${rv}" +EOF + ) "${pkgdir}/usr/bin/nslinkadmin" + + # DKMS + if [ "${_opt_DKMS}" -ne 0 ]; then + rm -rf "${pkgdir}/usr/lib/modules/" + install -d "${pkgdir}/usr/src/${pkgname}-${pkgver}" + install -Dpm644 'nslink.h' 'nslink_int.h' 'version.h' 'nslink.c' 'Makefile' -t "${pkgdir}/usr/src/${pkgname}-${pkgver}/" + install -Dm644 <(cat << EOF +# Automatically generated by ${pkgname}-${pkgver} PKGBUILD from Arch Linux AUR +# http://aur.archlinux.org/ + +PACKAGE_NAME="${pkgname}" +PACKAGE_VERSION="${pkgver}" +AUTOINSTALL="yes" + +BUILT_MODULE_NAME[0]="nslink" +BUILT_MODULE_LOCATION[0]="" +# Using all processors doesn't compile this tiny module any faster. +MAKE[0]="make -j1 all QUIET=1" +CLEAN[0]="make -j1 clean" +# Placing the DKMS generated module in a different location than the standard install prevents conflicts when PKGBUILD _opt_DKMS is toggled +DEST_MODULE_LOCATION[0]="/kernel/drivers/misc" +EOF + ) "${pkgdir}/usr/src/${pkgname}-${pkgver}/dkms.conf" + #make -C "${pkgdir}/usr/src/${pkgname}-${pkgver}/" clean + sed -i -e '# No DKMS instructions say to do this but it works and keeps the MAKE line real simple' \ + -e 's:$(shell uname -r):$(KERNELRELEASE):g' \ + -e 's:`uname -r`:$(KERNELRELEASE):g' \ + -e 's:$(KVER):$(KERNELRELEASE):g' \ + -e '# Get rid of make lines so make all makes the module' \ + -e 's:^\s\+make\s:#&:g' \ + "${pkgdir}/usr/src/${pkgname}-${pkgver}/Makefile" + fi + + # Install firmware updaters + cd "${srcdir}/${_srcdir2}" + install -Dpm755 *.py -t "${pkgdir}/usr/bin/" + install -Dpm644 'README.txt' -t "${pkgdir}/usr/share/nslink/" + + # Desktop file for GUI firmware updater + install -Dm644 <(cat << EOF +[Desktop Entry] +Name=Comtrol Update Firmware +GenericName=Device Server Manager +Comment=Manage Firmware on Comtrol Device Servers +Exec=DM-Firmware-Updater.py +Terminal=false +Type=Application +#Icon= +Categories=Application;Utilities; +MimeType=application/x-executable +EOF + ) "${pkgdir}/usr/share/applications/DM-Firmware-Updater.py.desktop" + set +u +} + +set +u diff --git a/dmupdate.py.usage.patch b/dmupdate.py.usage.patch new file mode 100644 index 000000000000..05cc640a4826 --- /dev/null +++ b/dmupdate.py.usage.patch @@ -0,0 +1,36 @@ +*** dmupdate.py.orig Tue Dec 20 17:11:29 2016 +--- dmupdate.py Tue Dec 20 17:15:37 2016 +*************** +*** 257,268 **** + del args[0] + + if e is None: + e = b + +! host = args[0] +! filename = args[1] + + if not zipfile.is_zipfile(filename): + binfile = open(filename,"rb") + else: + archsuffix = {3:".bin", 5:".nxbin"} +--- 257,275 ---- + del args[0] + + if e is None: + e = b + +! try: +! host = args[0] +! filename = args[1] +! except: +! print "Usage: dmupdate.py [-rqsg] [-b <addr] [-e <addr>] <hostname> <filename>" +! print "filename as .cmtl is preferred. .bin (ARM7) and .nxbin (Cortex-M) also work" +! print "For more help:" +! print "less +96 -S /usr/share/nslink/README.txt" +! sys.exit(1) + + if not zipfile.is_zipfile(filename): + binfile = open(filename,"rb") + else: + archsuffix = {3:".bin", 5:".nxbin"} diff --git a/nslink-install.sh b/nslink-install.sh new file mode 100644 index 000000000000..740dc98dac19 --- /dev/null +++ b/nslink-install.sh @@ -0,0 +1,52 @@ +_tp_config="/etc/nslink.conf" +_tp_configps="${_tp_config}.pacsave" +_tp_config_orig="/usr/share/nslink/nslink.conf.orig" + +post_upgrade() { + set -u + mandb -q + systemctl daemon-reload + # Handle the module update if DKMS doesn't + if [ ! -d /usr/src/nslink-*/ ]; then + depmod -a + if systemctl -q is-enabled 'nslink.service'; then + systemctl start 'nslink.service' + fi + fi + set +u +} + +post_install() { + set -u + if [ -f "${_tp_config}" ] && [ -f "${_tp_configps}" ] && diff -q "${_tp_config}" "${_tp_config_orig}"; then + mv "${_tp_configps}" "${_tp_config}" + fi + set +u + post_upgrade + if systemctl -q is-enabled 'nslink.service' && ! systemctl -q is-active 'nslink.service'; then + # We can't auto start the service because DKMS hasn't made the module yet + echo 'Please start the service with' + echo " systemctl start 'nslink.service'" + fi +} + +pre_upgrade() { + set -u + if [ ! -d /usr/src/nslink-*/ ]; then + systemctl stop 'nslink.service' # also rmmod the module + fi + set +u +} + +pre_remove() { + set -u + systemctl stop 'nslink.service' # pre_upgrade + set +u +} + +post_remove() { + set -u + mandb -q + systemctl daemon-reload + set +u +} diff --git a/nslinktool.systemd.patch b/nslinktool.systemd.patch new file mode 100644 index 000000000000..1d81f560bd8e --- /dev/null +++ b/nslinktool.systemd.patch @@ -0,0 +1,161 @@ +*** nslinktool.orig Tue Dec 20 16:30:33 2016 +--- nslinktool Tue Dec 20 16:30:52 2016 +*************** +*** 980,1001 **** + + def configDriver(self): + ConfigEditor(root,"/etc/nslink.conf") + + def runScript(self,cmdString): +! # figure out where the driver control shellscript is +! scriptPath = None; +! for path in ("/etc/rc.d/init.d/nslink", "/etc/rc.d/nslink", "/etc/init.d/nslink", "/etc/nslink"): +! if os.access(path,os.X_OK): +! scriptPath = path +! break +! if not scriptPath: +! MessageDialogOK(self.root,"\n\nCan't %s the driver\nThe script isn't installed in any of the usual places.\n\n" % cmdString,) +! return +! status,output = commands.getstatusoutput("%s %s" % (scriptPath,cmdString)) +! if status: +! MessageDialogOK(self.root,"\n\n Error trying to %s driver \n\n%s\n\n" % (cmdString,output)) + + def startDriver(self): + self.runScript("start") + self.driverStatus() + +--- 980,990 ---- + + def configDriver(self): + ConfigEditor(root,"/etc/nslink.conf") + + def runScript(self,cmdString): +! commands.getstatusoutput("systemctl %s 'nslink.service'" % (cmdString)) + + def startDriver(self): + self.runScript("start") + self.driverStatus() + +*************** +*** 1006,1046 **** + def restartDriver(self): + self.runScript("restart") + self.driverStatus() + + def findSymlinks(self): +! enabledSymlinks = [] +! disabledSymlinks = [] +! rcDir = None +! for path in ("/etc/rc.d/rc%d.d","/etc/rc%d.d"): +! if os.access(path % 2,os.R_OK): +! rcDir = path +! if not rcDir: +! raise "rcN.d directories not found\nYou must have a non-standard installation" +! else: +! for n in (2,3,4,5): +! path = (rcDir % n) + "/S95nslink" +! if os.access(path,os.R_OK): +! enabledSymlinks.append(path) +! path = (rcDir % n) + "/K05nslink" +! if os.access(path,os.R_OK): +! disabledSymlinks.append(path) + return (enabledSymlinks,disabledSymlinks) + + def disableDriver(self): + try: + enabledLinks,disabledLinks = self.findSymlinks() + if (not enabledLinks) and disabledLinks: + MessageDialogOK(self.root,"\n\n Driver already disabled \n\n") + elif (not enabledLinks) and (not disabledLinks): + MessageDialogOK(self.root,"\n\n Driver symlinks not installed in standard locations \n\n") + else: +! for l in enabledLinks: +! i = string.find(l,"S95nslink") +! if i >= 0: +! nl = l[:i] + "K05" + l[i+3:] +! os.rename(l,nl) + except: + MessageDialogOK(self.root,["\n\n Error disabling driver\n"] + traceback.format_exception_only(sys.exc_type,sys.exc_value)) + self.driverStatus() + + def enableDriver(self): +--- 995,1019 ---- + def restartDriver(self): + self.runScript("restart") + self.driverStatus() + + def findSymlinks(self): +! (disabledSymlinks,enabledSymlinks) = commands.getstatusoutput("systemctl -q is-enabled 'nslink.service'") +! disabledSymlinks = min(1,disabledSymlinks) +! enabledSymlinks = 1-disabledSymlinks +! #print "Enable=%d Disable=%d\n" % (enabledSymlinks,disabledSymlinks) + return (enabledSymlinks,disabledSymlinks) + + def disableDriver(self): + try: + enabledLinks,disabledLinks = self.findSymlinks() + if (not enabledLinks) and disabledLinks: + MessageDialogOK(self.root,"\n\n Driver already disabled \n\n") + elif (not enabledLinks) and (not disabledLinks): + MessageDialogOK(self.root,"\n\n Driver symlinks not installed in standard locations \n\n") + else: +! commands.getstatusoutput("systemctl disable 'nslink.service'") + except: + MessageDialogOK(self.root,["\n\n Error disabling driver\n"] + traceback.format_exception_only(sys.exc_type,sys.exc_value)) + self.driverStatus() + + def enableDriver(self): +*************** +*** 1049,1063 **** + if (not disabledLinks) and enabledLinks: + MessageDialogOK(self.root,"\n\n Driver already enabled \n\n") + elif (not enabledLinks) and (not disabledLinks): + MessageDialogOK(self.root,"\n\n Driver symlinks not installed in standard locations \n\n") + else: +! for l in disabledLinks: +! i = string.find(l,"K05nslink") +! if i >= 0: +! nl = l[:i] + "S95" + l[i+3:] +! os.rename(l,nl) + except: + MessageDialogOK(self.root,["\n\n Error enabling driver \n"] + traceback.format_exception_only(sys.exc_type,sys.exc_value)) + self.driverStatus() + + def driverStatus(self): +--- 1022,1032 ---- + if (not disabledLinks) and enabledLinks: + MessageDialogOK(self.root,"\n\n Driver already enabled \n\n") + elif (not enabledLinks) and (not disabledLinks): + MessageDialogOK(self.root,"\n\n Driver symlinks not installed in standard locations \n\n") + else: +! commands.getstatusoutput("systemctl enable 'nslink.service'") + except: + MessageDialogOK(self.root,["\n\n Error enabling driver \n"] + traceback.format_exception_only(sys.exc_type,sys.exc_value)) + self.driverStatus() + + def driverStatus(self): +*************** +*** 1089,1099 **** + elif disabledLinks and (not enabledLinks): + self.enableStatus.set("Driver startup: disabled") + else: + self.enableStatus.set("Driver startup: unknown") + except: +! self.enableStatus.set("Driver startup: unknown") + + def showHelp(self): + s,o = commands.getstatusoutput(r"(echo '.pl 1000i'; cat /usr/share/man/man8/nslinktool.8; echo '.pl \n(nlu+8') | groff -man -Tascii | col -b | expand") + if s: + MessageDialog("\n\n Error formatting nslinktool man page: \n" + o + "\n\n") +--- 1058,1068 ---- + elif disabledLinks and (not enabledLinks): + self.enableStatus.set("Driver startup: disabled") + else: + self.enableStatus.set("Driver startup: unknown") + except: +! self.enableStatus.set("Driver startup: error") + + def showHelp(self): + s,o = commands.getstatusoutput(r"(echo '.pl 1000i'; cat /usr/share/man/man8/nslinktool.8; echo '.pl \n(nlu+8') | groff -man -Tascii | col -b | expand") + if s: + MessageDialog("\n\n Error formatting nslinktool man page: \n" + o + "\n\n") |