summarylogtreecommitdiffstats
path: root/nslinktool.systemd.patch
blob: 1d81f560bd8ee4630a2877364c653feacca6fb86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
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")