Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3881

Raspberry Pi OS • Re: /usr/bin/sh being linked to dash not bash makes script fail under "at"

$
0
0
Thank you very much for your considered reply.
It likely would not cause any issues to run system scripts under bash instead of dash. But you should not change the symlink. For one thing, it will change back every time there is an update to the dash package, breaking all your scripts again.
Yes, I agree. That was an experiment, not something I think I should continue to do.
Is your script executable (chmod +x)? The #! line will not work if not.
Yes, it's executable.
I think the only bash-isms are that you used [[ ]] instead of [ ], and &> instead of (in this case) 2>.
I tried running the script at the command line using sh ("/bin/sh myscript mysplash") and it quickly objected to the double bracket syntax. So I changed the [[ ]] to [ ] and that was accepted. I ran it again, and it didn't seem to object to anything else, but I changed the &> anyway.
I see you have already discovered that replacing system files is not expected or supported. There is almost certainly a better way to change the splash screen, without getting into a fight with the OS. However I do not use it, so I cannot test.
I have looked into creating my own plymouth theme. It seems like I could just copy the "pix" directory to a new directory "mytheme", copy mysplash.png there, make various edits within mytheme as appropriate, and finally set mytheme as the default theme. That seems simple enough, and I may try it. However, even if RPi updates left mytheme alone, I would still worry that they would change the default back to pix...
By the way, it is /bin/sh, /bin/dash, and /bin/bash. On current systems /bin is a symlink to usr/bin, so it does not make much difference. But the packaging system still remembers the official paths, and commands like dpkg -S /bin/sh will fail if you add /usr.
I decided to just remove the shebang. With the edits mentioned above, the script seems generic enough that it runs in my terminal under both bash and sh, and should run within the at job - about to find out. Here's the diff:

Code:

diff --git a/reminder_splashfix.sh b/reminder_splashfix.shindex e261b7e..b7c7ae9 100755--- a/reminder_splashfix.sh+++ b/reminder_splashfix.sh@@ -1,12 +1,10 @@-#!/usr/bin/bash- # script to check if a custom splash image has been over-written,  #   if so, it restores it AND updates the initramfs so that #   the custom image appears during both shutdown and boot  WRKDIR=/usr/share/plymouth/themes/pix -if [[ $# -eq 0 ]] ; then+if [ $# -eq 0 ] ; then     echo "Missing parameter for the custom splash image, i.e. /home/pi/mysplash.png"     exit 1 else@@ -15,7 +13,7 @@ fi  cd $WRKDIR -if cmp --silent splash.png $MYSPLASH &> /dev/null +if cmp --silent splash.png $MYSPLASH > /dev/null 2>&1  then        # equal         echo never mind, splash is OK

Statistics: Posted by tinker2much — Tue Aug 06, 2024 7:36 pm



Viewing all articles
Browse latest Browse all 3881

Trending Articles