Friday, February 10, 2023

bash script strategies

 I did a fair amount of bash scripting for a recent project to provide support for managing an ecosystem of docker containers, java applications, and javascript server, including some low-level utility scripts that are shared by higher-level scripts. 

In the process, I realized that it would be helpful to develop and follow some rules and patterns because otherwise it would be easy to have different solutions to the same problem in different places in code that is already difficult to read and understand. 

To that end, I decided to create a document on the project wiki to describe my current thinking and approach on various aspects of bash script development (portability, defining variables, command substitution, passing and receiving parameters between scripts, testing conditions, checking results of commands, console output, ...) so that I can refer back to it and extend it when I have similar work to do in the future.

Wednesday, February 8, 2023

disable App Store notifications on MacOS

I get an App Store notification on my MacBook literally every time I use it.  The sound makes my dogs go crazy, because it's the same noise as the camera on the front door bell.  Of course in true Apple fashion, there is no "App Store" notification setting on "System Preferences".  The only "solution" I can find is to allegedly disable notifications until some future date.  E.g. open Terminal and enter something like this:


defaults write com.apple.appstored LastUpdateNotification -date "2099-12-12 12:00:00 +0000"


Friday, February 25, 2022

mysql stored function with recursive query

I recently had a requirement for an advanced search/filter mechanism for an entity in a JSF application outside the scope of the relevant database entity's regular attributes.  It required a recursive query, as the database table represents a hierarchy of the items that it contains.  Our database backend is mysql/mariadb 8.

I decided to use a mysql stored function for the recursive query because I wanted to use the query from arbitrary SQL in contexts than the original requirement.  I have used recursive queries or stored functions in mysql before, so I just wanted to document my approach here for future reference.

I found the following links helpful:

The recursive part of the query looks like this:

WITH RECURSIVE ancestors as ( 
     SELECT parent_item_id FROM item_element WHERE parent_item_id in ( 
          SELECT parent_item_id FROM item_element WHERE id in ( 
                 SELECT first_item_element_id  
           FROM item_element_relationship ier  
           WHERE ier.relationship_type_id = 4 AND  
        second_item_element_id = item_self_element_id)) 

     UNION  

           SELECT ie.parent_item_id  
           FROM item_element ie, ancestors AS a  
           WHERE ie.contained_item_id1 = a.parent_item_id 

) SELECT count(i.name)  
INTO row_count  
FROM item i, ancestors  
WHERE i.id = ancestors.parent_item_id and i.name like name_filter_value;

The first part of the query (before the union) is the "anchor".  It is executed first and selects the elements that for the cable's direct endpoint machine design items.  The "recursive part" (after the union) is executed repeatedly until it returns no new data.

The function accepts parameters for the name filter value, and an optional specification of cable end for constraining the result to one end of the cable or the other.  Example queries look like this:

-- don't constrain cable end, matches any name against any device ancestor
select * from item where domain_id = 9 and cable_design_ancestor_filter(id, 'DLMA', '');

-- constrain matches by cable end (1 or 2)
select * 
from item 
where domain_id = 9 
and cable_design_ancestor_filter(id, 'Rack 01-01', '1') 
and cable_design_ancestor_filter(id, 'DLMA', '2');

Also worth documenting here is the mechanism for calling a stored function from JPA.  This is done by using "FUNCTION()" in the SQL statement, as is shown in these two named query examples:

@NamedQueries({

    @NamedQuery(name = "ItemDomainCableDesign.filterAncestorAny",

            query = "SELECT i FROM Item i WHERE i.domain.name = :domainName AND FUNCTION('cable_design_ancestor_filter', i.id, :nameFilterValue, '')"),

    @NamedQuery(name = "ItemDomainCableDesign.filterAncestorByEnd",

            query = "SELECT i FROM Item i WHERE i.domain.name = :domainName AND FUNCTION('cable_design_ancestor_filter', i.id, :end1Value, '1') AND FUNCTION('cable_design_ancestor_filter', i.id, :end2Value, '2')")

})

Here is the full code of the stored function. One thing I tried to avoid was that there are two separate recursive queries for the conditional cases where cable end either is or is not specified.  I was unable to find a solution using a stored procedure or by concatenating strings to form the query, but I'm guessing there must be a way...

