robertklep / dsm7-usb-serial-drivers

Synology DSM 7 USB serial drivers
510 stars 87 forks source link

🔧 Refactor USB serial drivers installation script #129

Open patrickclery opened 2 weeks ago

patrickclery commented 2 weeks ago

Just a proposal :)

This started as script I wrote for myself to simplify the installation, but I figured it could merge with the usb-serial-drivers.sh.

It mainly started because I wanted to remove the code that silences the output of insmod, but I decided to add a whole script to do everything.

Hope it offers some value :)

Usage:

./usb-serial-drivers.sh      

Install or enable the USB serial drivers on DSM 

Unit Commands:
  start                                         Load the USB serial drivers
  install [ARCHITECTURE] [DSM_VERSION] [--yes]  Install the USB serial drivers for the specified architecture
                                                    --yes Skip confirmation prompt

More information available at https://github.com/robertklep/dsm7-usb-serial-drivers

Successful execution:

Architecture set to: geminilake
DSM version set to: 7.2

2024-09-14 14:38:30 URL:https://raw.githubusercontent.com/robertklep/dsm7-usb-serial-drivers/main/modules/geminilake/dsm-7.2/ch341.ko [255928/255928] -> "/lib/modules/ch341.ko" [1]
[usb-serial-drivers] cp210x is already loaded. Removing it first.
2024-09-14 14:38:31 URL:https://raw.githubusercontent.com/robertklep/dsm7-usb-serial-drivers/main/modules/geminilake/dsm-7.2/cp210x.ko [272960/272960] -> "/lib/modules/cp210x.ko" [1]
[usb-serial-drivers] pl2303 is already loaded. Removing it first.
2024-09-14 14:38:31 URL:https://raw.githubusercontent.com/robertklep/dsm7-usb-serial-drivers/main/modules/geminilake/dsm-7.2/pl2303.ko [278384/278384] -> "/lib/modules/pl2303.ko" [1]
[usb-serial-drivers] ti_usb_3410_5052 is already loaded. Removing it first.
2024-09-14 14:38:31 URL:https://raw.githubusercontent.com/robertklep/dsm7-usb-serial-drivers/main/modules/geminilake/dsm-7.2/ti_usb_3410_5052.ko [311056/311056] -> "/lib/modules/ti_usb_3410_5052.ko" [1]
[usb-serial-drivers] usbserial is already loaded.
[usb-serial-drivers] ftdi_sio is already loaded.
[usb-serial-drivers] Loading cdc-acm
insmod: ERROR: could not insert module /lib/modules/cdc-acm.ko: File exists
[usb-serial-drivers] Loading ch341
[usb-serial-drivers] Loading cp210x
[usb-serial-drivers] Loading pl2303
[usb-serial-drivers] Loading ti_usb_3410_5052
[usb-serial-drivers] USB serial drivers have been enabled successfully.
robertklep commented 2 weeks ago

Very nice, thanks!

One possible improvement (that I could do myself if you can't/won't, so let me know 😄):

It looks like $ARCH can be read from /etc/synoinfo.conf:

source /etc/synoinfo.conf
echo Arch is $synobios

It would be cool to set it to that value as default, as I think a lot of users won't even know the platform of their NAS.

And one remark: the script uses /bin/sh but uses Bash-specific syntax. At the moment, /bin/sh is linked to /bin/bash so that's okay, but I'm not sure if it will always be like that (on a lot of regular Linux distros it's not anymore). Perhaps it's better to use #!/bin/bash instead?