代码拉取完成,页面将自动刷新
#!/bin/bash
KLIPPER_PATH="${HOME}/printer_data/config"
SYSTEMDDIR="/etc/systemd/system"
# Step 1: Verify Klipper has been installed
check_klipper()
{
if [ "$(sudo systemctl list-units --full -all -t service --no-legend | grep -F "klipper.service")" ]; then
echo "Klipper service found!"
else
echo "Klipper service not found, please install Klipper first"
exit -1
fi
}
# Step 2: link extension to Klipper
link_extension()
{
target=$(find ~/printer_data/config -name "print_area_bed_mesh.cfg")
if [[ -z "$target" ]]
then
target="$HOME/printer_data/config/print_area_bed_mesh.cfg"
fi
echo "Linking ${SRCDIR}/print_area_bed_mesh.cfg to $target"
ln -sf "${SRCDIR}/print_area_bed_mesh.cfg" "$target"
}
# Step 3: restarting Klipper
restart_klipper()
{
echo "Restarting Klipper..."
sudo systemctl restart klipper
}
# Helper functions
verify_ready()
{
if [ "$EUID" -eq 0 ]; then
echo "This script must not run as root"
exit -1
fi
}
# Force script to exit if an error occurs
set -e
# Find SRCDIR from the pathname of this script
SRCDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/ && pwd )"
# Parse command line arguments
while getopts "k:" arg; do
case $arg in
k) KLIPPER_PATH=$OPTARG;;
esac
done
# Run steps
verify_ready
link_extension
restart_klipper
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。