DROP FUNCTION IF EXISTS cable_design_ancestor_filter// 
CREATE FUNCTION cable_design_ancestor_filter 
(cable_item_id INT, 
name_filter_value VARCHAR(64), 
cable_end VARCHAR(64)) 
RETURNS BOOLEAN 
BEGIN  
DECLARE row_count INT; 
DECLARE item_self_element_id INT; 

-- check that cable_item_id is specified
IF ISNULL(cable_item_id)
THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'cable item id must be specified';
END IF;

-- add % to both ends of filter value 
IF ISNULL(name_filter_value) OR name_filter_value = ''
THEN
RETURN true;
END IF;
SET name_filter_value = CONCAT('%', name_filter_value); 
SET name_filter_value = CONCAT(name_filter_value, '%');

-- get self element id for cable design item 
SELECT self_element_id INTO item_self_element_id FROM v_item_self_element  WHERE item_id = cable_item_id; 

-- check if any endpoint or its ancestors match the filter using recursive query 
-- limit relationship elements to cable relationship type and specified cable end 
IF ISNULL(cable_end) OR cable_end = ''
THEN
-- cable end not specified
WITH RECURSIVE ancestors as ( 
     SELECT parent_item_id FROM item_element WHERE parent_item_id in ( 
          SELECT parent_item_id FROM item_element WHERE id in ( 
                 SELECT first_item_element_id  
           FROM item_element_relationship ier  
           WHERE ier.relationship_type_id = 4 AND  
        second_item_element_id = item_self_element_id)) 

     UNION  

           SELECT ie.parent_item_id  
           FROM item_element ie, ancestors AS a  
           WHERE ie.contained_item_id1 = a.parent_item_id 

) SELECT count(i.name)  
INTO row_count  
FROM item i, ancestors  
WHERE i.id = ancestors.parent_item_id and i.name like name_filter_value;
ELSE
-- cable end specified
WITH RECURSIVE ancestors as ( 
     SELECT parent_item_id FROM item_element WHERE parent_item_id in ( 
          SELECT parent_item_id FROM item_element WHERE id in ( 
                 SELECT first_item_element_id  
           FROM item_element_relationship ier,  
        item_element_relationship_property ierp,  
property_value pv  
           WHERE ier.relationship_type_id = 4 AND  
        second_item_element_id = item_self_element_id AND 
  ierp.item_element_relationship_id = ier.id AND 
  pv.id = ierp.property_value_id AND 
          pv.value = cable_end)) 

     UNION  

           SELECT ie.parent_item_id  
           FROM item_element ie, ancestors AS a  
           WHERE ie.contained_item_id1 = a.parent_item_id 

) SELECT count(i.name)  
INTO row_count  
FROM item i, ancestors  
WHERE i.id = ancestors.parent_item_id and i.name like name_filter_value;
END IF;

RETURN row_count > 0; 
END//

Thursday, September 2, 2021

displaying busy indicator on primefaces wizard component

 Using primefaces 8 to build a java web application, I had trouble figuring out how to display a busy indicator from a primefaces wizard component.  Other views use onstart/oncomplete attributes for button actions to display a "loading dialog" that indicates the application is busy while the action completes.  That approach doesn't work for wizard navigation, because the action is performed asynchronously from the button click.  I found a stack overflow thread with a description of the solution.

In a nutshell, I used the "onnext" attribute of the p:wizard tag to open the busy dialog, and the flowListener method (onFlowProcess()) to close it.  Here are a couple of code snippets.

First the xhtml code for the wizard:

        <p:wizard id="importWizard"
                  flowListener="#{wizardController.onFlowProcess}" 
                  widgetVar="#{rootViewId}"
                  showStepStatus="false" 
                  showNavBar="false"
                  onnext="PF('loadingDialog').show();">

The code for the modal loading dialog:

    <p:dialog modal="true" 
              id="loadingDialog"
              widgetVar="loadingDialog" 
              showHeader="false" 
              styleClass="viewTransparentBackgroundDialog"
              resizable="false">
        <h:outputText value="Loading Results... Please Wait..." />
        <p/>
        <p:graphicImage library="images" name="ajax-loader.gif" />
    </p:dialog>

The java server code:

     public String onFlowProcess(FlowEvent event) {
        String result = onFlowProcessHandler(event);
        SessionUtility.executeRemoteCommand("PF('loadingDialog').hide();");
        return result;
    }

 

Wednesday, March 31, 2021

sql logging for jsf application in netbeans

To enable SQL logging to the netbeans console for a JSF application running in Payara with EclipseLink, add the following properties to the persistence.xml file: 
<property name="eclipselink.logging.level" value="FINE"/>
<property name="eclipselink.logging.logger" value="DefaultLogger"/>
More information here and here.

On a related note, logging can also be enabled directly in mysql, if that's the underlying database.  Here are some notes about doing that:

log in to mysql as root:
-> use mysql; 
-> SET global log_output = 'table'; 
-> SET GLOBAL general_log = 1;
​
then you can see the logged statements using:
select * from general_log;

or count the number of sql statements:
select count(*) from general_log; 
​
and clean it up with:
truncate general_log; 
​

Friday, March 12, 2021

java method reference

I can never remember the syntax for passing a method reference in Java, so I'm pasting a note about it here.  Here is a decent link explaining the idea.

Here is a method that accepts a method reference as a parameter, and calls that method in its body:

protected ItemDomainEntity findByPath_(String path, Function<ItemDomainEntity, ItemDomainEntity> parentGetterMethod) {

    <snip>
    ItemDomainEntity candidateParent = parentGetterMethod.apply(candidateItem);
    <snip>

}

And then an example of calling that method:

findByPath_(path, ItemDomainMachineDesign::getParentMachineDesign);


Tuesday, February 2, 2021

dynamic datatable components in primefaces

I'm making notes about this here for future reference. I have an JSF application where I'm using a primefaces datatable component. 

One thing that I don't love about the current approach is that the rows in the table are domain objects in the application, and each column therefore must be a property of the object in order to display the column values. Some of the columns I want to display in the table are not naturally properties of the underlying domain object, but just temporary values associated with the task at hand. So to add them as table columns, I have to define them as properties of the object and I don't always like that. 

 More than once I've wondered if it would be better to just use a list of strings as each row in the table. This way, some of the columns might map to properties of the domain object, while others are temporary task-specific values. Anyway, I'm stashing a couple of notes here about how to do this in case I want to experiment with it later. 

Here is a snippet for displaying lists of strings as the rows for the datatable based on this thread: 

                            <p:dataTable id="#{rootViewId}TableContent"
                                         value="#{wizardController.rows}"
                                         rendered="true"
                                         var="row">    

                                <p:columns value="#{wizardController.rows[0]}" var="column" columnIndexVar="i">
                                    #{row[i]}
                                </p:columns>

And here is a second thread for displaying dynamically selected columns. This still uses properties on the domain object, but I wonder if I could retrieve the values from some sort of map associated with the domain object instead? Here is a snippet of the view components from that thread: 

<h:form>
    <p:selectCheckboxMenu value="#{employeeBean.selectedColumns}"
                          label="Table Columns">
        <f:selectItems value="#{employeeBean.columnMap.entrySet()}"
                       var="entry"
                       itemValue="#{entry.key}"
                       itemLabel="#{entry.value}"/>

        <p:ajax event="change" update="table"/>
    </p:selectCheckboxMenu>
    <br/>

    <p:dataTable id="table" var="emp" value="#{employeeBean.employeeList}">
        <p:columns value="#{employeeBean.selectedColumns}" var="colKey">
            <f:facet name="header">
                <h:outputText value="#{employeeBean.columnMap[colKey]}"/>
            </f:facet>
            <h:outputText value="#{emp[colKey]}"/>
        </p:columns>
    </p:dataTable>
</h:form>
And the corresponding bean code:
@ManagedBean
@ViewScoped
public class EmployeeBean {
    private List<String> selectedColumns = new ArrayList<>();
    private List<Employee> employeeList = new ArrayList<>();
    private Map<String, String> columnMap = new LinkedHashMap<>();

    @PostConstruct
    private void postConstruct() {
        initColumnProperties();
        initEmployeeList();
    }

    private void initColumnProperties() {
        addColumn("id", "ID");
        addColumn("name", "Name");
        addColumn("phoneNumber", "Phone Number");
        addColumn("address", "Address");
        selectedColumns.addAll(columnMap.keySet());
    }

    private void addColumn(String propertyName, String displayName) {
        columnMap.put(propertyName, displayName);
    }

    private void initEmployeeList() {
        DataFactory dataFactory = new DataFactory();
        for (int i = 1; i < 20; i++) {
            Employee employee = new Employee();
            employee.setId(i);
            employee.setName(dataFactory.getName());
            employee.setPhoneNumber(String.format("%s-%s-%s", dataFactory.getNumberText(3),
                    dataFactory.getNumberText(3),
                    dataFactory.getNumberText(4)));
            employee.setAddress(dataFactory.getAddress() + "," + dataFactory.getCity());
            employeeList.add(employee);
        }
    }

    public List<Employee> getEmployeeList() {
        return employeeList;
    }

    public List<String> getSelectedColumns() {
        return selectedColumns;
    }

    public void setSelectedColumns(List<String> selectedColumns) {
        this.selectedColumns = selectedColumns;
    }

    public Map<String, String> getColumnMap() {
        return columnMap;
    }
}

Friday, November 27, 2020

re-installing MacOS on macbook with bad OS install

We had a laptop that was in a bad state after a failed OS upgrade. It was trying to autoboot to the installer, but the installer claimed that the macbook didn't support that OS version. After looking up the valid latest OS version for the macbook, I followed the instructions in this macworld article to load a MacOS installer on a thumb drive and install MacOS on the broken macbook. I chose to format (erase) the hard drive using disk utility before installing MacOS.

Friday, April 24, 2020

merge latest from main git repo to my fork

This works better than a web-gui initiated pull request when there are conflicts that must be resolved manually. From this link:
# First add the upstream remote:

git remote add upstream https://repoA
git fetch upstream

# Merge in upstream changes:

git checkout master
git merge upstream/master

# Resolve conflicts and push:

git push origin master

# Your pull request should automatically update

Monday, April 6, 2020

skypeforlinux fails to run due to wrong version of libstdc++

Once again skypeforlinux fails to run, this seems to be a weekly occurrence for me. Not sure why it's so fragile. Usually it's due to the permissions problem that I documented a couple of months ago. This time, it's not finding the correct version of libstdc++. I updated the OS and installed anaconda last week, so I'm guessing it's due to one of those actions.

The error message looked like this:
$ /usr/share/skypeforlinux/skypeforlinux
A JavaScript error occurred in the main process
Uncaught Exception:
Error: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/share/skypeforlinux/resources/app.asar.unpacked/node_modules/electron-utility/build/Release/electron_utility.node)
at process.func (electron/js2c/asar.js:140:31)
at process.func [as dlopen] (electron/js2c/asar.js:140:31)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:922:18)
at Object.func (electron/js2c/asar.js:140:31)
at Object.func [as .node] (electron/js2c/asar.js:149:18)
at Module.load (internal/modules/cjs/loader.js:735:32)
at Module._load (internal/modules/cjs/loader.js:648:12)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
at Module.require (internal/modules/cjs/loader.js:775:19)

I found this link, and followed some instructions about using the libstdc++ installed under anaconda in the /usr/lib64 directory. Here is a summary of the steps:

strings /usr/lib64/libstdc++.so.6 | grep GLIBCXX # to see the version of libstdc++ in your lib directory
sudo yum install libstdc++ # does nothing, yum says the package is up to date
sudo find / -name "libstdc++.so.6*" # find other installations of libstdc++, including anaconda
sudo cp /home/craig/anaconda3/lib/libstdc++.so.6.0.26 /usr/lib64/ # install libstdc++ from anaconda pkg to lib directory
sudo sudo mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.bkp # make a backup of existing lib
sudo ln -s /usr/lib64/libstdc++.so.6.0.26 /usr/lib64/libstdc++.so.6 # make symlink for new lib

