The following is helpful if you purchased the RemotePi addon board for your raspberry pi that provides IR Remote control and a Power button.
Instructions for RemotePi install on Raspberry Pi OSMC Source: https://www.msldigital.com/pages/shutdown-scripts-for-osmc Log in using SSH The default SSH user name for OSMC is osmc, password osmc cd /etc sudo nano irswitch.sh Copy and paste the following text into the editor window ====================BELOW=THIS=LINE===================== #!/bin/bash # this is the GPIO pin receiving the shut-down signal GPIOpin1=14 echo "$GPIOpin1" > /sys/class/gpio/export echo "in" > /sys/class/gpio/gpio$GPIOpin1/direction while true; do sleep 1 power=$(cat /sys/class/gpio/gpio$GPIOpin1/value) if [ $power != 0 ]; then sudo systemctl stop mediacenter echo "out" > /sys/class/gpio/gpio$GPIOpin1/direction echo "1" > /sys/class/gpio/gpio$GPIOpin1/value sleep 3 sudo shutdown -h now fi done ====================ABOVE=THIS=LINE===================== Press ctrl+x to exit, y to confirm, enter to save the file sudo chmod +x irswitch.sh The above RemotePi Board shutdown script needs to be registered as a service cd /etc/systemd/system sudo nano irswitch.service Copy and paste the following text into the editor window ====================BELOW=THIS=LINE===================== [Unit] Description=RemotePi Service After=systemd-modules-load.service [Service] Type=simple ExecStart=/etc/irswitch.sh [Install] WantedBy=multi-user.target ====================ABOVE=THIS=LINE===================== Press ctrl+x to exit, y to confirm, enter to save the file sudo systemctl enable irswitch.service The following additional script enables the RemotePi Board to cut off the power, after OSMC has been shut down from the on-screen menu. sudo nano /etc/shutdown.sh Copy and paste the following contents ====================BELOW=THIS=LINE===================== #!/bin/bash REBOOT_GREP=$(systemctl list-units --type=target | grep reboot) SHUTDOWN_GREP=$(systemctl list-units --type=target | grep shutdown) if [ "$SHUTDOWN_GREP" ] && [ ! "$REBOOT_GREP" ]; then # the condition above makes sure, that the shutdown sequence is not run on reboot GPIOpin=15 GPIOpin1=14 echo "$GPIOpin" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$GPIOpin/direction echo "1" > /sys/class/gpio/gpio$GPIOpin/value sleep 0.125 echo "0" > /sys/class/gpio/gpio$GPIOpin/value sleep 0.2 echo "1" > /sys/class/gpio/gpio$GPIOpin/value sleep 0.4 echo "0" > /sys/class/gpio/gpio$GPIOpin/value echo "$GPIOpin1" > /sys/class/gpio/export echo "out" > /sys/class/gpio/gpio$GPIOpin1/direction echo "1" > /sys/class/gpio/gpio$GPIOpin1/value sleep 4 fi ====================ABOVE=THIS=LINE===================== Press ctrl+x to exit, y to confirm, enter to save the file After saving the file, mark it as executable with: sudo chmod +x /etc/shutdown.sh sudo nano /etc/systemd/system/irswitch2.service Copy and paste the following text into the editor window ====================BELOW=THIS=LINE===================== [Unit] Description=RemotePi Board Shutdown Service Before=multi-user.target Conflicts=shutdown.target [Service] ExecStart=/bin/true ExecStop=/etc/shutdown.sh Type=oneshot RemainAfterExit=yes [Install] WantedBy=multi-user.target ====================ABOVE=THIS=LINE===================== Press ctrl+x to exit, y to confirm, enter to save the file sudo systemctl enable irswitch2.service Reboot one time After reboot you can use the RemotePi Board to power cycle OSMC