Skip to content

Commit

Permalink
Merge pull request #1576 from rern/UPDATE
Browse files Browse the repository at this point in the history
Update
  • Loading branch information
rern authored Jan 22, 2024
2 parents fd259b7 + b4dadc0 commit 9adf23c
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 45 deletions.
3 changes: 1 addition & 2 deletions srv/http/assets/css/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

@font-face {
font-family : rern;
src : url( '/assets/fonts/rern.woff2?v=1705839327' );
src : url( '/assets/fonts/rern.woff2?v=1705850359' );
}
@font-face {
font-family : Lato;
Expand All @@ -32,7 +32,6 @@ i {
}
.i-22 { font-size: 22px !important }
.i-30 { font-size: 30px !important }
.i-accesspoint::before { content: '\F554' }
.i-add::before { content: '\F519' }
.i-addons::before { content: '\F50D' }
.i-airplay::before { content: '\F580' }
Expand Down
43 changes: 26 additions & 17 deletions srv/http/assets/js/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,22 +306,14 @@ $( '#setting-bluetooth' ).on( 'click', function() {
} );
} );
$( '#setting-wlan' ).on( 'click', function() {
bash( [ 'regdomlist' ], list => {
info( {
icon : SW.icon
, title : SW.title
, list : [
[ 'Country', 'select', list ]
, [ 'Auto start Access Point', 'checkbox' ]
]
, boxwidth : 250
, values : S.wlanconf || default_v.wlan
, checkchanged : S.wlan
, beforeshow : () => selectText2Html( { '00': '00 <gr>(allowed worldwide)</gr>' } )
, cancel : switchCancel
, ok : switchEnable
} );
}, 'json' );
if ( V.regdomlist ) {
infoWlan();
} else {
bash( [ 'regdomlist' ], list => {
V.regdomlist = list;
infoWlan();
}, 'json' );
}
} );
$( '#divi2smodulesw' ).on( 'click', function() {
setTimeout( i2sOptionSet, 0 );
Expand Down Expand Up @@ -816,7 +808,7 @@ function infoMirrorList() {
function infoMount( nfs ) {
var nfs = nfs || false;
var shareddata = SW.id === 'shareddata';
var values = default_v.mountcifs;
var values = nfs ? default_v.mountnfs : default_v.mountcifs;
values.IP = S.ipsub;
var tab = nfs ? [ infoMount, '' ] : [ '', () => infoMount( 'nfs' ) ];
if ( shareddata ) tab.push( infoMountRserver );
Expand Down Expand Up @@ -1097,6 +1089,23 @@ function infoRestore( reset ) {
} );
$( '#restore' ).prop( 'checked', 0 );
}
function infoWlan() {
var autostart = 'Auto start Access Point<br> &emsp; &emsp; <gr>(if not connected)</gr>';
info( {
icon : SW.icon
, title : SW.title
, list : [
[ 'Country', 'select', V.regdomlist ]
, [ autostart, 'checkbox' ]
]
, boxwidth : 250
, values : S.wlanconf || default_v.wlan
, checkchanged : S.wlan
, beforeshow : () => selectText2Html( { '00': '00 <gr>(allowed worldwide)</gr>' } )
, cancel : switchCancel
, ok : switchEnable
} );
}
function renderPage() {
$( '#divsystem .value' ).html( S.system );
$( '#divstatus .value' ).html( S.status + S.warning );
Expand Down
2 changes: 1 addition & 1 deletion srv/http/bash/settings/networks-data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ data='
, "ap" : '$( exists $dirsystem/ap )'
, "apconf" : '$apconf'
, "camilladsp" : '$( exists $dirsystem/camilladsp )'
, "connectedwl" : '$( netctl list | grep -q -m1 ^* && echo true )'
, "connectedwl" : '$( [[ $( iwgetid -r $wlandev ) ]] && echo true )'
, "gateway" : "'$gateway'"
, "hostname" : "'$( getContent $dirshm/avahihostname )'"
, "ipeth" : "'$ipeth'"
Expand Down
55 changes: 49 additions & 6 deletions srv/http/bash/settings/networks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@ netctlSwitch() {
local active connected ssid wlandev
ssid=$1
wlandev=$( < $dirshm/wlan )
connected=$( iwgetid $wlandev -r )
# iwctl station $wlandev disconnect
# iwctl station $wlandev connect "$ssid"
connected=$( iwgetid -r $wlandev )
ip link set $wlandev down
netctl switch-to "$ssid"
for i in {1..10}; do
sleep 1
# if [[ $( iwgetid $wlandev -r ) == $connected ]]; then
if netctl is-active "$ssid" &> /dev/null; then
[[ $connected ]] && netctl disable "$connected"
netctl enable "$ssid"
Expand All @@ -27,7 +24,6 @@ netctlSwitch() {
$dirsettings/networks-data.sh pushwl
else
echo -1
# [[ $connected ]] && iwctl station $wlandev connect "$connected"
[[ $connected ]] && netctl switch-to "$connected"
fi
}
Expand Down Expand Up @@ -102,15 +98,44 @@ Hidden=yes'
else
pushRefresh
fi

# wlandev=$( < $dirshm/wlan )
# iwctl station wlan0 scan "$SSID"
# [[ $HIDDEN ]] && connect=connect-hidden || connect=connect
# if [[ $ADDRESS ]]; then # static
# file="/var/lib/iwd/$SSID."
# if [[ $KEY ]]; then
# file+=psk
# data='[Security]
#Passphrase="'$KEY'"'
# else
# file+=open
# fi
# data+="\
#[IPv4]
#Address=$ADRESS
#Gateway=$GATEWAY
#" > "$file"
# iwctl station $wlandev $connect "$SSID"
# elif [[ $KEY ]]; then
# iwctl station $wlandev $connect "$SSID" --passphrase $KEY
# else # open
# iwctl station $wlandev $connect "$SSID"
# fi
# avahi-daemon --kill # flush cache and restart
# pushRefresh
;;
disconnect )
wlandev=$( < $dirshm/wlan )
connected=$( iwgetid $wlandev -r )
connected=$( iwgetid -r $wlandev )
netctl stop "$connected"
netctl disable "$connected"
systemctl stop wpa_supplicant
ip link set $wlandev up
$dirsettings/networks-data.sh pushwl

# iwctl station $wlandev disconnect
# $dirsettings/networks-data.sh pushwl
;;
lanedit )
if [[ $IP ]]; then
Expand Down Expand Up @@ -144,9 +169,24 @@ profileconnect )
sleep 2
fi
netctlSwitch "$SSID"

# wlandev=$( < $dirshm/wlan )
# [[ -e $dirsystem/ap ]] && rm -f $dirsystem/{ap,ap.conf} && systemctl restart iwd
# file=$( ls "/var/lib/iwd/$SSID".* )
# grep -q ^Hidden "$file" && connect=connect-hidden || connect=connect
# iwctl station $wlandev $connect "$SSID"
;;
profileget )
conf2json "/etc/netctl/$SSID"

