Custom autostart script not working

Having issues with your DietPi installation, or, found a bug? Post it here.
Post Reply
gurnarok
Posts: 5
Joined: Mon Feb 12, 2018 1:46 pm

Custom autostart script not working

Post by gurnarok »

Hi, I am having a problem with custom script.

Code: Select all

#!/bin/bash
#---Examples---

# - Chromium
#xinit chromium

# - LXDE
#startx

# - Print hello
#echo -e "Hello"

#---Put your code below this line---
echo 123 > /root/bootok

Code: Select all

root@Mars:~# ls -lh /root/
total 92K
drwxr-xr-x 4 root root 4.0K Feb 12 11:34 configs
drwxr-xr-x 2 root root 4.0K Jan 31 07:20 Desktop
-rw-r--r-- 1 root root    0 Jan 31 08:07 kodi_crashlog-20180131_080705.log
-rw-r--r-- 1 root root  82K Feb  1 18:31 kodi_crashlog-20180201_183123.log
In boot screen, I see a strange message:

Code: Select all

Started DietPi autostart (Custom /var/lib/dietpi/dietpi-autostart/custom.sh).
/bin/echo: /bin/echo: cannot execute binary file
So what is going on? How can I fix this? I am trying to delay Kodi from starting, giving MariaDB time to start.
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: Custom autostart script not working

Post by Fourdee »

Hi,

Confirmed, running some checks, will post back in a bit.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: Custom autostart script not working

Post by Fourdee »

Bug our end (thanks for letting us know), please copy/paste all into term:

Code: Select all

cat << _EOF_ > /etc/systemd/system/dietpi-autostart_custom.service
[Unit]
Description=DietPi autostart (Custom /var/lib/dietpi/dietpi-autostart/custom.sh)
After=dietpi-boot.service dietpi-ramdisk.service dietpi-ramlog.service rc-local.service
Requires=dietpi-boot.service dietpi-ramdisk.service

[Service]
Type=idle
ExecStartPre=/bin/bash -c 'echo -e "Starting DietPi-Autostart (Custom) script"'
ExecStartPre=$(which chmod) +x /var/lib/dietpi/dietpi-autostart/custom.sh
ExecStart=/bin/bash -c /var/lib/dietpi/dietpi-autostart/custom.sh
StandardOutput=tty
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
_EOF_
systemctl daemon-reload
systemctl restart dietpi-autostart_custom.service
Will also be resolved in v6.2 update.

test:

Code: Select all

root@DietPi:~# ls -lha
..
-rw-r--r--  1 root root    4 Feb 12 14:03 bootok
..
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
gurnarok
Posts: 5
Joined: Mon Feb 12, 2018 1:46 pm

Re: Custom autostart script not working

Post by gurnarok »

Thanks!

I made a dirty hack, adding sleep command into /DietPi/dietpi/misc/start_kodi

Code: Select all

        #/////////////////////////////////////////////////////////////////////////////////////
        # Main Loop
        #/////////////////////////////////////////////////////////////////////////////////////
        #-----------------------------------------------------------------------------------
        #Raspberry Pi
        if (( $G_HW_MODEL < 10 )); then

                sleep 2m
                kodi-standalone

        #Everything else
gurnarok
Posts: 5
Joined: Mon Feb 12, 2018 1:46 pm

Re: Custom autostart script not working

Post by gurnarok »

Ok, so I added the code and it works. But kodi is having problems starting up, I keep getting error messages when kodi tries to start.

Code: Select all

terminate called after throwing an instance of 'std::logic_error'
  what():   basic_string::_M_construct null not valid
Aborted
Cras report available at /kodi_crashlog-20180213_003222.log
terminate called after throwing an instance of 'std::logic_error'
  what():   basic_string::_M_construct null not valid
Aborted
Cras report available at /kodi_crashlog-20180213_003223.log
terminate called after throwing an instance of 'std::logic_error'
  what():   basic_string::_M_construct null not valid
Aborted
Cras report available at /kodi_crashlog-20180213_003225.log
/usb/bin/kodi --standalone has exited in an unclean state 3 times in the last 6 seconds.
Something is probably wrong
And the crash logs only contain

Code: Select all

root@Mars:/# cat kodi_crashlog-20180213_00322*
############## Kodi CRASH LOG ###############

################ SYSTEM INFO ################
 Date: Tue 13 Feb 00:32:22 EET 2018
 Kodi Options:
 Arch: armv7l
 Kernel: Linux 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017
 Release: Raspbian GNU/Linux 9 (stretch)
############## END SYSTEM INFO ##############

############### STACK TRACE #################
gdb not installed, can't get stack trace.
############# END STACK TRACE ###############

################# LOG FILE ##################

Logfile not found in the usual place.
Please attach it separately.
Use pastebin.com or similar for forums or IRC.

############### END LOG FILE ################

############ END Kodi CRASH LOG #############
############## Kodi CRASH LOG ###############

################ SYSTEM INFO ################
 Date: Tue 13 Feb 00:32:23 EET 2018
 Kodi Options:
 Arch: armv7l
 Kernel: Linux 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017
 Release: Raspbian GNU/Linux 9 (stretch)
############## END SYSTEM INFO ##############

