Merge branch 'master' into mobileraker
# Conflicts: # scripts/ui/update_menu.sh
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
klipper_repos.txt
|
||||
.vscode
|
||||
*.code-workspace
|
||||
klipper_repos.txt
|
||||
|
||||
19
README.md
19
README.md
@@ -33,7 +33,7 @@ that you have a functional Linux system on hand. `Raspberry Pi OS Lite (32bit)`
|
||||
if you are using a Raspberry Pi. The [official Raspberry Pi Imager](https://www.raspberrypi.com/software/)
|
||||
is the simplest way to flash an image like this to an SD card.
|
||||
|
||||
* Once you downloaded, installed and launched the Raspberry Pi Imager
|
||||
* Once you have downloaded, installed and launched the Raspberry Pi Imager,
|
||||
select `Choose OS -> Raspberry Pi OS (other)`: \
|
||||
<p align="center">
|
||||
<img src="https://raw.githubusercontent.com/th33xitus/kiauh/master/resources/screenshots/rpi_imager1.png" alt="KIAUH logo" height="350">
|
||||
@@ -47,7 +47,7 @@ select `Choose OS -> Raspberry Pi OS (other)`: \
|
||||
* Back in the Raspberry Pi Imager's main menu, select the corresponding SD card to which
|
||||
you want to flash the image.
|
||||
|
||||
* Make sure to go into the Advaced Option (the cog icon in the lower left corner of the main menu)
|
||||
* Make sure to go into the Advanced Option (the cog icon in the lower left corner of the main menu)
|
||||
and enable SSH and configure Wi-Fi.
|
||||
|
||||
* If you need more help for using the Raspberry Pi Imager, please visit the [official documentation](https://www.raspberrypi.com/documentation/computers/getting-started.html).
|
||||
@@ -64,18 +64,18 @@ distributions based on Debian 11 Bullseye. Read the notes further down below in
|
||||
* **Step 1:** \
|
||||
To download this script, it is necessary to have git installed. If you don't have git already installed, or if you are unsure, run the following command:
|
||||
```shell
|
||||
sudo apt-get install git -y
|
||||
sudo apt-get update && sudo apt-get install git -y
|
||||
```
|
||||
|
||||
* **Step 2:** \
|
||||
Once git is installed, use the following command to download KIAUH into your home-directoy:
|
||||
Once git is installed, use the following command to download KIAUH into your home-directory:
|
||||
|
||||
```shell
|
||||
cd ~ && git clone https://github.com/th33xitus/kiauh.git
|
||||
```
|
||||
|
||||
* **Step 3:** \
|
||||
Finally start KIAUH by running the next command:
|
||||
Finally, start KIAUH by running the next command:
|
||||
|
||||
```shell
|
||||
./kiauh/kiauh.sh
|
||||
@@ -179,3 +179,12 @@ prompt and confirm by hitting ENTER.
|
||||
* A big thank you to [lixxbox](https://github.com/lixxbox) for that awesome KIAUH-Logo!
|
||||
* Also, a big thank you to everyone who supported my work with a [Ko-fi](https://ko-fi.com/th33xitus) !
|
||||
* Last but not least: Thank you to all contributors and members of the Klipper Community who like and share this project!
|
||||
|
||||
<hr>
|
||||
|
||||
<h4 align="center">A special thank you to JetBrains for sponsoring this project with their incredible software!</h4>
|
||||
<p align="center">
|
||||
<a href="https://www.jetbrains.com/community/opensource/#support" target="_blank">
|
||||
<img src="https://resources.jetbrains.com/storage/products/company/brand/logos/jb_beam.png" alt="JetBrains Logo (Main) logo." height="128">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
@@ -1 +1 @@
|
||||
KLIPPER_ARGS="/home/%USER%/klipper/klippy/klippy.py %CFG% -I %PRINTER% -l %LOG% -a %UDS%"
|
||||
KLIPPER_ARGS="%KLIPPER_DIR%/klippy/klippy.py %CFG% -I %PRINTER% -l %LOG% -a %UDS%"
|
||||
@@ -11,7 +11,7 @@ WantedBy=multi-user.target
|
||||
Type=simple
|
||||
User=%USER%
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=/home/%USER%/klipper
|
||||
WorkingDirectory=%KLIPPER_DIR%
|
||||
EnvironmentFile=%ENV_FILE%
|
||||
ExecStart=%ENV%/bin/python $KLIPPER_ARGS
|
||||
Restart=always
|
||||
|
||||
@@ -1 +1 @@
|
||||
TELEGRAM_BOT_ARGS="/home/%USER%/moonraker-telegram-bot/bot/main.py -c %CFG% -l %LOG%"
|
||||
TELEGRAM_BOT_ARGS="%TELEGRAM_BOT_DIR%/bot/main.py -c %CFG% -l %LOG%"
|
||||
@@ -9,7 +9,7 @@ WantedBy=multi-user.target
|
||||
[Service]
|
||||
Type=simple
|
||||
User=%USER%
|
||||
WorkingDirectory=/home/%USER%/moonraker-telegram-bot
|
||||
WorkingDirectory=%TELEGRAM_BOT_DIR%
|
||||
EnvironmentFile=%ENV_FILE%
|
||||
ExecStart=%ENV%/bin/python $TELEGRAM_BOT_ARGS
|
||||
Restart=always
|
||||
|
||||
@@ -1 +1 @@
|
||||
MOONRAKER_ARGS="/home/%USER%/moonraker/moonraker/moonraker.py -d %PRINTER_DATA%"
|
||||
MOONRAKER_ARGS="%MOONRAKER_DIR%/moonraker/moonraker.py -d %PRINTER_DATA%"
|
||||
@@ -12,7 +12,7 @@ Type=simple
|
||||
User=%USER%
|
||||
SupplementaryGroups=moonraker-admin
|
||||
RemainAfterExit=yes
|
||||
WorkingDirectory=/home/%USER%/moonraker
|
||||
WorkingDirectory=%MOONRAKER_DIR%
|
||||
EnvironmentFile=%ENV_FILE%
|
||||
ExecStart=%ENV%/bin/python $MOONRAKER_ARGS
|
||||
Restart=always
|
||||
|
||||
@@ -197,7 +197,7 @@ function compare_crowsnest_versions() {
|
||||
}
|
||||
|
||||
function install_crowsnest_dependencies() {
|
||||
local packages
|
||||
local packages log_name="Crowsnest"
|
||||
local install_script="${CROWSNEST_DIR}/tools/install.sh"
|
||||
|
||||
### read PKGLIST from official install-script
|
||||
@@ -208,21 +208,11 @@ function install_crowsnest_dependencies() {
|
||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||
read -r -a packages <<< "${packages}"
|
||||
|
||||
### Update system package info
|
||||
status_msg "Updating package lists..."
|
||||
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||
log_error "failure while updating package lists"
|
||||
error_msg "Updating package lists failed!"
|
||||
exit 1
|
||||
fi
|
||||
### Update system package lists if stale
|
||||
update_system_package_lists
|
||||
|
||||
### Install required packages
|
||||
status_msg "Installing required packages..."
|
||||
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||
log_error "failure while installing required crowsnest packages"
|
||||
error_msg "Installing required packages failed!"
|
||||
exit 1
|
||||
fi
|
||||
install_system_packages "${log_name}" "packages[@]"
|
||||
}
|
||||
|
||||
function update_crowsnest() {
|
||||
|
||||
@@ -70,6 +70,7 @@ function select_mcu_connection() {
|
||||
echo -e "| How is the controller board connected to the host? |"
|
||||
echo -e "| 1) USB |"
|
||||
echo -e "| 2) UART |"
|
||||
echo -e "| 3) USB (DFU mode) |"
|
||||
blank_line
|
||||
back_help_footer
|
||||
|
||||
@@ -85,6 +86,10 @@ function select_mcu_connection() {
|
||||
status_msg "Identifying MCU possibly connected via UART ...\n"
|
||||
get_uart_id || true # continue even after exit code 1
|
||||
break;;
|
||||
3)
|
||||
status_msg "Identifying MCU connected via USB in DFU mode ...\n"
|
||||
get_dfu_id || true # continue even after exit code 1
|
||||
break;;
|
||||
B|b)
|
||||
advanced_menu
|
||||
break;;
|
||||
@@ -329,6 +334,16 @@ function get_uart_id() {
|
||||
done
|
||||
}
|
||||
|
||||
function get_dfu_id() {
|
||||
unset mcu_list
|
||||
sleep 1
|
||||
mcus=$(lsusb | grep "DFU" | cut -d " " -f 6 2>/dev/null)
|
||||
|
||||
for mcu in ${mcus}; do
|
||||
mcu_list+=("${mcu}")
|
||||
done
|
||||
}
|
||||
|
||||
function show_flash_method_help() {
|
||||
top_border
|
||||
echo -e "| ~~~~~~~~ < ? > Help: Flash MCU < ? > ~~~~~~~~ |"
|
||||
@@ -406,4 +421,4 @@ function show_mcu_connection_help() {
|
||||
error_msg "Invalid command!";;
|
||||
esac
|
||||
done
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,24 @@ set -e
|
||||
#===================================================#
|
||||
|
||||
function install_fluidd() {
|
||||
### exit early if moonraker not found
|
||||
if [[ -z $(moonraker_systemd) ]]; then
|
||||
local error="Moonraker not installed! Please install Moonraker first!"
|
||||
print_error "${error}" && return
|
||||
local error="Moonraker not installed! It's recommended to install Moonraker first!"
|
||||
print_error "${error}"
|
||||
while true; do
|
||||
local yn
|
||||
read -p "${cyan}###### Proceed to install Fluidd without installing Moonraker? (y/N):${white} " yn
|
||||
case "${yn}" in
|
||||
Y|y|Yes|yes)
|
||||
select_msg "Yes"
|
||||
break;;
|
||||
N|n|No|no|"")
|
||||
select_msg "No"
|
||||
abort_msg "Exiting Fluidd setup ...\n"
|
||||
return;;
|
||||
*)
|
||||
error_msg "Invalid Input!";;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
### checking dependencies
|
||||
@@ -30,7 +44,7 @@ function install_fluidd() {
|
||||
|
||||
status_msg "Initializing Fluidd installation ..."
|
||||
### first, we create a backup of the full klipper_config dir - safety first!
|
||||
backup_klipper_config_dir
|
||||
#backup_klipper_config_dir
|
||||
|
||||
### check for other enabled web interfaces
|
||||
unset SET_LISTEN_PORT
|
||||
@@ -313,9 +327,9 @@ function get_local_fluidd_version() {
|
||||
function get_remote_fluidd_version() {
|
||||
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
|
||||
|
||||
local version
|
||||
version=$(get_fluidd_download_url | rev | cut -d"/" -f2 | rev)
|
||||
echo "${version}"
|
||||
local tags
|
||||
tags=$(curl -s "https://api.github.com/repos/fluidd-core/fluidd/tags" | grep "name" | cut -d'"' -f4)
|
||||
echo "${tags}" | head -1
|
||||
}
|
||||
|
||||
function compare_fluidd_versions() {
|
||||
@@ -341,27 +355,28 @@ function compare_fluidd_versions() {
|
||||
#================================================#
|
||||
|
||||
function get_fluidd_download_url() {
|
||||
local fl_tags tags latest_tag latest_url stable_tag stable_url url
|
||||
local releases_by_tag tags tag unstable_url url
|
||||
|
||||
fl_tags="https://api.github.com/repos/fluidd-core/fluidd/tags"
|
||||
tags=$(curl -s "${fl_tags}" | grep "name" | cut -d'"' -f4)
|
||||
|
||||
### latest download url including pre-releases (alpha, beta, rc)
|
||||
latest_tag=$(echo "${tags}" | head -1)
|
||||
latest_url="https://github.com/fluidd-core/fluidd/releases/download/${latest_tag}/fluidd.zip"
|
||||
|
||||
### get stable fluidd download url
|
||||
stable_tag=$(echo "${tags}" | grep -E "^v([0-9]+\.?){3}$" | head -1)
|
||||
stable_url="https://github.com/fluidd-core/fluidd/releases/download/${stable_tag}/fluidd.zip"
|
||||
### latest stable download url
|
||||
url="https://github.com/fluidd-core/fluidd/releases/latest/download/fluidd.zip"
|
||||
|
||||
read_kiauh_ini "${FUNCNAME[0]}"
|
||||
if [[ ${fluidd_install_unstable} == "true" ]]; then
|
||||
url="${latest_url}"
|
||||
echo "${url}"
|
||||
else
|
||||
url="${stable_url}"
|
||||
echo "${url}"
|
||||
releases_by_tag="https://api.github.com/repos/fluidd-core/fluidd/tags"
|
||||
tags=$(curl -s "${releases_by_tag}" | grep "name" | cut -d'"' -f4)
|
||||
tag=$(echo "${tags}" | head -1)
|
||||
|
||||
### latest unstable download url including pre-releases (alpha, beta, rc)
|
||||
unstable_url="https://github.com/fluidd-core/fluidd/releases/download/${tag}/fluidd.zip"
|
||||
|
||||
if [[ ${unstable_url} == *"download//"* ]]; then
|
||||
warn_msg "Download URL broken! Falling back to URL of latest stable release!"
|
||||
else
|
||||
url=${unstable_url}
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${url}"
|
||||
}
|
||||
|
||||
function fluidd_port_check() {
|
||||
|
||||
@@ -295,7 +295,7 @@ function create_klipper_virtualenv() {
|
||||
# @param {string}: python_version - klipper-env python version
|
||||
#
|
||||
function install_klipper_packages() {
|
||||
local packages python_version="${1}"
|
||||
local packages log_name="Klipper" python_version="${1}"
|
||||
local install_script="${KLIPPER_DIR}/scripts/install-debian.sh"
|
||||
|
||||
status_msg "Reading dependencies..."
|
||||
@@ -321,21 +321,11 @@ function install_klipper_packages() {
|
||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||
read -r -a packages <<< "${packages}"
|
||||
|
||||
### Update system package info
|
||||
status_msg "Updating package lists..."
|
||||
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||
log_error "failure while updating package lists"
|
||||
error_msg "Updating package lists failed!"
|
||||
exit 1
|
||||
fi
|
||||
### Update system package lists if stale
|
||||
update_system_package_lists
|
||||
|
||||
### Install required packages
|
||||
status_msg "Installing required packages..."
|
||||
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||
log_error "failure while installing required klipper packages"
|
||||
error_msg "Installing required packages failed!"
|
||||
exit 1
|
||||
fi
|
||||
install_system_packages "${log_name}" "packages[@]"
|
||||
}
|
||||
|
||||
function create_klipper_service() {
|
||||
@@ -378,8 +368,8 @@ function create_klipper_service() {
|
||||
|
||||
sudo cp "${service_template}" "${service}"
|
||||
sudo cp "${env_template}" "${env_file}"
|
||||
sudo sed -i "s|%USER%|${USER}|g; s|%ENV%|${KLIPPY_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
||||
sudo sed -i "s|%USER%|${USER}|; s|%LOG%|${log}|; s|%CFG%|${cfg}|; s|%PRINTER%|${klippy_serial}|; s|%UDS%|${klippy_socket}|" "${env_file}"
|
||||
sudo sed -i "s|%USER%|${USER}|g; s|%KLIPPER_DIR%|${KLIPPER_DIR}|; s|%ENV%|${KLIPPY_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
||||
sudo sed -i "s|%USER%|${USER}|; s|%KLIPPER_DIR%|${KLIPPER_DIR}|; s|%LOG%|${log}|; s|%CFG%|${cfg}|; s|%PRINTER%|${klippy_serial}|; s|%UDS%|${klippy_socket}|" "${env_file}"
|
||||
|
||||
ok_msg "Klipper service file created!"
|
||||
fi
|
||||
@@ -634,4 +624,4 @@ function get_klipper_python_ver() {
|
||||
local version
|
||||
version=$("${KLIPPY_ENV}"/bin/python --version 2>&1 | cut -d" " -f2 | cut -d"." -f1)
|
||||
echo "${version}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +16,24 @@ set -e
|
||||
#===================================================#
|
||||
|
||||
function install_mainsail() {
|
||||
### exit early if moonraker not found
|
||||
if [[ -z $(moonraker_systemd) ]]; then
|
||||
local error="Moonraker not installed! Please install Moonraker first!"
|
||||
print_error "${error}" && return
|
||||
local error="Moonraker not installed! It's recommended to install Moonraker first!"
|
||||
print_error "${error}"
|
||||
while true; do
|
||||
local yn
|
||||
read -p "${cyan}###### Proceed to install Mainsail without installing Moonraker? (y/N):${white} " yn
|
||||
case "${yn}" in
|
||||
Y|y|Yes|yes)
|
||||
select_msg "Yes"
|
||||
break;;
|
||||
N|n|No|no|"")
|
||||
select_msg "No"
|
||||
abort_msg "Exiting Mainsail setup ...\n"
|
||||
return;;
|
||||
*)
|
||||
error_msg "Invalid Input!";;
|
||||
esac
|
||||
done
|
||||
fi
|
||||
|
||||
### checking dependencies
|
||||
@@ -157,6 +171,7 @@ function download_mainsail_macros() {
|
||||
}
|
||||
|
||||
function download_mainsail() {
|
||||
local services
|
||||
local url
|
||||
url=$(get_mainsail_download_url)
|
||||
|
||||
@@ -179,8 +194,9 @@ function download_mainsail() {
|
||||
exit 1
|
||||
fi
|
||||
|
||||
### check for moonraker multi-instance and if multi-instance was found, enable mainsails remoteMode
|
||||
if [[ $(moonraker_systemd | wc -w) -gt 1 ]]; then
|
||||
### check for moonraker multi-instance and if no-instance or multi-instance was found, enable mainsails remoteMode
|
||||
services=$(moonraker_systemd)
|
||||
if [[ ( -z "${services}" ) || ( $(echo "${services}" | wc -w) -gt 1 ) ]]; then
|
||||
enable_mainsail_remotemode
|
||||
fi
|
||||
}
|
||||
@@ -318,9 +334,9 @@ function get_local_mainsail_version() {
|
||||
function get_remote_mainsail_version() {
|
||||
[[ ! $(dpkg-query -f'${Status}' --show curl 2>/dev/null) = *\ installed ]] && return
|
||||
|
||||
local version
|
||||
version=$(get_mainsail_download_url | rev | cut -d"/" -f2 | rev)
|
||||
echo "${version}"
|
||||
local tags
|
||||
tags=$(curl -s "https://api.github.com/repos/mainsail-crew/mainsail/tags" | grep "name" | cut -d'"' -f4)
|
||||
echo "${tags}" | head -1
|
||||
}
|
||||
|
||||
function compare_mainsail_versions() {
|
||||
@@ -511,27 +527,28 @@ function ms_theme_delete() {
|
||||
#================================================#
|
||||
|
||||
function get_mainsail_download_url() {
|
||||
local ms_tags tags latest_tag latest_url stable_tag stable_url url
|
||||
local releases_by_tag tags tag unstable_url url
|
||||
|
||||
ms_tags="https://api.github.com/repos/mainsail-crew/mainsail/tags"
|
||||
tags=$(curl -s "${ms_tags}" | grep "name" | cut -d'"' -f4)
|
||||
|
||||
### latest download url including pre-releases (alpha, beta, rc)
|
||||
latest_tag=$(echo "${tags}" | head -1)
|
||||
latest_url="https://github.com/mainsail-crew/mainsail/releases/download/${latest_tag}/mainsail.zip"
|
||||
|
||||
### get stable mainsail download url
|
||||
stable_tag=$(echo "${tags}" | grep -E "^v([0-9]+\.?){3}$" | head -1)
|
||||
stable_url="https://github.com/mainsail-crew/mainsail/releases/download/${stable_tag}/mainsail.zip"
|
||||
### latest stable download url
|
||||
url="https://github.com/mainsail-crew/mainsail/releases/latest/download/mainsail.zip"
|
||||
|
||||
read_kiauh_ini "${FUNCNAME[0]}"
|
||||
if [[ ${mainsail_install_unstable} == "true" ]]; then
|
||||
url="${latest_url}"
|
||||
echo "${url}"
|
||||
else
|
||||
url="${stable_url}"
|
||||
echo "${url}"
|
||||
releases_by_tag="https://api.github.com/repos/mainsail-crew/mainsail/tags"
|
||||
tags=$(curl -s "${releases_by_tag}" | grep "name" | cut -d'"' -f4)
|
||||
tag=$(echo "${tags}" | head -1)
|
||||
|
||||
### latest unstable download url including pre-releases (alpha, beta, rc)
|
||||
unstable_url="https://github.com/mainsail-crew/mainsail/releases/download/${tag}/mainsail.zip"
|
||||
|
||||
if [[ ${unstable_url} == *"download//"* ]]; then
|
||||
warn_msg "Download URL broken! Falling back to URL of latest stable release!"
|
||||
else
|
||||
url=${unstable_url}
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${url}"
|
||||
}
|
||||
|
||||
function mainsail_port_check() {
|
||||
|
||||
@@ -110,7 +110,7 @@ function telegram_bot_setup_dialog() {
|
||||
}
|
||||
|
||||
function install_telegram_bot_dependencies() {
|
||||
local packages
|
||||
local packages log_name="Telegram Bot"
|
||||
local install_script="${TELEGRAM_BOT_DIR}/scripts/install.sh"
|
||||
|
||||
### read PKGLIST from official install-script
|
||||
@@ -121,21 +121,11 @@ function install_telegram_bot_dependencies() {
|
||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||
read -r -a packages <<< "${packages}"
|
||||
|
||||
### Update system package info
|
||||
status_msg "Updating package lists..."
|
||||
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||
log_error "failure while updating package lists"
|
||||
error_msg "Updating package lists failed!"
|
||||
exit 1
|
||||
fi
|
||||
### Update system package lists if stale
|
||||
update_system_package_lists
|
||||
|
||||
### Install required packages
|
||||
status_msg "Installing required packages..."
|
||||
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||
log_error "failure while installing required moonraker-telegram-bot packages"
|
||||
error_msg "Installing required packages failed!"
|
||||
exit 1
|
||||
fi
|
||||
install_system_packages "${log_name}" "packages[@]"
|
||||
}
|
||||
|
||||
function create_telegram_bot_virtualenv() {
|
||||
@@ -328,11 +318,11 @@ function write_telegram_bot_service() {
|
||||
else
|
||||
sudo sed -i "s|%INST%|${i}|" "${service}"
|
||||
fi
|
||||
sudo sed -i "s|%USER%|${USER}|g; s|%ENV%|${TELEGRAM_BOT_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
||||
sudo sed -i "s|%USER%|${USER}|g; s|%TELEGRAM_BOT_DIR%|${TELEGRAM_BOT_DIR}|; s|%ENV%|${TELEGRAM_BOT_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
||||
|
||||
status_msg "Creating environment file for instance ${i} ..."
|
||||
cp "${env_template}" "${env_file}"
|
||||
sed -i "s|%USER%|${USER}|; s|%CFG%|${cfg}|; s|%LOG%|${log}|" "${env_file}"
|
||||
sed -i "s|%USER%|${USER}|; s|%TELEGRAM_BOT_DIR%|${TELEGRAM_BOT_DIR}|; s|%CFG%|${cfg}|; s|%LOG%|${log}|" "${env_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,7 @@ function moonraker_setup_dialog() {
|
||||
}
|
||||
|
||||
function install_moonraker_dependencies() {
|
||||
local packages
|
||||
local packages log_name="Moonraker"
|
||||
local install_script="${MOONRAKER_DIR}/scripts/install-moonraker.sh"
|
||||
|
||||
### read PKGLIST from official install-script
|
||||
@@ -152,21 +152,11 @@ function install_moonraker_dependencies() {
|
||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||
read -r -a packages <<< "${packages}"
|
||||
|
||||
### Update system package info
|
||||
status_msg "Updating package lists..."
|
||||
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||
log_error "failure while updating package lists"
|
||||
error_msg "Updating package lists failed!"
|
||||
exit 1
|
||||
fi
|
||||
### Update system package lists if stale
|
||||
update_system_package_lists
|
||||
|
||||
### Install required packages
|
||||
status_msg "Installing required packages..."
|
||||
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||
log_error "failure while installing required moonraker packages"
|
||||
error_msg "Installing required packages failed!"
|
||||
exit 1
|
||||
fi
|
||||
install_system_packages "${log_name}" "packages[@]"
|
||||
}
|
||||
|
||||
function create_moonraker_virtualenv() {
|
||||
@@ -370,8 +360,8 @@ function write_moonraker_service() {
|
||||
|
||||
[[ -z ${i} ]] && sudo sed -i "s| %INST%||" "${service}"
|
||||
[[ -n ${i} ]] && sudo sed -i "s|%INST%|${i}|" "${service}"
|
||||
sudo sed -i "s|%USER%|${USER}|g; s|%ENV%|${MOONRAKER_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
||||
sudo sed -i "s|%USER%|${USER}|; s|%PRINTER_DATA%|${printer_data}|" "${env_file}"
|
||||
sudo sed -i "s|%USER%|${USER}|g; s|%MOONRAKER_DIR%|${MOONRAKER_DIR}|; s|%ENV%|${MOONRAKER_ENV}|; s|%ENV_FILE%|${env_file}|" "${service}"
|
||||
sudo sed -i "s|%USER%|${USER}|; s|%MOONRAKER_DIR%|${MOONRAKER_DIR}|; s|%PRINTER_DATA%|${printer_data}|" "${env_file}"
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
@@ -307,7 +307,7 @@ function clone_octoeverywhere() {
|
||||
}
|
||||
|
||||
function install_octoeverywhere_dependencies() {
|
||||
local packages
|
||||
local packages log_name="OctoEverywhere"
|
||||
local install_script="${OCTOEVERYWHERE_DIR}/install.sh"
|
||||
|
||||
### read PKGLIST from official install-script
|
||||
@@ -318,21 +318,11 @@ function install_octoeverywhere_dependencies() {
|
||||
echo "${cyan}${packages}${white}" | tr '[:space:]' '\n'
|
||||
read -r -a packages <<< "${packages}"
|
||||
|
||||
### Update system package info
|
||||
status_msg "Updating package lists..."
|
||||
if ! sudo apt-get update --allow-releaseinfo-change; then
|
||||
log_error "failure while updating package lists"
|
||||
error_msg "Updating package lists failed!"
|
||||
exit 1
|
||||
fi
|
||||
### Update system package lists if stale
|
||||
update_system_package_lists
|
||||
|
||||
### Install required packages
|
||||
status_msg "Installing required packages..."
|
||||
if ! sudo apt-get install --yes "${packages[@]}"; then
|
||||
log_error "failure while installing required octoeverywhere packages"
|
||||
error_msg "Installing required packages failed!"
|
||||
exit 1
|
||||
fi
|
||||
install_system_packages "${log_name}" "packages[@]"
|
||||
}
|
||||
|
||||
#===================================================#
|
||||
|
||||
@@ -35,7 +35,8 @@ function install_ui() {
|
||||
}
|
||||
|
||||
function install_menu() {
|
||||
clear && print_header
|
||||
clear -x && sudo -v && clear -x # (re)cache sudo credentials so password prompt doesn't bork ui
|
||||
print_header
|
||||
install_ui
|
||||
|
||||
### save all installed webinterface ports to the ini file
|
||||
|
||||
@@ -41,6 +41,7 @@ function update_ui() {
|
||||
}
|
||||
|
||||
function update_menu() {
|
||||
clear -x && sudo -v && clear -x # (re)cache sudo credentials so password prompt doesn't bork ui
|
||||
do_action "" "update_ui"
|
||||
|
||||
local action
|
||||
@@ -72,7 +73,7 @@ function update_menu() {
|
||||
11)
|
||||
do_action "update_crowsnest" "update_ui";;
|
||||
12)
|
||||
do_action "update_system" "update_ui";;
|
||||
do_action "upgrade_system_packages" "update_ui";;
|
||||
a)
|
||||
do_action "update_all" "update_ui";;
|
||||
B|b)
|
||||
|
||||
@@ -20,6 +20,8 @@ function check_euid() {
|
||||
echo -e "${red}"
|
||||
top_border
|
||||
echo -e "| !!! THIS SCRIPT MUST NOT RUN AS ROOT !!! |"
|
||||
echo -e "| |"
|
||||
echo -e "| It will ask for credentials as needed. |"
|
||||
bottom_border
|
||||
echo -e "${white}"
|
||||
exit 1
|
||||
@@ -285,7 +287,7 @@ function python3_check() {
|
||||
|
||||
function dependency_check() {
|
||||
local dep=( "${@}" )
|
||||
local packages
|
||||
local packages log_name="dependencies"
|
||||
status_msg "Checking for the following dependencies:"
|
||||
|
||||
#check if package is installed, if not write its name into array
|
||||
@@ -303,12 +305,12 @@ function dependency_check() {
|
||||
done
|
||||
echo
|
||||
|
||||
if sudo apt-get update --allow-releaseinfo-change && sudo apt-get install "${packages[@]}" -y; then
|
||||
ok_msg "Dependencies installed!"
|
||||
else
|
||||
error_msg "Installing dependencies failed!"
|
||||
return 1 # exit kiauh
|
||||
fi
|
||||
# update system package lists if stale
|
||||
update_system_package_lists
|
||||
|
||||
# install required packages
|
||||
install_system_packages "${log_name}" "packages[@]"
|
||||
|
||||
else
|
||||
ok_msg "Dependencies already met!"
|
||||
return
|
||||
@@ -358,27 +360,78 @@ function create_required_folders() {
|
||||
done
|
||||
}
|
||||
|
||||
function check_system_updates() {
|
||||
local updates_avail info_msg
|
||||
updates_avail=$(apt list --upgradeable 2>/dev/null | sed "1d")
|
||||
|
||||
if [[ -n ${updates_avail} ]]; then
|
||||
info_msg="${yellow}System upgrade available!${white}"
|
||||
# add system to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "system"
|
||||
function update_system_package_lists() {
|
||||
local cache_mtime update_age update_interval silent
|
||||
|
||||
if [[ $1 == '--silent' ]]; then silent="true"; fi
|
||||
|
||||
if [[ -e /var/lib/apt/periodic/update-success-stamp ]]; then
|
||||
cache_mtime="$(stat -c %Y /var/lib/apt/periodic/update-success-stamp)"
|
||||
elif [[ -e /var/lib/apt/lists ]]; then
|
||||
cache_mtime="$(stat -c %Y /var/lib/apt/lists)"
|
||||
else
|
||||
info_msg="${green}System up to date! ${white}"
|
||||
log_warning "Failure determining package cache age, forcing update"
|
||||
cache_mtime=0
|
||||
fi
|
||||
|
||||
echo "${info_msg}"
|
||||
update_age="$(($(date +'%s') - cache_mtime))"
|
||||
update_interval=$((48*60*60)) # 48hrs
|
||||
|
||||
# update if cache is greater than update_interval
|
||||
if (( update_age > update_interval )); then
|
||||
if [[ ! ${silent} == "true" ]]; then status_msg "Updating package lists..."; fi
|
||||
if ! sudo apt-get update --allow-releaseinfo-change &>/dev/null; then
|
||||
log_error "Failure while updating package lists!"
|
||||
if [[ ! ${silent} == "true" ]]; then error_msg "Updating package lists failed!"; fi
|
||||
return 1
|
||||
else
|
||||
log_info "Package lists updated successfully"
|
||||
if [[ ! ${silent} == "true" ]]; then status_msg "Updated package lists."; fi
|
||||
fi
|
||||
else
|
||||
log_info "Package lists updated recently, skipping update..."
|
||||
fi
|
||||
}
|
||||
|
||||
function update_system() {
|
||||
status_msg "Updating System ..."
|
||||
if sudo apt-get update --allow-releaseinfo-change && sudo apt-get upgrade -y; then
|
||||
print_confirm "Update complete! Check the log above!\n ${yellow}KIAUH will not install any dist-upgrades or\n any packages which have been kept back!${green}"
|
||||
function check_system_updates() {
|
||||
local updates_avail status
|
||||
if ! update_system_package_lists --silent; then
|
||||
status="${red}Update check failed! ${white}"
|
||||
else
|
||||
print_error "System update failed! Please watch for any errors printed above!"
|
||||
updates_avail="$(apt list --upgradeable 2>/dev/null | sed "1d")"
|
||||
|
||||
if [[ -n ${updates_avail} ]]; then
|
||||
status="${yellow}System upgrade available!${white}"
|
||||
# add system to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "system"
|
||||
else
|
||||
status="${green}System up to date! ${white}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${status}"
|
||||
}
|
||||
|
||||
function upgrade_system_packages() {
|
||||
status_msg "Upgrading System ..."
|
||||
update_system_package_lists
|
||||
if sudo apt-get upgrade -y; then
|
||||
print_confirm "Upgrade complete! Check the log above!\n ${yellow}KIAUH will not install any dist-upgrades or\n any packages which have been held back!${green}"
|
||||
else
|
||||
print_error "System upgrade failed! Please look for any errors printed above!"
|
||||
fi
|
||||
}
|
||||
|
||||
function install_system_packages() {
|
||||
local log_name="$1"
|
||||
local packages=("${!2}")
|
||||
status_msg "Installing packages..."
|
||||
if sudo apt-get install -y "${packages[@]}"; then
|
||||
ok_msg "${log_name^} packages installed!"
|
||||
else
|
||||
log_error "Failure while installing ${log_name,,} packages"
|
||||
error_msg "Installing ${log_name} packages failed!"
|
||||
exit 1 # exit kiauh
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user