加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
install.sh 1.34 KB
一键复制 编辑 原始数据 按行查看 历史
3D Print PT 提交于 2023-02-27 13:10 . Update install.sh
#!/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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化