Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
fuswim
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sysadmin
fuswim
Commits
d63f8192
Commit
d63f8192
authored
4 years ago
by
root
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working...
parent
042c992b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
6 deletions
+69
-6
fuswim
fuswim
+69
-6
No files found.
fuswim
View file @
d63f8192
#!/usr/bin/env python3
import
iwlist
import
iw_parse
from
pprint
import
pprint
import
psutil
import
sys
from
shell_cmd
import
sh
try
:
from
setproctitle
import
setproctitle
setproctitle
(
"fuswim"
)
except
:
pass
boot
=
False
auto
=
False
def
kill_proc
(
name
,
ops
=
False
):
for
process
in
psutil
.
process_iter
():
if
process
.
name
()
==
name
:
if
ops
:
if
ops
in
process
.
cmdline
():
process
.
kill
()
else
:
process
.
kill
()
def
start_wpa
(
interface
):
kill_proc
(
"dhclient"
,
interface
)
kill_proc
(
"wpa_supplicant"
,
interface
)
sh
(
"/sbin/wpa_supplicant -s -B -P /run/wpa_supplicant."
+
interface
+
".pid -i wlan0 -D nl80211,wext -C /run/wpa_supplicant"
)
if
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
==
'boot'
:
print
(
' * fuswim starts... '
)
boot
=
True
auto
=
True
if
len
(
sys
.
argv
)
>
1
and
sys
.
argv
[
1
]
==
'auto'
:
auto
=
True
interface
=
"wlan0"
if
sys
.
argv
[
-
1
]
not
in
[
'auto'
,
'boot'
,
sys
.
argv
[
0
]]:
interface
=
sys
.
argv
[
-
1
]
if
not
interface
in
psutil
.
net_if_stats
()
.
keys
():
print
(
"Interface "
+
interface
+
" doesn't exists. Exiting..."
)
sys
.
exit
(
1
)
# check for wpa_supplicant
wpas
=
False
for
process
in
psutil
.
process_iter
():
if
process
.
name
()
==
'wpa_supplicant'
:
if
interface
in
process
.
cmdline
():
wpas
=
True
if
not
wpas
:
if
auto
not
boot
:
print
(
"wpa_supplicant for "
+
interface
+
" not running, launch it... "
)
start_wpa
(
interface
)
else
:
print
(
"wpa_supplicant for "
+
interface
+
" not running, exiting... "
)
sys
.
exit
(
1
)
else
:
if
psutil
.
net_if_stats
()[
interface
]
.
isup
:
if
boot
:
print
(
"wpa_supplicant for "
+
interface
+
" already configured, exiting... "
)
sys
.
exit
(
0
)
else
:
print
(
"wpa_supplicant for "
+
interface
+
" already configured, reconfiguring it"
)
start_wpa
(
interface
)
else
:
print
(
"wpa_supplicant for "
+
interface
+
" already configured, reconfiguring it"
)
start_wpa
(
interface
)
from
pprint
import
pprint
netw
=
iw_parse
.
get_interfaces
(
interface
=
"wlan0"
)
pprint
(
netw
)
# detect all networks...
#netw = iw_parse.get_interfaces(interface="wlan0")
#pprint(netw)
#networks = iwlist.parse(iwlist.scan('wlan0'))
#pprint(networks)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment