cat >/usr/local/bin/5g_module_load.sh<<EOF
#!/usr/bin/env bash
# filename: 5g_module_load.sh

MODULE_DIR=/lib/modules/5.4.0-109-generic/kernel/drivers/usb/serial

MODULE_LIST=(
    usbserial.ko
    usb_wwan.ko
    option.ko
)

ls /dev/ttyU* >/dev/null 2>/dev/null
if [[ "\$?" -ne "0" ]]
then
    for module in \${MODULE_LIST[@]}
    do

    /sbin/insmod \${MODULE_DIR}/\${module}
    done
else
    echo "Skip."
fi
EOF


chmod +x /usr/local/bin/5g_module_load.sh 

cat >/etc/systemd/system/5g-module.service<<EOF
[Unit]
Description=5G Network Module Load

[Service]
Type=simple
ExecStartPre=/bin/sleep 30
ExecStart=/usr/local/bin/5g_module_load.sh
TimeoutStopSec=5
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
EOF

systemctl daemon-reload
systemctl start 5g-module
systemctl enable 5g-module
