mirror of
https://github.com/gryf/wicd.git
synced 2025-12-31 02:52:29 +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'
|
||||
elif os.path.exists('/usr/bin/crux'):
|
||||
self.init = '/etc/rc.d/'
|
||||
elif os.path.exists('/etc/lunar.release'):
|
||||
self.init='/etc/init.d/'
|
||||
self.initfile = 'init/lunar/wicd'
|
||||
else:
|
||||
self.init = 'FAIL'
|
||||
self.no_install_init = True
|
||||
|
||||
19
wicd/misc.py
19
wicd/misc.py
@@ -57,7 +57,7 @@ ROUTE = 2
|
||||
GKSUDO = 1
|
||||
KDESU = 2
|
||||
KTSUSS = 3
|
||||
_sudo_dict = {
|
||||
__sudo_dict = {
|
||||
AUTO : "",
|
||||
GKSUDO : "gksudo",
|
||||
KDESU : "kdesu",
|
||||
@@ -171,20 +171,9 @@ def WriteLine(my_file, text):
|
||||
""" write a line to a file """
|
||||
my_file.write(text + "\n")
|
||||
|
||||
def ExecuteScripts(scripts_dir, verbose=False):
|
||||
""" 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):
|
||||
def ExecuteScript(script):
|
||||
""" Execute a command and send its output to the bit bucket. """
|
||||
if verbose:
|
||||
print "Executing %s" % script
|
||||
ret = call("%s > /dev/null 2>&1" % script, shell=True)
|
||||
if verbose:
|
||||
"%s returned %s" % (script, ret)
|
||||
call("%s > /dev/null 2>&1" % script, shell=True)
|
||||
|
||||
def ReadFile(filename):
|
||||
""" 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):
|
||||
""" Try to intelligently decide which graphical sudo program to use. """
|
||||
if prog_num:
|
||||
return find_path(_sudo_dict[prog_num])
|
||||
return find_path(__sudo_dict[prog_num])
|
||||
desktop_env = detect_desktop_environment()
|
||||
env_path = os.environ['PATH'].split(":")
|
||||
paths = []
|
||||
|
||||
@@ -202,12 +202,10 @@ class Controller(object):
|
||||
def Disconnect(self, *args, **kargs):
|
||||
""" Disconnect from the network. """
|
||||
iface = self.iface
|
||||
misc.ExecuteScripts(wpath.disconnectscripts, self.debug)
|
||||
if self.disconnect_script:
|
||||
if self.disconnect_script != None:
|
||||
print 'Running disconnect script'
|
||||
misc.ExecuteScript(expand_script_macros(self.disconnect_script,
|
||||
'disconnection', *args),
|
||||
self.debug)
|
||||
'disconnection', *args))
|
||||
iface.ReleaseDHCP()
|
||||
iface.SetAddress('0.0.0.0')
|
||||
iface.FlushRoutes()
|
||||
@@ -336,6 +334,7 @@ class ConnectThread(threading.Thread):
|
||||
finally:
|
||||
self.lock.release()
|
||||
|
||||
|
||||
def GetStatus(self):
|
||||
""" Get the threads current status message in a thread-safe way.
|
||||
|
||||
@@ -369,10 +368,6 @@ class ConnectThread(threading.Thread):
|
||||
self.SetStatus('interface_down')
|
||||
iface.Down()
|
||||
|
||||
@abortable
|
||||
def run_global_scripts_if_needed(self, script_dir):
|
||||
misc.ExecuteScripts(script_dir, verbose=self.debug)
|
||||
|
||||
@abortable
|
||||
def run_script_if_needed(self, script, msg, bssid='wired', essid='wired'):
|
||||
""" Execute a given script if needed.
|
||||
@@ -384,8 +379,7 @@ class ConnectThread(threading.Thread):
|
||||
"""
|
||||
if script:
|
||||
print 'Executing %s script' % (msg)
|
||||
misc.ExecuteScript(expand_script_macros(script, msg, bssid, essid),
|
||||
self.debug)
|
||||
misc.ExecuteScript(expand_script_macros(script, msg, bssid, essid))
|
||||
|
||||
@abortable
|
||||
def flush_routes(self, iface):
|
||||
@@ -797,7 +791,6 @@ class WirelessConnectThread(ConnectThread):
|
||||
self.is_connecting = True
|
||||
|
||||
# Run pre-connection script.
|
||||
self.run_global_scripts_if_needed(wpath.preconnectscripts)
|
||||
self.run_script_if_needed(self.before_script, 'pre-connection',
|
||||
self.network['bssid'], self.network['essid'])
|
||||
|
||||
@@ -840,7 +833,6 @@ class WirelessConnectThread(ConnectThread):
|
||||
self.set_dns_addresses()
|
||||
|
||||
# Run post-connection script.
|
||||
self.run_global_scripts_if_needed(wpath.postconnectscripts)
|
||||
self.run_script_if_needed(self.after_script, 'post-connection',
|
||||
self.network['bssid'], self.network['essid'])
|
||||
|
||||
@@ -1009,7 +1001,6 @@ class WiredConnectThread(ConnectThread):
|
||||
self.is_connecting = True
|
||||
|
||||
# Run pre-connection script.
|
||||
self.run_global_scripts_if_needed(wpath.preconnectscripts)
|
||||
self.run_script_if_needed(self.before_script, 'pre-connection', 'wired',
|
||||
'wired')
|
||||
|
||||
@@ -1028,7 +1019,6 @@ class WiredConnectThread(ConnectThread):
|
||||
self.set_dns_addresses()
|
||||
|
||||
# Run post-connection script.
|
||||
self.run_global_scripts_if_needed(wpath.postconnectscripts)
|
||||
self.run_script_if_needed(self.after_script, 'post-connection', 'wired',
|
||||
'wired')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user