Huawei E3372h-153 (Stick mode) Fedora 30 usb_modeswitch

Fedora 30 .x86_64 5.3.6-200. 2019 OCTOBER
DISCLAIMER: I am in no way an expert of Linux in general or Fedora more in particular, I have only been using Linux(Fedora) for a year now and my level of nerdy/geekyness is only around upper mid range:) Therefore I apologize if I use the wrong jargon etc, I only mean to assist a very special community where I can. That being said my solution does not require ingenious knowledge and could probably have been solved in a much simpler fashion (by a rocket scientist). I am going to assume that if you are reading this that you know what a terminal is and that you have at least executed a few commands there before. Do not fear the terminal!
./
For some users, the use of the Huawei E3372 4G internet USB plug-in modem can be troublesome. From what I have come to understand after a number of hours of searching online and of testing, tweaking and finally solving is that there are 2 main versions of this modem. One uses a so called ‘Hi-Link’ firmware (Huawei E3372s I think) and the other a ‘Stick’ which I believe corresponds to mine (the E3372h). The firmware is different but the device is the same. This means they are interchangeable and there is a lot online explaining how to do this.
What should be said about this modem is that it is, like everything else, better designed to work with Windows. However, do not despair as from my experience, it would appear that it can be used perfectly by Linux and as a result, by Fedora!
I will begin by explaining the problem:
When plugging in my USB stick modem into the machine, I am met with Fedora recognizing it as a storage device (i.e CD/DVD/SD card). This is completely normal. This is how Huawei have designed this device. It can be used as two types of device; a SIM card reading modem or an SD card reader. The trouble begins when you want Fedora to recognize it as a modem so you can get on with your life! Luckily, this kind of dilema did not start yesterday and more ingenious people have already solved this problem by creating a tool called “usb_modeswitch”.
usb_modeswitch is already pre-installed I believe on Fedora. usb_modeswitch is supposed to automatically detect usb devices plugged in and switch them to the appropriate modes. However, because Huawei have two firmwares, In which (I think) it isn’t always necessary for usb_modeswitch to switch modes, it won’t always. Either that or there is a bug with the system Fedora or usb_modeswitch and it needs to be fixed. I have tried to go directly onto the website of the people who I think are the developers of usb_modeswitch (https://www.draisberghof.de/usb_modeswitch/) but their website is offline !!
Now to more technical stuff. My solution:
-Create a new usb rule that when I plug in my specific Huawei modem, it runs a command script that I created to automatically switch modes. Thus enabling me to just put in my SIM pin (if the sim has one), selecting to connect to the network and Voila!!

It appears that there is a rule file /lib/udev/rules.d/40-usb_modeswitch.rules
which carries all of the rules and exceptions for usb mode switching. There is a rule about Huawei, but it doesn’t seem to make any difference whatsoever so we will be ignoring this.
The first thing to note is that devices have their own ID numbers etc.
The way to find out yours is by typing into the terminal while the device is plugged in:

$ lsusb

the output should look something like:

Now here you should see your device with a Huawei technologies description at the right. Take for example:

Bus 001 Device 007: ID 12d1:14dc Huawei Technologies Co., Ltd.

There are two ID numbers separated by colons 12d1 & 14dc
These are your two original ID numbers and you are going to need them later on in the same order, so write them down.
Next you need to be able to manually put your device into the correct mode i.e get it working as a modem. The command for this will be:

$ sudo usb_modeswitch -J -v 0x12d1 -p 0x14dc

Be sure to modify the command above to include your own product IDs which should have as the first number 12d1 but the second number may vary.
If this command was successful you should have had no complaints from the terminal and should within a minute see the possibility to activate a broadband connection next to Wifi and Ethernet connections on the connections options on your desktop. Obviously here you will need to know how to setup (it’s super quick 5 clicks) a broadband connection based on the settings that your ISP gave you. If this works then great, we are on the right track. If it doesn’t then you may need to search for some more help, there may be another problem.
What we do next is create a file with a text editor of any kind. Copy and paste the following:

#!/bin/bash

sudo usb_modeswitch -J -v 0x12d1 -p 0x14dc

Be sure to include YOUR numbers. Then save the file with a relevant name and save it in a place(remember the path to the directory) that you will not delete it by accident for as long as you will need to use your Huawei modem.
What we have just done is to create well…a script. I mean this isn’t a real script there’s hardly any code but nevertheless it’s a script that’s going to help us.
The next step is to get Fedora to know how you want this script to be dealt with, to run it as a script and not open it to view the file. To execute the following command you should be in the target directory where you saved the file to, so for example Desktop if that is where you did save it:

$ sudo chmod +x {your file name}

This will let the system know to run this as a script. The next step is to create a rule file in the same place as all the other rules. So go to /lib/udev/rules.d/
give yourself Super User rights by typing command:

$ su

You will be prompted for password and then you should see the # key appear. BE VERY CAREFUL at this stage as you have tremendous power and can ruin things in a very bad way on your system if you use this particular terminal window to do other things. Only create this rule I mention. Now you can name this rule anything you want, perhaps 99-myhuaweimodem.rules.
I do recommend however to use the number 99 just we can find the rules easily and also to give it a .rules ending so that it fits in with the rest. when I was in the path /lib/udev/rules.d/ I opened a terminal there and then used the command

$ nano

This should open up a text editor in the terminal where you will paste the following being sure to use your device numbers where you see them in this line:

ACTION==“add”, ATTRS{idVendor}==“12d1”, ATTRS{idProduct}==“14dc”, RUN+="/home/{your-user-name}/Desktop/{your-file-name}"

Please ensure that you use your numbers and that the path
/home/{your-user-name}/Desktop/{your-file-name} corresponds to where you saved the file(script) you created earlier and the user name etc is yours obviously and do not include the { } signs! Then save this file.
The last and final step:
You remember how in our little script that we created, well the command that we used there was
sudo usb_modeswitch bla bla bla.
Well, that is all fantastic, but Linux will not execute a sudo command without a password. And because this is a simple ‘script’ there aren’t any clauses that tell it to alert us if the desired results are not achieved. So nothing will happen as yet. We need to give the user (yourself) the authorization to run such a command as sudo without a password. So that is done by adding an exception to the sudoers file which can be found in /etc/sudoers
However, this monkey won’t let us make any changes to this file unless we are are sudo and admin ourselves, so you need to edit this text file as root (sudo or su) and do it using nano, the terminal text editor like we did earlier using the command:

$ sudo nano sudoers

At the very end of this file once we have opened it we need to add the line at the bottom:

{your-user-name} ALL=NOPASSWD: /usr/sbin/usb_modeswitch

Be sure to insert your system user name where I wrote {your-user-name} without the { } signs.
Now save the changes you made and restart your machine. The changes should take effect and now when you insert your modem, it will work as a modem automatically.
I am not really sure if this is indeed the best fix, but I could not find much more about this issue especially seeing as the developers site is shut down, so I solved the problem as best I could.
I hope this helps someone who may be having the same issues I did.