############### STACK TRACE #################
gdb not installed, can't get stack trace.
############# END STACK TRACE ###############

################# LOG FILE ##################

Logfile not found in the usual place.
Please attach it separately.
Use pastebin.com or similar for forums or IRC.

############### END LOG FILE ################

############ END Kodi CRASH LOG #############
############## Kodi CRASH LOG ###############

################ SYSTEM INFO ################
 Date: Tue 13 Feb 00:32:25 EET 2018
 Kodi Options:
 Arch: armv7l
 Kernel: Linux 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017
 Release: Raspbian GNU/Linux 9 (stretch)
############## END SYSTEM INFO ##############

############### STACK TRACE #################
gdb not installed, can't get stack trace.
############# END STACK TRACE ###############

################# LOG FILE ##################

Logfile not found in the usual place.
Please attach it separately.
Use pastebin.com or similar for forums or IRC.

############### END LOG FILE ################

############ END Kodi CRASH LOG #############
root@Mars:/#
My custom startup script

Code: Select all

root@Mars:~# cat /var/lib/dietpi/dietpi-autostart/custom.sh
#!/bin/bash
#---Examples---

# - Chromium
#xinit chromium

# - LXDE
#startx

# - Print hello
#echo -e "Hello"

#---Put your code below this line---
#rm /mnt/pub_files/*_boot_ok
#touch /mnt/pub_files/$(date +%F__%H_%M)_boot_ok
sleep 2m
/DietPi/dietpi/misc/start_kodi
Edit:
Installed gdb to get something out of the crashlog, got this.

Code: Select all

root@Mars:~# cat /kodi_crashlog-20180213_104756.log
############## Kodi CRASH LOG ###############

################ SYSTEM INFO ################
 Date: Tue 13 Feb 10:47:56 EET 2018
 Kodi Options:
 Arch: armv7l
 Kernel: Linux 4.9.59-v7+ #1047 SMP Sun Oct 29 12:19:23 GMT 2017
 Release: Raspbian GNU/Linux 9 (stretch)
############## END SYSTEM INFO ##############

############### STACK TRACE #################
=====>  Core file: /core (2018-02-13 10:47:56.591485956 +0200)
        =========================================
[New LWP 3416]
[New LWP 3417]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
Core was generated by `/usr/lib/arm-linux-gnueabihf/kodi/kodi_v7.bin --lircdev /var/run/lirc/lircd'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
[Current thread is 1 (Thread 0x71ed8000 (LWP 3416))]

Thread 2 (Thread 0x71ed7300 (LWP 3417)):
#0  0x76f3a94c in __pthread_cond_wait (cond=0x2cddf30, mutex=0x2cddf68) at pthread_cond_wait.c:186
#1  0x009f1488 in ANNOUNCEMENT::CAnnouncementManager::Process() ()
#2  0x0069f674 in CThread::Action() ()
#3  0x0069feb0 in CThread::staticThread(void*) ()
#4  0x76f33fc4 in start_thread (arg=0x71ed7300) at pthread_create.c:335
#5  0x753e3c68 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:76 from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)

Thread 1 (Thread 0x71ed8000 (LWP 3416)):
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x7533f824 in __GI_abort () at abort.c:89
#2  0x754f3060 in __gnu_cxx::__verbose_terminate_handler() () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#3  0x754f0db0 in ?? () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#4  0x754f0e24 in std::terminate() () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#5  0x754f1158 in __cxa_throw () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#6  0x755194d4 in std::__throw_logic_error(char const*) () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6
#7  0x007ea6cc in ?? ()
#8  0x007ecddc in CApplication::Create() ()
#9  0x006b7988 in XBMC_Run ()
#10 0x003d37ac in main ()
############# END STACK TRACE ###############

################# LOG FILE ##################

Logfile not found in the usual place.
Please attach it separately.
Use pastebin.com or similar for forums or IRC.

############### END LOG FILE ################

############ END Kodi CRASH LOG #############
User avatar
Fourdee
Site Admin
Posts: 2782
Joined: Tue Feb 06, 2007 1:36 pm

Re: Custom autostart script not working

Post by Fourdee »

Confirmed with Kodi, I tried a few methods with no success, doesnt seem to like being launched under bash with systemD.
Needs further investigations, will need to pick this up at a later date.

Simple solution for now is using your hack (http://dietpi.com/phpbb/viewtopic.php?f ... 900#p10866) and selecting Kodi as autostart option.
Just bear in mind, updating DietPi will revert your changes (replaced with latest scripts), so you'll need to re-add it back in.
If you find our project or support useful, then we’d really appreciate it if you’d consider contributing to the project however you can.
Donating is the easiest – you can use PayPal or become a DietPi patron.
gurnarok
Posts: 5
Joined: Mon Feb 12, 2018 1:46 pm

Re: Custom autostart script not working

Post by gurnarok »

Fourdee wrote:Simple solution for now is using your hack (http://dietpi.com/phpbb/viewtopic.php?f ... 900#p10866) and selecting Kodi as autostart option.
Just bear in mind, updating DietPi will revert your changes (replaced with latest scripts), so you'll need to re-add it back in.
Would it be possible, to have an option to set a delay (in seconds) when selecting Kodi as autostart.
Post Reply