Closed wdlkmpx closed 6 years ago
On Sat, 01 Oct 2016 20:36:42 -0700 wdlkmpx notifications@github.com wrote:
i might revise my netwiz version again, but i'm not sure if i'll be able to go throgh all of that again, it's brain damaging. but what do you think?
LOL. I couldn't do what you did (go through 5000 lines of netwiz code) - so I decided to write a replacement that would handle all the use cases that network-wizard does.
I call it "network-setup.sh". It's uses "dialog", so it can be used in either terminal only or in urxvt (I personally feel it's unfortunate if you can setup network only when GUI is available). It's not pretty but its functional, does everything that network-wizard does including static IP and configuring wired ethernet, auto-reconnect and updates IP address when connection is lost/restored, etc; all in about 900 lines (including comments). Oh and it uses tab indentation (tabstop=4) too for your sanity. Thanks to L18L, it has been i18n-ed too.
Let me know if you're interested.
On Sat, 01 Oct 2016 21:18:36 -0700 ninaholic notifications@github.com wrote:
I think Dougal's is based off SNS
No, network wizard was originally created by rarsa, and then enhanced by Dougal. SNS was created by Barry much later (I hazard a guess for the same reason: that he didn't want to go through the 5000 lines of network-wizard code).
I never use netwiz....I use sns if I'm doing a quick temporary setup on a new install for testing or compilation......for permanent long-term installs I use Frisbee - but I wouldn't get rid of netwiz - keep all three please.
Wouldn't it be smart to add @wdlkmpx netwiz code to the rationalise branch so it gets wider testing?
Do we need more than 1 connection tool for eth/wifi? Rerwin is updating frisbee, you netwiz, but sns is still the simple option. What works, and what code is maintainable?
Well, i first removed about 1000 lines, but as i was applying my ideas and code all those lines came back. My netwiz has two modes: wizard and automatic, in the automatic mode it behaves like frisbee trying to connect from any interface available and showing splashes.. berserk mode. that's why i don't use frisbee or sns, because i already made Netwiz do everything i want.
As a service it behaves like frisbee if it's not configured to use a specific interface. I guess i can remove some stuff and simplify it a bit, but i'm not sure, what jamesbond suggests also seems reasonable
I meant "also". I put all the scripts in /usr/local/netwiz, and symlinks to those files /etc/ /usr/. probably wagprofiles.sh is the heavily "bloated" script. the netwiz has even code for pcmcia, even stuff related to firewire. there's another dialog for Prism Wireless, i'm not sure why
I guess i should have a look at jamesbod's script
Line count, including some random experiments
123 /usr/local/netwiz/common_funcs 61 /usr/local/netwiz/ifplugd 145 /usr/local/netwiz/net-setup.sh 2039 /usr/local/netwiz/netwiz 692 /usr/local/netwiz/rc.network 78 /usr/local/netwiz/rc.network.keepalive 2152 /usr/local/netwiz/wag-profiles.sh 37 /usr/local/netwiz/wpa_cli 35 /usr/local/netwiz/x_start
5362 total
My 5000 linecount was based on netwiz + wag-profiles.sh + rc.network.
Here's mine: https://gist.github.com/jamesbond3142/1f0fe31868fc1f11fb2cd734b3cbb3d1 I couldn't get github to display tabs with tabsetting=4 (it always shows 8 spaces), but cut and paste it into geany and the indentation will align together.
Notes about it:
start_wired_autodhcp() {
local TIMEOUT=15 # 15 seconds timeout
while [ $TIMEOUT -ge 0 ]; do
#echo auto_dhcp $TIMEOUT
for IFACE in $(ls /sys/class/net); do case $IFACE in
lo|teredo) ;; # ignore
*)
if ! iwconfig | grep -q "^$IFACE"; then # not wireless
# start dhcp, but only if not configured by network wizard/network-setup
read ADDR < /sys/class/net/$IFACE/address
if ! [ -f /etc/network-setup/ip/$IFACE ] &&
! [ -f /etc/network-wizard/network/interfaces/$ADDR.conf ]; then
ifconfig $IFACE up >/dev/null; ifconfig $IFACE | grep -q UP || continue
echo auto dhcp for $IFACE
dhcpcd -q -L -h $(hostname) $IFACE &
else
echo $IFACE will be configured by network-wizard
fi
break 2
fi
esac; done
TIMEOUT=$((TIMEOUT-1))
sleep 1
done
}
It's quite interesting, i'll take a close look to see if i can replace netwiz stuff with it. Netwiz uses iwconfig and wlanctl (prism usb).. i guess wlanctl is a no-no nowadays.
I have a modded network wizard which works in cli mode, even automatic cli mode. It was my first attempt at editing network wizard, i used to type "networkwizard -auto" when connection went down (there was no reconnection). that was before i knew rc.network belongs to the same package, and that was the script to edit. it was also clear that net-setup and wagprofiles are one package, because they depend on each other. it's complicated. this the output:
(NW) Processing eth0
eth0 Ethernet via-rhine pci VIA Technologies VT6102 RhineII
Testing eth0 interface... UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 X eth0: Found a live network. You can proceed to acquire an IP address.
There may be a delay of up to 60 seconds while Puppy waits for the server to respond. Please wait patiently...
dhcpcd[23774]: version 6.7.1-dropwait starting .....
I see the is_valid_ipv4 function. I remember netwiz used to call a couple obscure apps, and this is the code i replace the ip stuff with, code i found somewhere of course:
function ip2dec() { #ip to decimal
local a b c d ip=$@
IFS=. read -r a b c d <<< "$ip"
printf '%d\n' "$((a * 256 ** 3 + b * 256 ** 2 + c * 256 + d))" #return value
}
function validip() { #replace dotquad.c to parse $1 as a dotted-quad IP address
local ip=$1
local stat=1
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
OIFS=$IFS
IFS='.'
ip=($ip)
IFS=$OIFS
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
stat=$?
fi
[ $stat -eq 0 ] && ip2dec $1 #return decimal
return $stat
} #end of validip function
Yess. After a few tweaks, the script is working now, but partially. It shows all the dialogs and everything seems ok, except wireless connections. Apparently puppy is a bit different. despite using the correct commands and all, there's something that doesn't work. Netwiz does produce a successfull connection, so it has to be an hybrid i guess. Meanwhile these are the numbers:
122 common_funcs 61 ifplugd 121 net-setup.sh 1888 netwiz 585 rc.network 78 rc.network.keepalive 1793 wag-profiles.sh 37 wpa_cli 35 x_start 4720 total
So in the end there will be cli and gui network wizard, both using the same base, at least that's my plan..
Oh man the key to make the cli app work was to understand network wizard, by copying a few lines and changing a few things, now i have wireless connection completely configured with the agent's script.
What i like about dougal's work despide being incredibly complicated, is that he made everything work with functions, everything was a function, otherwise it would be impossible to simplify this.. but by removing about 1400 lines, now it's easier to understand.
Now i have two implementations working fine... by taking the best bits of both - adding more common_funcs, hopefully this can be heavily simplified for a gui/cli experience.. we're going out of the matrix https://www.youtube.com/watch?v=YHyF4ZljapI
the numbers including the lang file file that was in /usr/share/locale:
124 common_funcs 46 ifplugd 429 net-setup.mo 19 net-setup.sh 877 netwiz.cli 1122 netwiz.gui 511 netwiz.gui.extra 558 rc.network 1537 wag-profiles.sh 19 wpa_cli 23 x_start
5265 total
If you like (and I mean - if you really like), I can take a round with the gui when things settles... I know you are capable of doing this yourself - just want to help out here. I like the idea of simplifying the connection code - both for the user and for the developer.
The challenge is that I only got wireless myself
Thanks for the offering, i converted most dialogs to the woofce style, some may some extra touches, we'll see when it's done. The script had a bunch of simple dialogs, that i replaced with box_yesno, box_no, box_splash.. and about 800 lines were gone. I have some more changes for box_yesno to push
I see room for improvements and creation of new gtkdialog scripts to emulate the yad one-liners, maybe "filechooser" with some of these switches https://github.com/puppylinux-woof-CE/woof-CE/blob/2f65017f39415c575f5e799ebc4e760301fc7554/woof-code/rootfs-skeleton/usr/lib/gtkdialog/box_yesno
This is the inspiration: http://rpm.pbone.net/index.php3/stat/45/idpl/17003956/numer/1/nazwa/yad
I really to plan to make it quite simple, maybe applying a global rule: dhcp or static ip, and so on, to make things straightforward. it will take a week probably, i usually learn while editing, that's my style. while testing i also come to some conclusions, why and how, things start to make sense.
The are the numbers:
213 common_funcs 46 ifplugd 419 net-setup.mo 20 net-setup.sh 810 netwiz.cli 1041 netwiz.gui 490 netwiz.gui.extra 470 rc.network 1380 wag-profiles.sh 19 wpa_cli 23 x_start
4931 total
I broke the wagprofiles stuff and got rid of it. The gui is able to connect only through wired ethernet devices (dhcp, static) at the moment, but the cli works with both wired and wireless, DHCP and static. I guess the final result will be an hybrid between Network wizard, fatdog's net-setup and SNS. Basically the gui design, extra stuff, DHCP, Static IP setup and a few more routines are from net wiz. Now the gui has extra buttons: one to enable/disable and configure a static ip, another for profiles (to be implemented as simple as possible.. maybe only to delete? just like SNS). and Options, for miscellaneous options, probably not needed?.
The cli, wireless stuff and profiles are from network-setup.sh. The eye candy and the idea of simplicity to simply connect and generate a profile afterwards is from SNS.
Closing this.
I still have my simplified, fixed and cool cli/gui net-setup, but i haven't finished (fixing) the GUI yet (maybe some day i will), as i've been busy doing & fixing many other things, but that's another issue
What do you think?
The default connect app should have always been Network Wizard. I opened a thread about a possible update: http://murga-linux.com/puppy/viewtopic.php?t=105658
and posted some images: https://postimg.org/gallery/1b0czsfv4/
since then, i added a few changes, one of them was cloning the SNS wireless dialog. Network wizard is huge, all the "default" effort should have gone to that app.. my idea is kill SNS and have NetWiz and Frisbee as the only connect apps for Wired or wireless lan, i might revise my netwiz version again, but i'm not sure if i'll be able to go throgh all of that again, it's brain damaging. but what do you think?