• 0
Votes
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 195

Backtrace:

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/views/question.php
Line: 195
Function: _error_handler

File: /home/u125378470/domains/lawhelpguru.org/public_html/application/controllers/Questions.php
Line: 416
Function: view

File: /home/u125378470/domains/lawhelpguru.org/public_html/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

How to add only missing parameters to config file?

I am working with OpenWRT config file. One of my config file is like,

File 1:

config wifi1
 option enable  '1'
 option status ''
 option ssid ''

File 2:

config wifi1
  option enable '1'
  option status ''
  option ssid 'Primary5G'
  option password '12345678'

File1 is my default file, File2 is runtime generated file. In case if we add more parameters to File1. For example,

File1 Modified,

config wifi1
  option enable '1'
  option status ''
  option ssid ''
  option wps '1'

I need to merge these files, copy the missing parameters content into File2, without overwriting the existing modified parameters. So the File2 should be like,

config wifi1
  option enable '1'
  option status ''
  option ssid 'Primary5G'
  option password '12345678'
  option wps '1'

I need to do this shell script for merging the content. I tried to use diff and patch for obtaining the output required.

I tried with below commands,

diff file1 file2 > diffs

This diffs has all the modifications, which I don't require. If this could have worked, thought of applying this patch using,

patch -i diffs file2

But it is overwriting the existing parameters as well. And I can't use pattern because we have have multiple parameters going forward. Any help?

Sample file will be like,

config  wifi-device     'radio0'
  option    type        'mac80211'
  option    channel     '104'
  option    hwmode      '11a'
  option    path        'pci0000:00/0000:00:00.0'
  option    htmode      'HT20'
  option    country     'DE'

config  wifi-iface
  option    device      'radio0'
  option    network     'lan'
  option    mode        'ap'
  option    ssid        'OpenWrt'
  option    encryption  'none'