Skip to content

Commit 5323611

Browse files
authored
[add] Create update script for Armored Turtle Automated Filament Changer (#614)
Introduces an automated update utility script, this script provides a command-line interface for updating the AFC software with safety checks and a menu-driven workflow.
1 parent d4f79be commit 5323611

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

update-afc.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
#!/usr/bin/env bash
2+
# Armored Turtle Automated Filament Changer
3+
#
4+
# Copyright (C) 2024-2026 Armored Turtle
5+
#
6+
# This file may be distributed under the terms of the GNU GPLv3 license.
7+
8+
set -e
9+
export LC_ALL=C
10+
11+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12+
13+
source "${SCRIPT_DIR}/include/constants.sh"
14+
15+
# Menu functions
16+
source "${SCRIPT_DIR}/include/menus/main_menu.sh"
17+
source "${SCRIPT_DIR}/include/menus/install_menu.sh"
18+
source "${SCRIPT_DIR}/include/menus/update_menu.sh"
19+
source "${SCRIPT_DIR}/include/menus/utilities_menu.sh"
20+
source "${SCRIPT_DIR}/include/menus/additional_system_menu.sh"
21+
source "${SCRIPT_DIR}/include/utils.sh"
22+
23+
# Install / Update functions
24+
source "${SCRIPT_DIR}/include/buffer_configurations.sh"
25+
source "${SCRIPT_DIR}/include/check_commands.sh"
26+
source "${SCRIPT_DIR}/include/colors.sh"
27+
source "${SCRIPT_DIR}/include/install_functions.sh"
28+
source "${SCRIPT_DIR}/include/uninstall.sh"
29+
source "${SCRIPT_DIR}/include/update_commands.sh"
30+
source "${SCRIPT_DIR}/include/update_functions.sh"
31+
32+
source "${SCRIPT_DIR}/include/unit_functions.sh"
33+
34+
original_args=("$@")
35+
36+
main() {
37+
###################### Main script logic below ######################
38+
39+
while getopts "a:k:s:m:n:b:p:y:th" arg; do
40+
case ${arg} in
41+
a) moonraker_address=${OPTARG} ;;
42+
k) klipper_dir=${OPTARG} ;;
43+
m) moonraker_config_file=${OPTARG} ;;
44+
n) moonraker_port=${OPTARG} ;;
45+
s) klipper_service=${OPTARG} ;;
46+
b) branch=${OPTARG} ;;
47+
p) printer_config_dir=${OPTARG} ;;
48+
y) klipper_venv=${OPTARG} ;;
49+
t) test_mode=True ;;
50+
h) show_help
51+
exit 0 ;;
52+
*) exit 1 ;;
53+
esac
54+
done
55+
56+
moonraker="${moonraker_address}:${moonraker_port}"
57+
58+
afc_config_dir="${printer_config_dir}/AFC"
59+
afc_file="${afc_config_dir}/AFC.cfg"
60+
moonraker_config_file="${moonraker_config_file:-${printer_config_dir}/moonraker.conf}"
61+
afc_path="$HOME/AFC-Klipper-Add-On"
62+
63+
64+
# Perform prerequisite and safety checks, then start the update process
65+
echo "Ensuring we are not running as root..."
66+
check_root
67+
echo "Ensuring no conflicting software is present..."
68+
check_for_hh
69+
echo "Checking to ensure crudini and jq are present..."
70+
check_for_prereqs
71+
if [ "$test_mode" == "False" ]; then
72+
check_python_version
73+
clone_and_maybe_restart
74+
fi
75+
check_existing_install
76+
echo "Starting update process..."
77+
sleep 2
78+
clear
79+
update_menu
80+
}
81+
82+
main "$@"

0 commit comments

Comments
 (0)