# file=$( ls "/var/lib/iwd/$SSID".* )
# . <( grep -E '^Add|^Hid|^Pas' "$file" )
# echo '{
# "Address" : "'$Address'"
# , "Hidden" : "'$Hidden'"
# , "type" : "'${file/*.}'"
# , "Passphrase" : "'$Passphrase'"
#}'
;;
profileremove )
netctl is-enabled "$SSID" && netctl disable "$SSID"
Expand All @@ -158,6 +198,9 @@ profileremove )
fi
rm "/etc/netctl/$SSID"
$dirsettings/networks-data.sh pushwl

# iwctl known-networks "$SSID" forget
# $dirsettings/networks-data.sh pushwl
;;
scankill )
killProcess networksscan
Expand Down
28 changes: 9 additions & 19 deletions srv/http/bash/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,10 @@ echo mpd > $dirshm/player

lsmod | grep -q -m1 brcmfmac && touch $dirshm/onboardwlan # initial status

# wait for lan connection
connectedCheck 5
# if lan not connected and enabled wifi profile available, wait for wi-fi connection
if [[ ! $ipaddress && $wlandev ]]; then
readarray -t netctllist <<< $( netctl list | sed -E 's/^. //' )
if [[ $netctllist ]]; then
for profile in "${netctllist[@]}"; do
[[ $( netctl is-enabled "$profile" ) == enabled ]] && enabledprofile=1 && break
done
[[ $enabledprofile ]] && connectedCheck 30
fi
# wait for connection
connectedCheck 5 # lan
if [[ ! $ipaddress && $wlandev ]]; then # if lan not connected and wlan exists
ls -d /etc/systemd/system/netctl* &> /dev/null && connectedCheck 30 # wlan
fi

[[ -e $dirsystem/ap ]] && ap=1
Expand Down Expand Up @@ -121,8 +114,9 @@ if [[ $ipaddress ]]; then
avahi-resolve -a4 $ipaddress | awk '{print $NF}' > $dirshm/avahihostname
$dirsettings/addons-data.sh &> /dev/null &
else
[[ -e $filebootwifi ]] && mv /boot/wifi{,X}
if [[ $wlandev && ! $ap ]]; then
if [[ $netctllist ]]; then
if [[ $( netctl list ) ]]; then
[[ ! -e $dirsystem/wlannoap ]] && ap=1
else
ap=1
Expand Down Expand Up @@ -175,15 +169,11 @@ elif [[ -e $dirmpd/updating ]]; then
elif [[ -e $dirmpd/listing ]]; then
$dirbash/cmd-list.sh &> /dev/null &
fi
# if no wlan // usb wlan // no access point and no connected wlan, disable wlan
# usb wlan || no wlan || not ap + not connected
if (( $( rfkill | grep -c wlan ) > 1 )) \
|| ! rfkill | grep -q wlan \
|| ( [[ ! -e $dirsystem/ap ]] && ! netctl list | grep -q -m1 ^* ); then
rmmod brcmfmac_wcc &> /dev/null
rmmod brcmfmac &> /dev/null
onboardwlan=false
else
onboardwlan=true
|| [[ ! -e $dirsystem/ap && ! $( iwgetid -r $wlandev ) ]]; then
rmmod brcmfmac_wcc brcmfmac &> /dev/null
fi

if [[ $restorefailed ]]; then
Expand Down

0 comments on commit 9adf23c

Please sign in to comment.