sbp wrote: 
> Thanks, you are absolutely right. 
> The SSH piCoreplayer script has been neglected for some time, as I have
> been focused on the web-GUI stuff.  Therefore, I have not added the
> functionality of saving changes made by the SSH script to the config.cfg
> file - so as you describe changes will not survive a reboot.  I will be
> happy if you have the time to look into this and I would be happy to
> incorporate these changes into the new piCorePlayer. At some time I was
> thinking that we didn't need the piCorePlayer script anymore, but
> actually I think we need both a web-GUI and a SSH script? 
> 

Hello Steen.  Weekend gave me some time to tinker with this.  I was
hoping for something a little more elegant, but the processing
capabilities of AWK embraced in the wifi.sh script and the SED escape
characters used in ivySox were mind numbing.  I took the logic from each
and produced a smashup.  Hopefully should make future maintenance easier
if either of those sources drift.

To provide synchronization between /usr/local/sbin/config.cfg and
/home/tc/wifi.db I would propose a new script and modification to the
existing /usr/local/sbin/picoreplayer script.

1) create a new shell script, set_wifi.sh, in /usr/local/sbin
containing:

Code:
--------------------
    #!/bin/sh
  
  alias awk="busybox awk"
  
  CONFIG=/usr/local/sbin/config.cfg
  
  read TCUSER < /etc/sysconfig/tcuser
  DB=/home/"$TCUSER"/wifi.db
  
  set -- $(echo "" | awk -v dbfile="$DB" '
  BEGIN {
  getline dbitem < dbfile
  split(dbitem,field,"\t")
  ssid = field[1]
  passwd = field[2]
  enc = field[3]
  close(dbfile)
  }
  END {
  print("\"" ssid "\"")
  print("\"" passwd "\"")
  print("\"" enc "\"")
  
  } ' )
  
  sudo sed -i "s/\(SSID *=*\).*/\1$1/" $CONFIG
  sudo sed -i "s/\(PASSWORD *=*\).*/\1$2/" $CONFIG
  sudo sed -i "s/\(ENCRYPTION *=*\).*/\1$3/" $CONFIG
  
--------------------


2) Modify /usr/local/sbin/picoreplayer to invoke the new script in
option 8 logic.

Code:
--------------------
    
  Just a snippet of original script
  
  "8")
  echo "Setup WiFi"
  rm -f /home/tc/wifi.db
  sudo ifconfig wlan0 down
  sudo sleep 1
  sudo ifconfig wlan0 up
  sudo sleep 1
  sudo /usr/local/bin/wifi.sh
  #add the following line
  sudo /usr/local/sbin/set_wifi.sh
  #
  sudo filetool.sh -b
  echo "  "
  echo "  "
  ;;
  
--------------------



If needed, I can probably create the DIFF if you use that.  Let me know
if this will work for you.


------------------------------------------------------------------------
mcdudeabides's Profile: http://forums.slimdevices.com/member.php?userid=57765
View this thread: http://forums.slimdevices.com/showthread.php?t=97803

_______________________________________________
unix mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/unix

Reply via email to