Page 1 of 1

Problem installing ON/OFF SHIM (Pimoroni)

PostPosted: 29 Mar 2019, 17:17
by klettervirus
I tried to install a hardware switch (ON/OFF ShHIM from Pimoroni). It needs to run an install script:

curl https://get.pimoroni.com/onoffshim | bash

When I trie that, it does not install the script but tells me something else:

"Running as root, please log in as a regular user with sudo rights!"

I do not understand, does that mean that a nromal user using "su" can do more than root? What is it that I need to do to install the script?

Thanks in advance for the help, kindest regards, Stefan

Re: Problem installing ON/OFF SHIM (Pimoroni)

PostPosted: 01 Apr 2019, 17:03
by janui
Hi klettervirus,
Linux has got very particular about what can and what can not be run as root. You also have a script designed for one of the standard Linux versions like Rasbian. RuneAudio uses Arch-Linux which uses a formal publication and version control process. So there is no guarantee that your script will deliver what is should.
As you point out it seems a waste of time forbidding things to be run as root then insisting that they are run as root via sudo. But I am afraid that’s the way it is.
I suggest you make a user called ‘shim’ and try using it to run the script. Create the user:
Code: Select all
userdel shim
groupdel shim
groupadd -r shim
useradd -r -d /home/shim -g shim shim
mkdir /home/shim
then add a file to the directory /etc/sudoers.d, for example: sudo-shim:
Code: Select all
nano /etc/sudoers.d/sudo-shim
With this content:
Code: Select all
shim ALL=NOPASSWD: ALL
Copy the script to directory /home and run:
Code: Select all
chmod 777 /home/<scriptname>
Then we should be ready to go, switch to the user shim with this:
Code: Select all
su shim
To check who you are:
Code: Select all
whoami
Then run your script:
Code: Select all
cd /home
sudo <scriptname>
That should do it. You can exit the shim user environment with:
Code: Select all
exit
Check who you are with whoami.
Janui

PS do not forget to clean up afterwards:
Code: Select all
rm /etc/sudoers.d/sudo-shim
userdel shim
groupdel shim
rmdir /home/shim

Re: Problem installing ON/OFF SHIM (Pimoroni)

PostPosted: 01 Apr 2019, 19:24
by klettervirus
Thanks so much, will try that!

Re: Problem installing ON/OFF SHIM (Pimoroni)

PostPosted: 05 Sep 2019, 15:32
by andre_chang
This way can realize the shutdown state, click the button to start it?

Re: Problem installing ON/OFF SHIM (Pimoroni)

PostPosted: 06 Sep 2019, 08:08
by janui
Hi andre_chang,
andre_chang wrote:This way can realize the shutdown state, click the button to start it?
See here: post26916.html
And here: shutdown-restart-pushbutton-t6781.html
I do not know if stablgr succeeded in making it work. Collin uses an elegant power switch configuration. However this looks like a better solution than using python scripts: https://github.com/ali1234/systemd-gpio
janui
Edited 06-09-2019