https://torte71.github.io/InsideSovolKlipperScreen/shutdown_linux.html
sudo apt install python3)sudo apt install putty-tools~./ssh/authorized_keys fileman ssh and man ssh-keygen for further help
Copy the 5 files hs110_off, hs110_on, mks_poweroff , shutdown_sv06 (from below) and tplink_smartplug.py (from above link) into a single directory.
Make these files executable by using chmod +x *.
Have putty-tools installed (as stated above), unless you have generated ssh keys for passwordless login.
Modify hs110_off and hs110_on, so the IP-address points to your HS110 wifi power plug.
Without further modifications, these files should now work for the Sovol KlipperScreen.
For other devices, change the variables PRINTER, USERNAME and PASSWORD in mks_poweroff according to your settings.
Now you should be able to shutdown and power off the device using clear text passwords by executing shutdown_sv06.
To power it on, execute hs110_on.
To use passwordless login (recommended), you need to generate a key file.
You can either use putty's plink or standard ssh for that, but the keys need to be generated differently.
First create the “.ssh” directory (if not already existing)
mkdir -p ~/.ssh ; chmod 700 ~/.sshFor plink:
puttygen to generate the keyputtygen -t ed25519 -f ~/.ssh/printerkeyputtygen again to generate and display the accompanying standard ssh public keyputtygen ~/.ssh/printerkey -Lman puttgen for further detailsFor standard ssh:
ssh-keygen to generate the keyssh-keygen -t ed25519 -f ~/.ssh/printerkeycat ~/.ssh/printerkey.pub to display the ssh public keyman ssh-keygen for further details.PLINKCMD variable in mks_poweroff to sshThen
chmod 600 ~/.ssh/printerkeyPLINKKEY variable in mks_poweroff so it points to your private key file (~/.ssh/printerkey in these examples)PASSWORD variable in mks_poweroff~/.ssh/authorized_keys:nano ~/.ssh/authorized_keyssudo visudo):mks ALL=NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroffNow you should be able to shutdown and power off the device without clear text passwords.
#!/bin/sh python tplink_smartplug.py -t 192.168.1.60 -c off
#!/bin/sh python tplink_smartplug.py -t 192.168.1.60 -c on
#!/bin/bash # Install plink (allows passwords given on commandline) # apt install putty-tools # To use a ssh key: # Adjust PLINKKEY so it points to your private key # (generated with "puttygen" when using putty, or with "ssh-keygen" for default ssh) # Using ssh instead of plink is possible when using a ssh key instead of a clear text password: # Set PLINKCMD=ssh # === best practice is using a PLINKKEY instead of a cleartext PASSWORD === PRINTER=mkspi USERNAME=mks PASSWORD=makerbase PLINKCMD=plink PLINKKEY= # options for plink with putty key (created with puttygen) #PASSWORD= #PLINKKEY=~/.ssh/printerkey # options for standard ssh (key created with ssh-keygen) #PASSWORD= #PLINKKEY=~/.ssh/printerkey #PLINKCMD=ssh # === nothing should be changed below here === # MKSPI: allow user "mks" to shutdown/reboot/halt (without "sudo" asking for a password): # add following to /etc/sudoers.conf (run "visudo"): # mks ALL=NOPASSWD: /sbin/halt, /sbin/reboot, /sbin/poweroff POWERCMD="sudo poweroff" if [ "$PLINKCMD" == "plink" ]; then OPTBATCH=-batch fi if [ ! -z $PLINKKEY ]; then OPTKEY="-i $PLINKKEY" fi if [ ! -z $PASSWORD ]; then OPTPW="-pw $PASSWORD" POWERCMD="echo $PASSWORD|sudo -S poweroff" fi $PLINKCMD $OPTPW $OPTKEY $OPTBATCH $USERNAME@$PRINTER $POWERCMD
#!/bin/bash
PRINTER=mkspi
# try to ping MKSPI, shut it down, if it responds
if ping -c 1 -W 1 $PRINTER >/dev/null; then
echo Shutting down MKSPI
bash mks_poweroff
echo -n Waiting for MKS to shutdown.
# ping MKSPI, until it stops responding
while ping -c 1 -W 1 $PRINTER >/dev/null; do
echo -n .
sleep 1
done
# not responding any longer
echo MKSPI has shut down.
echo Waiting additional 7 seconds...
sleep 7
fi
echo Power off HS110 smartplug...
bash hs110_off
Back to shutdown
Back to start