Skip to content

Commit

Permalink
Scripts: swap to new verify_registered_extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
miklschmidt committed Dec 1, 2024
1 parent 0e08c05 commit bff874b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 132 deletions.
120 changes: 1 addition & 119 deletions configuration/scripts/ratos-common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,54 +64,7 @@ install_beacon()
echo "beacon: installing python requirements to env."
"${KLIPPER_ENV}"/bin/pip install -r "${BEACON_DIR}"/requirements.txt

# update link to beacon.py
echo "beacon: registering beacon with the configurator."
_register_klippy_extension "beacon" "$BEACON_DIR" "beacon.py"

}

_register_klippy_extension() {
EXT_NAME=$1
EXT_PATH=$2
EXT_FILE=$3
ERROR_IF_EXISTS=$4
[[ "$ERROR_IF_EXISTS" == "false" ]] && ERROR_IF_EXISTS="" || ERROR_IF_EXISTS="-e "

report_status "Registering klippy extension '$EXT_NAME' with the RatOS Configurator..."
if [ ! -e "$EXT_PATH/$EXT_FILE" ]
then
echo "ERROR: The file you're trying to register does not exist"
exit 1
fi

# shellcheck disable=SC2086
if ! ratos extensions register klipper $ERROR_IF_EXISTS"$EXT_NAME" "$EXT_PATH"/"$EXT_FILE"
then
echo "ERROR: Failed to register $EXT_NAME. Is the RatOS configurator running?"
exit 1
fi
}

_register_klippy_kinematics_extension() {
EXT_NAME=$1
EXT_PATH=$2
EXT_FILE=$3
ERROR_IF_EXISTS=$4
[[ "$ERROR_IF_EXISTS" == "false" ]] && ERROR_IF_EXISTS="" || ERROR_IF_EXISTS="-e "

report_status "Registering klipper kinematics extension '$EXT_NAME' with the RatOS Configurator..."
if [ ! -e "$EXT_PATH/$EXT_FILE" ]
then
echo "ERROR: The file you're trying to register does not exist"
exit 1
fi

# shellcheck disable=SC2086
if ! ratos extensions register klipper -k $ERROR_IF_EXISTS"$EXT_NAME" "$EXT_PATH"/"$EXT_FILE"
then
echo "ERROR: Failed to register $EXT_NAME. Is the RatOS configurator running?"
exit 1
fi
# Beacon extension will be registered in verify_registered_extensions
}

regenerate_config() {
Expand All @@ -120,77 +73,6 @@ regenerate_config() {
ratos config regenerate
}

register_gcode_shell_command()
{
EXT_NAME="gcode_shell_extension"
EXT_PATH=$(realpath "$SCRIPT_DIR"/../klippy)
EXT_FILE="gcode_shell_command.py"
_register_klippy_extension $EXT_NAME "$EXT_PATH" $EXT_FILE
}

register_ratos_homing()
{
EXT_NAME="ratos_homing_extension"
EXT_PATH=$(realpath "$SCRIPT_DIR"/../klippy)
EXT_FILE="ratos_homing.py"
# Don't error if extension is already registered
_register_klippy_extension $EXT_NAME "$EXT_PATH" $EXT_FILE "false"
}

register_resonance_generator()
{
EXT_NAME="resonance_generator_extension"
EXT_PATH=$(realpath "$SCRIPT_DIR"/../klippy)
EXT_FILE="resonance_generator.py"
# Don't error if extension is already registered
_register_klippy_extension $EXT_NAME "$EXT_PATH" $EXT_FILE "false"
}

unregister_vaoc_led()
{
if ratos extensions list | grep "vaoc_led" &>/dev/null; then
report_status "Unregistering experimental vaoc_led extension..."
ratos extensions unregister klipper vaoc_led
fi
}

register_z_offset_probe()
{
EXT_NAME="z_offset_probe_extension"
EXT_PATH=$(realpath "$SCRIPT_DIR"/../klippy)
EXT_FILE="z_offset_probe.py"
# Don't error if extension is already registered
_register_klippy_extension $EXT_NAME "$EXT_PATH" $EXT_FILE "false"
}

register_ratos_kinematics() {
if ratos extensions list | grep "ratos-kinematics" &>/dev/null; then
report_status "Unregistering old ratos-kinematics extension..."
ratos extensions unregister klipper -k ratos_hybrid_corexy
fi

RATOS_USER_HOME=$(getent passwd "${RATOS_USERNAME}" | cut -d: -f6)
if [ -e "${RATOS_USER_HOME}/config/RatOS/klippy/kinematics/ratos-kinematics" ]; then
report_status "Removing old ratos-kinematics directory..."
rm -rf "${RATOS_USER_HOME}/config/RatOS/klippy/kinematics/ratos-kinematics"
fi
EXT_NAME="ratos_hybrid_corexy"
EXT_PATH=$(realpath "${SCRIPT_DIR}/../klippy/kinematics")
EXT_FILE="ratos_hybrid_corexy.py"
_register_klippy_kinematics_extension $EXT_NAME "$EXT_PATH" $EXT_FILE "false"
}

register_ratos()
{
EXT_NAME="ratos_extension"
EXT_PATH=$(realpath "$SCRIPT_DIR"/../klippy)
EXT_FILE="ratos.py"
# Don't error if extension is already registered
_register_klippy_extension $EXT_NAME "$EXT_PATH" $EXT_FILE "false"
}



remove_old_postprocessor()
{
if [ -L "${KLIPPER_DIR}/klippy/extras/ratos_post_processor.py" ]; then
Expand Down
7 changes: 1 addition & 6 deletions configuration/scripts/ratos-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,4 @@ install_beacon
install_hooks
install_dependencies
ensure_sudo_command_whitelisting
register_gcode_shell_command
register_ratos_homing
register_z_offset_probe
register_ratos
register_resonance_generator
register_ratos_kinematics
verify_registered_extensions
10 changes: 3 additions & 7 deletions configuration/scripts/ratos-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,12 @@ symlink_extensions()
update_symlinks
ensure_sudo_command_whitelisting
ensure_service_permission
ensure_node_18
fix_klippy_env_ownership
patch_klipperscreen_service_restarts
install_beacon
install_hooks
ensure_node_18
patch_klipperscreen_service_restarts
register_z_offset_probe
remove_old_postprocessor
register_ratos
register_resonance_generator
register_ratos_kinematics
unregister_vaoc_led
verify_registered_extensions
symlink_extensions
update_beacon_fw

0 comments on commit bff874b

Please sign in to comment.