Friday, April 3, 2020

growing virtualbox guest centos7 linux VM on windows 10 host

Here's another thing that was a whole lot harder than it seems like it should have been. I found several threads/links that were ALMOST everything I needed to know, but missing a couple of important details that probably weren't relevant to the author's situation so not in their process.

This link is very helpful (and this one) and basically describes the correct process.

The details that were missing from the first link were:

1. modifyhd must be done for each snapshot in the VM, not just the main vdi itself (see this link):

To list all the virtualbox drives, use "c:\Program Files\Oracle\VirtualBox>VBoxmanage list hdds". Then for each one associated with the vm you are growing, use modifyhd: "c:\Program Files\Oracle\VirtualBox>VBoxmanage modifyhd "C:\Users\auto\VirtualBox VMs\craigmcc APS dev\Snapshots\{4841ac14-4e09-4b0b-aa54-9665bb1bd4b3}.vdi" --resize 50000". So in my case I used modifyhd 5 times:

c:\Program Files\Oracle\VirtualBox>VBoxmanage modifyhd "C:\Users\auto\VirtualBox VMs\craigmcc APS dev\craigmcc APS dev 20200306 1620-disk001.vdi" --resize 50000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

c:\Program Files\Oracle\VirtualBox>VBoxmanage modifyhd "C:\Users\auto\VirtualBox VMs\craigmcc APS dev\Snapshots\{97e89522-0465-4f68-bfa9-ca33d790a379}.vdi" --resize 50000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

c:\Program Files\Oracle\VirtualBox>VBoxmanage modifyhd "C:\Users\auto\VirtualBox VMs\craigmcc APS dev\Snapshots\{9eb0ae2e-6b3a-41ba-a212-3c27410d8dbf}.vdi" --resize 50000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

c:\Program Files\Oracle\VirtualBox>VBoxmanage modifyhd "C:\Users\auto\VirtualBox VMs\craigmcc APS dev\Snapshots\{6b89d87f-f0d2-4a10-a64a-0b22fdde66de}.vdi" --resize 50000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

c:\Program Files\Oracle\VirtualBox>VBoxmanage modifyhd "C:\Users\auto\VirtualBox VMs\craigmcc APS dev\Snapshots\{4841ac14-4e09-4b0b-aa54-9665bb1bd4b3}.vdi" --resize 50000
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%

