Sample Header Ad - 728x90

systemd service does not trigger the tmux command upon reboot

3 votes
1 answer
2171 views
I am using a Yocto image based on the linux-mainline kernel. I have systemd on the embedded OS that I have created. ### Aim I have a UMTS dongle connected to the board which will use usb_modeswitch to recognise the dongle and wvdial to connect to the 3G insfrastructure. ### Method I wrote a simple bash script in /usr/umts.sh as follows #!/bin/bash sleep 1; usb_modeswitch --default-vendor 12d1 --default-product 1446 -J sleep 1; /usr/bin/tmux new-session -d -s Cloud /usr/bin/tmux set-option set-remain-on-exit on /usr/bin/tmux new-window -d -n 'wvdial' -t Cloud:1 'sleep 1; /usr/bin/wvdialconf; /usr/bin/wvdial'; usb_modeswitch will configure the USB Dongle and the next part will create a tmux session and trigger wvdial within. my systemd script looks like follows in /etc/systemd/system/enable-umts.service GNU nano 2.2.5 File: /etc/systemd/system/enable-umts.service [Unit] Description=Enable UMTS Dongle for Cloud Connectivity [Service] Type=oneshot ExecStart=/usr/umts.sh [Install] WantedBy=default.target (I have given execution rights to the script using chmod +x /usr/umts.sh) I reloaded the daemon systemctl daemon-reload and enabled the service systemctl enable enable-umts.service and rebooted the board (NOTE: I have only root on board and no other user) The dmesg infact triggers the usb_modeswitch from the script above and I see related messages [ OK ] Started Enable UMTS Dongle for Cloud Connectivity. [ 13.051247] scsi host2: usb-storage 1-1:1.5 [ 13.067326] usb-storage 1-1:1.6: USB Mass Storage device detected [ 13.074645] scsi host3: usb-storage 1-1:1.6 [ 13.158627] usbcore: registered new interface driver usbserial [ 13.165501] usbcore: registered new interface driver usbserial_generic [ 13.174754] usbserial: USB Serial support registered for generic [ 13.202356] usbcore: registered new interface driver option [ 13.208714] usbserial: USB Serial support registered for GSM modem (1-port) [ 13.216468] option 1-1:1.0: GSM modem (1-port) converter detected [ 13.229840] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0 [ 13.238774] option 1-1:1.3: GSM modem (1-port) converter detected [ 13.248906] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1 [ 13.256172] option 1-1:1.4: GSM modem (1-port) converter detected [ 13.264467] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2 [ 14.069960] scsi 2:0:0:0: CD-ROM HUAWEI Mass Storage 2.31 PQ: 0 ANSI: 2 [ 14.088684] scsi 3:0:0:0: Direct-Access HUAWEI TF CARD Storage PQ: 0 ANSI: 2 [ 14.127686] sd 3:0:0:0: [sda] Attached SCSI removable disk GSM modem (1-port) converter detected ] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0 [ 13.238774] option 1-1:1.3: GSM modem (1-port) converter detected [ 13.248906] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1 [ 13.256172] option 1-1:1.4: GSM modem (1-port) coPassword But upon login I try to list the sessions tmux ls and it states there are no sessions created. The `script in fact does not fail and the service status is as follows: ● enable-umts.service - Enable UMTS Dongle for Cloud Connectivity Loaded: loaded (/etc/systemd/system/enable-umts.service; enabled; vendor preset: enabled) Active: inactive (dead) since Thu 2018-05-17 12:52:10 UTC; 4min 51s ago Process: 214 ExecStart=/usr/umts.sh (code=exited, status=0/SUCCESS) Main PID: 214 (code=exited, status=0/SUCCESS) May 17 12:52:09 phyboard-mira-imx6-3 umts.sh: Set up interface 0 May 17 12:52:09 phyboard-mira-imx6-3 umts.sh: Use endpoint 0x01 for message sending ... May 17 12:52:09 phyboard-mira-imx6-3 umts.sh: Trying to send message 1 to endpoint 0x01 ... May 17 12:52:09 phyboard-mira-imx6-3 umts.sh: OK, message successfully sent May 17 12:52:09 phyboard-mira-imx6-3 umts.sh: Reset response endpoint 0x81 May 17 12:52:09 phyboard-mira-imx6-3 umts.sh: Reset message endpoint 0x01 May 17 12:52:09 phyboard-mira-imx6-3 umts.sh: Could not reset endpoint (probably harmless): -99 May 17 12:52:09 phyboard-mira-imx6-3 umts.sh: Device is gone, skip any further commands May 17 12:52:09 phyboard-mira-imx6-3 umts.sh: -> Run lsusb to note any changes. Bye! May 17 12:52:10 phyboard-mira-imx6-3 systemd: Started Enable UMTS Dongle for Cloud Connectivity. If execute the script /usr/umts.sh as a standalone script then in fact it does everything it is supposed to do (open a new tmux session and triggers wvdial) What is wrong here? I tried adding more sleep time but that isn't working either. Sadly there is no rc.local or cron available for the yocto image I am working on.
Asked by Shan-Desai (811 rep)
May 17, 2018, 12:56 PM
Last activity: May 20, 2018, 04:09 PM