mirror of
https://github.com/gryf/wicd.git
synced 2026-01-04 04:44:12 +01:00
Merge.
This commit is contained in:
13
in/init=lunar=wicd.in
Executable file
13
in/init=lunar=wicd.in
Executable file
@@ -0,0 +1,13 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Startup script for wicd
|
||||||
|
#
|
||||||
|
# chkconfig: 345 99 01
|
||||||
|
#
|
||||||
|
# description: wicd wireless/wired internet connection daemon
|
||||||
|
#
|
||||||
|
# processname: wicd
|
||||||
|
# pidfile: %PIDFILE%
|
||||||
|
#
|
||||||
|
|
||||||
|
. /lib/lsb/init-functions $1
|
||||||
3
setup.py
3
setup.py
@@ -162,6 +162,9 @@ class configure(Command):
|
|||||||
self.initfile = 'init/pld/wicd'
|
self.initfile = 'init/pld/wicd'
|
||||||
elif os.path.exists('/usr/bin/crux'):
|
elif os.path.exists('/usr/bin/crux'):
|
||||||
self.init = '/etc/rc.d/'
|
self.init = '/etc/rc.d/'
|
||||||
|
elif os.path.exists('/etc/lunar.release'):
|
||||||
|
self.init='/etc/init.d/'
|
||||||
|
self.initfile = 'init/lunar/wicd'
|
||||||
else:
|
else:
|
||||||
self.init = 'FAIL'
|
self.init = 'FAIL'
|
||||||
self.no_install_init = True
|
self.no_install_init = True
|
||||||
|
|||||||
19
wicd/misc.py
19
wicd/misc.py
@@ -57,7 +57,7 @@ ROUTE = 2
|
|||||||
GKSUDO = 1
|
GKSUDO = 1
|
||||||
KDESU = 2
|
KDESU = 2
|
||||||
KTSUSS = 3
|
KTSUSS = 3
|
||||||
_sudo_dict = {
|
__sudo_dict = {
|
||||||
AUTO : "",
|
AUTO : "",
|
||||||
GKSUDO : "gksudo",
|
GKSUDO : "gksudo",
|
||||||
KDESU : "kdesu",
|
KDESU : "kdesu",
|
||||||
@@ -171,20 +171,9 @@ def WriteLine(my_file, text):
|
|||||||
""" write a line to a file """
|
""" write a line to a file """
|
||||||
my_file.write(text + "\n")
|
my_file.write(text + "\n")
|
||||||
|
|
||||||
def ExecuteScripts(scripts_dir, verbose=False):
|
def ExecuteScript(script):
|
||||||
""" Execute every executable file in a given directory. """
|
|
||||||
for obj in os.listdir(scripts_dir):
|
|
||||||
obj = os.path.abspath(os.path.join(scripts_dir, obj))
|
|
||||||
if os.path.isfile(obj) and os.access(obj, os.X_OK):
|
|
||||||
ExecuteScript(os.path.abspath(obj), verbose=verbose)
|
|
||||||
|
|
||||||
def ExecuteScript(script, verbose=False):
|
|
||||||
""" Execute a command and send its output to the bit bucket. """
|
""" Execute a command and send its output to the bit bucket. """
|
||||||
if verbose:
|
call("%s > /dev/null 2>&1" % script, shell=True)
|
||||||
print "Executing %s" % script
|
|
||||||
ret = call("%s > /dev/null 2>&1" % script, shell=True)
|
|
||||||
if verbose:
|
|
||||||
"%s returned %s" % (script, ret)
|
|
||||||
|
|
||||||
def ReadFile(filename):
|
def ReadFile(filename):
|
||||||
""" read in a file and return it's contents as a string """
|
""" read in a file and return it's contents as a string """
|
||||||
@@ -411,7 +400,7 @@ def get_sudo_cmd(msg, prog_num=0):
|
|||||||
def choose_sudo_prog(prog_num=0):
|
def choose_sudo_prog(prog_num=0):
|
||||||
""" Try to intelligently decide which graphical sudo program to use. """
|
""" Try to intelligently decide which graphical sudo program to use. """
|
||||||
if prog_num:
|
if prog_num:
|
||||||
return find_path(_sudo_dict[prog_num])
|
return find_path(__sudo_dict[prog_num])
|
||||||
desktop_env = detect_desktop_environment()
|
desktop_env = detect_desktop_environment()
|
||||||
env_path = os.environ['PATH'].split(":")
|
env_path = os.environ['PATH'].split(":")
|
||||||
paths = []
|
paths = []
|
||||||
|
|||||||
@@ -202,12 +202,10 @@ class Controller(object):
|
|||||||
def Disconnect(self, *args, **kargs):
|
def Disconnect(self, *args, **kargs):
|
||||||
""" Disconnect from the network. """
|
""" Disconnect from the network. """
|
||||||
iface = self.iface
|
iface = self.iface
|
||||||
misc.ExecuteScripts(wpath.disconnectscripts, self.debug)
|
if self.disconnect_script != None:
|
||||||
if self.disconnect_script:
|
|
||||||
print 'Running disconnect script'
|
print 'Running disconnect script'
|
||||||
misc.ExecuteScript(expand_script_macros(self.disconnect_script,
|
misc.ExecuteScript(expand_script_macros(self.disconnect_script,
|
||||||
'disconnection', *args),
|
'disconnection', *args))
|
||||||
self.debug)
|
|
||||||
iface.ReleaseDHCP()
|
iface.ReleaseDHCP()
|
||||||
iface.SetAddress('0.0.0.0')
|
iface.SetAddress('0.0.0.0')
|
||||||
iface.FlushRoutes()
|
iface.FlushRoutes()
|
||||||
@@ -336,6 +334,7 @@ class ConnectThread(threading.Thread):
|
|||||||
finally:
|
finally:
|
||||||
self.lock.release()
|
self.lock.release()
|
||||||
|
|
||||||
|
|
||||||
def GetStatus(self):
|
def GetStatus(self):
|
||||||
""" Get the threads current status message in a thread-safe way.
|
""" Get the threads current status message in a thread-safe way.
|
||||||
|
|
||||||
@@ -369,10 +368,6 @@ class ConnectThread(threading.Thread):
|
|||||||
self.SetStatus('interface_down')
|
self.SetStatus('interface_down')
|
||||||
iface.Down()
|
iface.Down()
|
||||||
|
|
||||||
@abortable
|
|
||||||
def run_global_scripts_if_needed(self, script_dir):
|
|
||||||
misc.ExecuteScripts(script_dir, verbose=self.debug)
|
|
||||||
|
|
||||||
@abortable
|
@abortable
|
||||||
def run_script_if_needed(self, script, msg, bssid='wired', essid='wired'):
|
def run_script_if_needed(self, script, msg, bssid='wired', essid='wired'):
|
||||||
""" Execute a given script if needed.
|
""" Execute a given script if needed.
|
||||||
@@ -384,8 +379,7 @@ class ConnectThread(threading.Thread):
|
|||||||
"""
|
"""
|
||||||
if script:
|
if script:
|
||||||
print 'Executing %s script' % (msg)
|
print 'Executing %s script' % (msg)
|
||||||
misc.ExecuteScript(expand_script_macros(script, msg, bssid, essid),
|
misc.ExecuteScript(expand_script_macros(script, msg, bssid, essid))
|
||||||
self.debug)
|
|
||||||
|
|
||||||
@abortable
|
@abortable
|
||||||
def flush_routes(self, iface):
|
def flush_routes(self, iface):
|
||||||
@@ -797,7 +791,6 @@ class WirelessConnectThread(ConnectThread):
|
|||||||
self.is_connecting = True
|
self.is_connecting = True
|
||||||
|
|
||||||
# Run pre-connection script.
|
# Run pre-connection script.
|
||||||
self.run_global_scripts_if_needed(wpath.preconnectscripts)
|
|
||||||
self.run_script_if_needed(self.before_script, 'pre-connection',
|
self.run_script_if_needed(self.before_script, 'pre-connection',
|
||||||
self.network['bssid'], self.network['essid'])
|
self.network['bssid'], self.network['essid'])
|
||||||
|
|
||||||
@@ -840,7 +833,6 @@ class WirelessConnectThread(ConnectThread):
|
|||||||
self.set_dns_addresses()
|
self.set_dns_addresses()
|
||||||
|
|
||||||
# Run post-connection script.
|
# Run post-connection script.
|
||||||
self.run_global_scripts_if_needed(wpath.postconnectscripts)
|
|
||||||
self.run_script_if_needed(self.after_script, 'post-connection',
|
self.run_script_if_needed(self.after_script, 'post-connection',
|
||||||
self.network['bssid'], self.network['essid'])
|
self.network['bssid'], self.network['essid'])
|
||||||
|
|
||||||
@@ -1009,7 +1001,6 @@ class WiredConnectThread(ConnectThread):
|
|||||||
self.is_connecting = True
|
self.is_connecting = True
|
||||||
|
|
||||||
# Run pre-connection script.
|
# Run pre-connection script.
|
||||||
self.run_global_scripts_if_needed(wpath.preconnectscripts)
|
|
||||||
self.run_script_if_needed(self.before_script, 'pre-connection', 'wired',
|
self.run_script_if_needed(self.before_script, 'pre-connection', 'wired',
|
||||||
'wired')
|
'wired')
|
||||||
|
|
||||||
@@ -1028,7 +1019,6 @@ class WiredConnectThread(ConnectThread):
|
|||||||
self.set_dns_addresses()
|
self.set_dns_addresses()
|
||||||
|
|
||||||
# Run post-connection script.
|
# Run post-connection script.
|
||||||
self.run_global_scripts_if_needed(wpath.postconnectscripts)
|
|
||||||
self.run_script_if_needed(self.after_script, 'post-connection', 'wired',
|
self.run_script_if_needed(self.after_script, 'post-connection', 'wired',
|
||||||
'wired')
|
'wired')
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user