2. after using "lvextend" you must use "xfs_growfs" to make the space available (this is mentioned in the 2nd link above, but not the first.

After running lvextend, "lsblk" output looked correct, but "df -h" did not show the newly available space. I fixed this by running "sudo xfs_growfs /dev/mapper/centos-root". Now df shows the correct output.

So in a nutshell here are the steps:

1. make the disk partition larger, I used the command line tools shown above whereas the first link does so in vbox manager. "df" doesn't show the available space at this point, unlike the example in the first link above where df does show the space. But gparted does see it...
2. download gparted .iso file
3. mount the .iso file under the vm's storage tab on settings under IDE controller, make sure on system tab that optical is before hard disk in boot order
4. start the vm and run gparted, add the unallocated space to the partition you want to grow (in my case where / is mounted)
5. i had to follow the special LVM instructions in the first link, so in gparted you must "deactivate" the partition with the lock icon before growing it
6. unmount optical disk for gparted and reboot vm
7. display physical volumns with "sudo pvs", should show new free space
8. grow the physical volume with "sudo pvresize /dev/sda2"
9. "lsblk" still shows that the root partition is not using the entire available free space
10. run "sudo lvextend -l +100%FREE /dev/centos/root" to use the entire free space for the logical volume
11. run "sudo xfs_growfs /dev/mapper/centos-root" to grow the logical volume while mounted

Thursday, April 2, 2020

centos7 linux laptop can't connect to public wifi portals

It's not always the case, but sometimes/often I can't connect to public wifi portals from my linux laptop that open a login page automatically. The page is never displayed, and I get no internet service (though there is a wifi connection and network setup). This always happens on American Airlines and Delta flights, which is nice.

I did some research and found a couple of threads suggesting that I need to configure the NetworkManager service, and it will open the login page on the captive wifi portal. I found another link on the matter, with details about how to edit the config file. I basically did what it says, though I called the file /etc/NetworkManager/conf.d/20-connectivity-centos.conf. Supposedly this is read by the NetworkManager daemon at startup.

I restarted the daemon using these instructions, since the ones in the ubuntu threads don't work for me. I used "sudo systemctl restart NetworkManager".

Monday, March 2, 2020

virtualbox VM on centos 7 guest won't connect to network

Here's another one that I don't really understand. After working fine all last week with use all day every day, my virtualbox VM running on centos 7 guest and windows 10 host would not connect to the network. I rebooted my entire network, the guest and the host, but the problem remained. I easily found a solution with a google search, but I'm not entirely sure why it's necessary or why things worked fine last week without it. Here is the thread containing the fix, and in the end I just added the following lines to the guest file /etc/sysconfig/network-scripts/ifcfg-enp0s3:

DNS1=8.8.8.8
DNS2=8.8.4.4
# Note this was set to no
ONBOOT=yes

I restarted the guest VM, and then everything works fine.

The two DNS entries are for the Google Public DNS system. I don't know why I didn't need them last week, or why ONBOOT (which was previously set to no wasn't a problem either...

Friday, February 28, 2020

installing cisco anyconnect on centos 7 linux

I struggle every time I have to install cisco anyconnect vpn client on linux because you can't really download it unless you have a support contract. Since I'm a contractor, I need the program to communicate with multiple clients' networks. I'm sure I could track it down at one of my clients, but in a pinch I can usually find it to download from a university. Here are a couple of relevant excerpts about download and installation, copied in case the corresponding web page disappears.

===== (from UCI link)

Installing the VPN Client

Download the Anyconnect VPN client.

From the Terminal, navigate to the Downloads folder and unzip the file by typing [tar xzvf anyconnect-xxx.tar.gz]
NOTE: The *actual* file name will contain the name of the current version of the installer (e.g. anyconnect-linux64-4.5.03040-predeploy-k9.tar.gz)

A folder with the same name as the file will appear in the current directory. Open the folder and then go to the vpn directory, and once you are there type [./vpn_install.sh]

The VPN client will be installed on your system and the vpnagentd process will be started. This process will be started each time your system is booted.

NOTE: Ubuntu/Debian users should run this command to download a dependency for the VPN UI: [sudo apt-get install libpangox-1.0-0]

Starting the VPN Client

To start the client from the terminal, type [/opt/cisco/anyconnect/bin/vpnui]. Note: if you are not running a GUI, you can enter interactive mode by entering[/opt/cisco/anyconnect/bin/vpn]

NOTE: If you are using a desktop environment, you should be able to find the client in one of your menus as well (e.g. in a RHEL environment, look in Applications -> Internet).

In the “Connect to:” box, type vpn.uci.edu and press Return on your keyboard. Note: in interactive mode type [connect vpn.uci.edu]

In the “Group” menu that will appear, select the tunnel you wish to use, usually “UCI” or “UCIFull”. (See the differences in the Tunnels below.)

Enter your UCInetID and password in the appropriate boxes and click “Connect”.

You should get a banner box. When you do, click “Accept” and you are now connected.

=====

other links:

UA link

gatech link

particle accelerator machine protection

Just compiling some links and notes here for a new project I'm starting...

CERN paper

Monday, February 3, 2020

skype quit working on centos7 laptop

Not sure how it happened, but skype had been working well for weeks, but suddenly the program would no longer start. When I tried to run from the applications menu, I would just get a spinning wheel. Also running /usr/bin/skypeforlinux would fail but with no output. Oddly, /usr/bin/skypeforlinux is not a link, but the program is under /usr/share/skypeforlinux/skypeforlinux. When I ran that executable from the command line, I received an error message like this:

[28370:0203/134512.756947:FATAL:setuid_sandbox_host.cc(157)] The SUID sandbox helper binary was found, but is not configured correctly. Rather than run without sandboxing I'm aborting now. You need to make sure that /usr/share/skypeforlinux/chrome-sandbox is owned by root and has mode 4755.

So I checked that it was owned by root, but the permissions were not correct so I used chmod to change to 4755, and now the program runs. I'm not sure what is the difference between /usr/bin/skypeforlinux and /usr/share/skypeforlinux/skypeforlinux, e.g., the latter gave an error message while the former failed silently. But now that the program is working, they both open the skype GUI. Strange.

Thursday, December 19, 2019

redhat 7 laptop getting ERR_NETWORK_CHANGED errors in chrome

For a long time, I've been getting and ignoring errors in Chrome on my centos 7 laptop about "ERR_NETWORK_CHANGED".  This often makes transactions in banking and shopping sites fail completely and causes me to switch to a different machine.  Last week I used the Southwest wifi while traveling, and constantly received messages about network disconnects while using google docs.  I'm hoping the problem is the same, but not sure.  It happens with both wired and wireless network connection.

Anyway, I spent some time investigating today.  I thought it was network disconnects, but after looking at lots of generic network troubleshooting info, I searched for the chrome error and found some interesting hits.

This link suggests that the problem is due to ipv6, and disabling it SEEMS to have also solved my problem though it remains to be seen.  But I did not see any details as to WHY ipv6 is a problem, just that it is.  I'm sure if I looked harder I'd find it.  Here is another link about how to disable ipv6, I disabled all 3 properties that it mentions, but I used "sysctl -w" to change the configuration instead of editing sysctl.conf.  The result should be the same.

I used the "watch" command as suggested in the first link to monitor the output of "ip address" and see that the ipv6 interface was occasionally flapping to "tentative".  I used "sysctl -w" to disable ipv6.  And then I used watch again to confirm that the ipv6 interfaces are gone and that the word tentative is no longer appearing in the "ip address" output.

Here are the commands that I found helpful:
watch -n 2 -b -d 'ip address'
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1
ip address | grep ipv6
watch -d 'ip address | fgrep tentative'
Finally, here is another link for general network troubleshooting that gives some helpful background.

Wednesday, December 18, 2019

wired ethernet adapter on docking station quit working from Dell XPS 15 laptop

One of the joys of using Windows is when things that have been working forever mysteriously quit working.  That was the case with my Dell XPS 15 laptop running Windows 10.  "All of the sudden" the wired ethernet port on the docking station quit working.  There was probably/possibly a Dell/Windows update in the interim that broke it but who knows.  It took me a while to figure out, but to solve the problem I used these instructions for manually fixing the docking station drivers from the dell website (expand the "Installing drivers" node).  I skipped some of the steps, but I updated the bios and thunderbolt controller driver from this link.  I updated the docking station firmware from this link.  At this point I received a message that a new thunderbolt device was detected which made me happy.

I downloaded the realtek USB GBE ethernet controller driver from the drivers page for the laptop, and first used it to remove the existing installation and then ran it again to reinstall.  At this point, I turned off the wireless and confirmed that the wired ethernet port was indeed working correctly.

Monday, December 9, 2019

handling primefaces datatable events

This article is a good tutorial for handling events for the primefaces datatable component,

update tag behavior for components nested in Primefaces dataTable

I discovered the hard way that update="someComponentId" does not work for a commandLink nested inside a datatable. After some searching I found that you must use the syntax 'update=":formId:componentId" to make the update work. E.g., the example below works, but if I change the commandLink update to update="#{viewName}MembersPanel", an error results:

                <p:dataTable id="#{viewName}MemberDataTable"
                             var="member"
                             value="#{wizardController.members}"
                             emptyMessage="No members added.">

                    <p:column headerText="Cable name">
                        <h:outputText value="#{member.name}" />
                    </p:column>

                    <p:column headerText="Action">
                        <p:commandLink  id="#{viewName}RemoveCommandLink"
                                        value="Remove"
                                        action="#{wizardController.removeMember(member)}"
                                        onstart="PF('loadingDialog').show()"
                                        oncomplete="PF('loadingDialog').hide();update#{rootViewId}WizardButtons();"
                                        update="@form:#{viewName}MembersPanel"
                                        process="@form:#{viewName}MembersPanel">
                        </p:commandLink>
                    </p:column>

                </p:dataTable>