mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-24 00:03:42 +05:00
Merge branch 'th33xitus:master' into fix-331
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1,3 @@
|
||||
.vscode
|
||||
*.code-workspace
|
||||
klipper_repos.txt
|
||||
15
README.md
15
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).
|
||||
@@ -68,14 +68,14 @@ 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
|
||||
@@ -152,23 +152,24 @@ prompt and confirm by hitting ENTER.
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><h3></h3></th>
|
||||
<th><h3><a href="https://github.com/Clon1998/mobileraker_companion">Mobileraker's Companion</a></h3></th>
|
||||
<th><h3><a href="https://octoeverywhere.com/?source=kiauh_readme">OctoEverywhere For Klipper</a></h3></th>
|
||||
<th><h3></h3></th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th></th>
|
||||
<th><a href="https://github.com/Clon1998/mobileraker_companion"><img src="https://raw.githubusercontent.com/Clon1998/mobileraker/master/assets/icon/mr_appicon.png" alt="OctoEverywhere Logo" height="64"></th>
|
||||
<th><a href="https://octoeverywhere.com/?source=kiauh_readme"><img src="https://octoeverywhere.com/img/logo.svg" alt="OctoEverywhere Logo" height="64"></a></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th></th>
|
||||
<th>by <a href="https://github.com/Clon1998">Patrick Schmidt</a></th>
|
||||
<th>by <a href="https://github.com/QuinnDamerell">Quinn Damerell</a></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
|
||||
</table>
|
||||
|
||||
<hr>
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
This document covers possible important changes to KIAUH.
|
||||
|
||||
### 2023-06-17
|
||||
KIAUH has now added support for installing Mobileraker's companion!
|
||||
Mobileraker is a free and Open Source Android and iOS App for Klipper, utilizing the Moonraker API, allowing you
|
||||
to control your printer. Thank you to [Clon1998](https://github.com/Clon1998) for adding this feature!
|
||||
|
||||
### 2023-02-03
|
||||
The installer for MJPG-Streamer got replaced by crowsnest. It is an improved webcam service, utilizing ustreamer.
|
||||
Please have a look here for additional info about crowsnest and how to configure it: https://github.com/mainsail-crew/crowsnest \
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -78,4 +78,9 @@ function set_globals() {
|
||||
CROWSNEST_DIR="${HOME}/crowsnest"
|
||||
CROWSNEST_REPO="https://github.com/mainsail-crew/crowsnest.git"
|
||||
|
||||
#=============== Mobileraker ================#
|
||||
MOBILERAKER_ENV="${HOME}/mobileraker-env"
|
||||
MOBILERAKER_DIR="${HOME}/mobileraker_companion"
|
||||
MOBILERAKER_REPO="https://github.com/Clon1998/mobileraker_companion.git"
|
||||
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ function start_klipper_setup() {
|
||||
### user selection for python version
|
||||
print_dialog_user_select_python_version
|
||||
while true; do
|
||||
read -p "${cyan}###### Select Python version:${white} " input
|
||||
read -p "${cyan}###### Select Python version:${white} " -i "1" -e input
|
||||
case "${input}" in
|
||||
1)
|
||||
select_msg "Python 3.x\n"
|
||||
@@ -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
|
||||
|
||||
247
scripts/mobileraker.sh
Normal file
247
scripts/mobileraker.sh
Normal file
@@ -0,0 +1,247 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#=======================================================================#
|
||||
# Copyright (C) 2020 - 2023 Dominik Willner <th33xitus@gmail.com> #
|
||||
# #
|
||||
# This file is part of KIAUH - Klipper Installation And Update Helper #
|
||||
# https://github.com/th33xitus/kiauh #
|
||||
# #
|
||||
# This file may be distributed under the terms of the GNU GPLv3 license #
|
||||
#=======================================================================#
|
||||
|
||||
#
|
||||
# This file is written and maintained by Patrick Schmidt author of Mobileraker
|
||||
# It is based of the kliperscreen.sh install script!
|
||||
|
||||
|
||||
set -e
|
||||
|
||||
#===================================================#
|
||||
#========== INSTALL MOBILERAKER COMPANION ==========#
|
||||
#===================================================#
|
||||
|
||||
function mobileraker_systemd() {
|
||||
local services
|
||||
services=$(find "${SYSTEMD}" -maxdepth 1 -regextype posix-extended -regex "${SYSTEMD}/mobileraker.service")
|
||||
echo "${services}"
|
||||
}
|
||||
|
||||
function install_mobileraker() {
|
||||
### return early if python version check fails
|
||||
if [[ $(python3_check) == "false" ]]; then
|
||||
local error="Versioncheck failed! Python 3.7 or newer required!\n"
|
||||
error="${error} Please upgrade Python."
|
||||
print_error "${error}" && return
|
||||
fi
|
||||
|
||||
### first, we create a backup of the full klipper_config dir - safety first!
|
||||
backup_klipper_config_dir
|
||||
|
||||
### install Mobileraker's Companion
|
||||
mobileraker_setup
|
||||
|
||||
### add Mobileraker's Companion to the update manager in moonraker.conf
|
||||
patch_mobileraker_update_manager
|
||||
|
||||
do_action_service "restart" "mobileraker"
|
||||
}
|
||||
|
||||
function mobileraker_setup() {
|
||||
local dep=(wget curl unzip dfu-util)
|
||||
dependency_check "${dep[@]}"
|
||||
status_msg "Cloning Mobileraker's companion from ${MOBILERAKER_REPO} ..."
|
||||
|
||||
# force remove existing Mobileraker's companion dir
|
||||
[[ -d ${MOBILERAKER_DIR} ]] && rm -rf "${MOBILERAKER_DIR}"
|
||||
|
||||
# clone into fresh Mobileraker's companion dir
|
||||
cd "${HOME}" || exit 1
|
||||
if ! git clone "${MOBILERAKER_REPO}" "${MOBILERAKER_DIR}"; then
|
||||
print_error "Cloning mobileraker's companion from\n ${MOBILERAKER_REPO}\n failed!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
status_msg "Installing Mobileraker's companion ..."
|
||||
if "${MOBILERAKER_DIR}"/scripts/install-mobileraker-companion.sh; then
|
||||
ok_msg "Mobileraker's companion successfully installed!"
|
||||
else
|
||||
print_error "Mobileraker's companion installation failed!"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
#===================================================#
|
||||
#=========== REMOVE MOBILERAKER COMPANION ==========#
|
||||
#===================================================#
|
||||
|
||||
function remove_mobileraker() {
|
||||
### remove Mobileraker's companion dir
|
||||
if [[ -d ${MOBILERAKER_DIR} ]]; then
|
||||
status_msg "Removing Mobileraker's companion directory ..."
|
||||
rm -rf "${MOBILERAKER_DIR}" && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove Mobileraker's companion VENV dir
|
||||
if [[ -d ${MOBILERAKER_ENV} ]]; then
|
||||
status_msg "Removing Mobileraker's companion VENV directory ..."
|
||||
rm -rf "${MOBILERAKER_ENV}" && ok_msg "Directory removed!"
|
||||
fi
|
||||
|
||||
### remove Mobileraker's companion service
|
||||
if [[ -e "${SYSTEMD}/mobileraker.service" ]]; then
|
||||
status_msg "Removing mobileraker service ..."
|
||||
do_action_service "stop" "mobileraker"
|
||||
do_action_service "disable" "mobileraker"
|
||||
sudo rm -f "${SYSTEMD}/mobileraker.service"
|
||||
|
||||
###reloading units
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl reset-failed
|
||||
ok_msg "Mobileraker's companion Service removed!"
|
||||
fi
|
||||
|
||||
|
||||
remove_mobileraker_logs
|
||||
|
||||
print_confirm "Mobileraker's companion successfully removed!"
|
||||
}
|
||||
|
||||
function remove_mobileraker_logs() {
|
||||
local files regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/logs\/mobileraker\.log.*"
|
||||
files=$(find "${HOME}" -maxdepth 3 -regextype posix-extended -regex "${regex}" | sort)
|
||||
|
||||
if [[ -n ${files} ]]; then
|
||||
for file in ${files}; do
|
||||
status_msg "Removing ${file} ..."
|
||||
rm -f "${file}"
|
||||
ok_msg "${file} removed!"
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
#===================================================#
|
||||
#=========== UPDATE MOBILERAKER COMPANION ==========#
|
||||
#===================================================#
|
||||
|
||||
function update_mobileraker() {
|
||||
local old_md5
|
||||
old_md5=$(md5sum "${MOBILERAKER_DIR}/scripts/mobileraker-requirements.txt" | cut -d " " -f1)
|
||||
|
||||
do_action_service "stop" "mobileraker"
|
||||
cd "${MOBILERAKER_DIR}"
|
||||
git pull origin main -q && ok_msg "Fetch successfull!"
|
||||
git checkout -f main && ok_msg "Checkout successfull"
|
||||
|
||||
if [[ $(md5sum "${MOBILERAKER_DIR}/scripts/mobileraker-requirements.txt" | cut -d " " -f1) != "${old_md5}" ]]; then
|
||||
status_msg "New dependecies detected..."
|
||||
"${MOBILERAKER_ENV}"/bin/pip install -r "${MOBILERAKER_DIR}/scripts/mobileraker-requirements.txt"
|
||||
ok_msg "Dependencies have been installed!"
|
||||
fi
|
||||
|
||||
ok_msg "Update complete!"
|
||||
do_action_service "start" "mobileraker"
|
||||
}
|
||||
|
||||
#===================================================#
|
||||
#=========== MOBILERAKER COMPANION STATUS ==========#
|
||||
#===================================================#
|
||||
|
||||
function get_mobileraker_status() {
|
||||
local sf_count status
|
||||
sf_count="$(mobileraker_systemd | wc -w)"
|
||||
|
||||
### remove the "SERVICE" entry from the data array if a moonraker service is installed
|
||||
local data_arr=(SERVICE "${MOBILERAKER_DIR}" "${MOBILERAKER_ENV}")
|
||||
(( sf_count > 0 )) && unset "data_arr[0]"
|
||||
|
||||
### count+1 for each found data-item from array
|
||||
local filecount=0
|
||||
for data in "${data_arr[@]}"; do
|
||||
[[ -e ${data} ]] && filecount=$(( filecount + 1 ))
|
||||
done
|
||||
|
||||
if (( filecount == ${#data_arr[*]} )); then
|
||||
status="Installed!"
|
||||
elif (( filecount == 0 )); then
|
||||
status="Not installed!"
|
||||
else
|
||||
status="Incomplete!"
|
||||
fi
|
||||
echo "${status}"
|
||||
}
|
||||
|
||||
function get_local_mobileraker_commit() {
|
||||
[[ ! -d ${MOBILERAKER_DIR} || ! -d "${MOBILERAKER_DIR}/.git" ]] && return
|
||||
|
||||
local commit
|
||||
cd "${MOBILERAKER_DIR}"
|
||||
commit="$(git describe HEAD --always --tags | cut -d "-" -f 1,2)"
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function get_remote_mobileraker_commit() {
|
||||
[[ ! -d ${MOBILERAKER_DIR} || ! -d "${MOBILERAKER_DIR}/.git" ]] && return
|
||||
|
||||
local commit
|
||||
cd "${MOBILERAKER_DIR}" && git fetch origin -q
|
||||
commit=$(git describe origin/main --always --tags | cut -d "-" -f 1,2)
|
||||
echo "${commit}"
|
||||
}
|
||||
|
||||
function compare_mobileraker_versions() {
|
||||
local versions local_ver remote_ver
|
||||
local_ver="$(get_local_mobileraker_commit)"
|
||||
remote_ver="$(get_remote_mobileraker_commit)"
|
||||
|
||||
if [[ ${local_ver} != "${remote_ver}" ]]; then
|
||||
versions="${yellow}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
# add moonraker to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "mobileraker"
|
||||
else
|
||||
versions="${green}$(printf " %-14s" "${local_ver}")${white}"
|
||||
versions+="|${green}$(printf " %-13s" "${remote_ver}")${white}"
|
||||
fi
|
||||
|
||||
echo "${versions}"
|
||||
}
|
||||
|
||||
#================================================#
|
||||
#=================== HELPERS ====================#
|
||||
#================================================#
|
||||
|
||||
function patch_mobileraker_update_manager() {
|
||||
local patched moonraker_configs regex
|
||||
regex="${HOME//\//\\/}\/([A-Za-z0-9_]+)\/config\/moonraker\.conf"
|
||||
moonraker_configs=$(find "${HOME}" -maxdepth 3 -type f -regextype posix-extended -regex "${regex}" | sort)
|
||||
|
||||
patched="false"
|
||||
for conf in ${moonraker_configs}; do
|
||||
if ! grep -Eq "^\[update_manager mobileraker\]\s*$" "${conf}"; then
|
||||
### add new line to conf if it doesn't end with one
|
||||
[[ $(tail -c1 "${conf}" | wc -l) -eq 0 ]] && echo "" >> "${conf}"
|
||||
|
||||
### add Mobileraker's Companion update manager section to moonraker.conf
|
||||
status_msg "Adding Mobileraker's Companion to update manager in file:\n ${conf}"
|
||||
/bin/sh -c "cat >> ${conf}" << MOONRAKER_CONF
|
||||
|
||||
[update_manager mobileraker]
|
||||
type: git_repo
|
||||
path: ${HOME}/mobileraker_companion
|
||||
origin: https://github.com/Clon1998/mobileraker_companion.git
|
||||
primary_branch:main
|
||||
managed_services: mobileraker
|
||||
env: ${HOME}/mobileraker-env/bin/python
|
||||
requirements: scripts/mobileraker-requirements.txt
|
||||
install_script: scripts/install-mobileraker-companion.sh
|
||||
MOONRAKER_CONF
|
||||
|
||||
fi
|
||||
|
||||
patched="true"
|
||||
done
|
||||
|
||||
if [[ ${patched} == "true" ]]; then
|
||||
do_action_service "restart" "moonraker"
|
||||
fi
|
||||
}
|
||||
@@ -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[@]"
|
||||
}
|
||||
|
||||
#===================================================#
|
||||
|
||||
@@ -27,14 +27,16 @@ function install_ui() {
|
||||
echo -e "| 3) [Mainsail] | 8) [Telegram Bot] |"
|
||||
echo -e "| 4) [Fluidd] | 9) $(obico_install_title) |"
|
||||
echo -e "| | 10) [OctoEverywhere] |"
|
||||
echo -e "| | 11) [Mobileraker] |"
|
||||
echo -e "| Touchscreen GUI: | |"
|
||||
echo -e "| 5) [KlipperScreen] | Webcam Streamer: |"
|
||||
echo -e "| | 11) [Crowsnest] |"
|
||||
echo -e "| | 12) [Crowsnest] |"
|
||||
back_footer
|
||||
}
|
||||
|
||||
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
|
||||
@@ -68,6 +70,8 @@ function install_menu() {
|
||||
10)
|
||||
do_action "octoeverywhere_setup_dialog" "install_ui";;
|
||||
11)
|
||||
do_action "install_mobileraker" "install_ui";;
|
||||
12)
|
||||
do_action "install_crowsnest" "install_ui";;
|
||||
B|b)
|
||||
clear; main_menu; break;;
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
set -e
|
||||
|
||||
function main_ui() {
|
||||
echo -e "${yellow}/=======================================================\\"
|
||||
echo -e "| Please read the newest changelog carefully: |"
|
||||
echo -e "| https://git.io/JnmlX |"
|
||||
echo -e "\=======================================================/${white}"
|
||||
top_border
|
||||
echo -e "| $(title_msg "~~~~~~~~~~~~~~~ [ Main Menu ] ~~~~~~~~~~~~~~~") |"
|
||||
hr
|
||||
@@ -32,8 +28,11 @@ function main_ui() {
|
||||
echo -e "| | Crowsnest: $(print_status "crowsnest")|"
|
||||
echo -e "| | Obico: $(print_status "moonraker_obico")|"
|
||||
echo -e "| | OctoEverywhere: $(print_status "octoeverywhere")|"
|
||||
echo -e "| | Mobileraker: $(print_status "mobileraker")|"
|
||||
echo -e "| | |"
|
||||
echo -e "| $(print_kiauh_version)| Octoprint: $(print_status "octoprint")|"
|
||||
echo -e "| | Octoprint: $(print_status "octoprint")|"
|
||||
hr
|
||||
echo -e "| $(print_kiauh_version)| Changelog: ${magenta}https://git.io/JnmlX${white} |"
|
||||
quit_footer
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,8 @@ function remove_ui() {
|
||||
echo -e "| | 12) [Telegram Bot] |"
|
||||
echo -e "| Touchscreen GUI: | 13) [Obico for Klipper] |"
|
||||
echo -e "| 7) [KlipperScreen] | 14) [OctoEverywhere] |"
|
||||
echo -e "| | 15) [NGINX] |"
|
||||
echo -e "| | 15) [Mobileraker] |"
|
||||
echo -e "| | 16) [NGINX] |"
|
||||
back_footer
|
||||
}
|
||||
|
||||
@@ -69,6 +70,8 @@ function remove_menu() {
|
||||
14)
|
||||
do_action "remove_octoeverywhere" "remove_ui";;
|
||||
15)
|
||||
do_action "remove_mobileraker" "remove_ui";;
|
||||
16)
|
||||
do_action "remove_nginx" "remove_ui";;
|
||||
B|b)
|
||||
clear; main_menu; break;;
|
||||
|
||||
@@ -33,13 +33,15 @@ function update_ui() {
|
||||
echo -e "| 7) [Telegram Bot] |$(compare_telegram_bot_versions)|"
|
||||
echo -e "| 8) [Obico for Klipper]|$(compare_moonraker_obico_versions)|"
|
||||
echo -e "| 9) [OctoEverywhere] |$(compare_octoeverywhere_versions)|"
|
||||
echo -e "| 10) [Crowsnest] |$(compare_crowsnest_versions)|"
|
||||
echo -e "| 10) [Mobileraker] |$(compare_mobileraker_versions)|"
|
||||
echo -e "| 11) [Crowsnest] |$(compare_crowsnest_versions)|"
|
||||
echo -e "| |------------------------------|"
|
||||
echo -e "| 11) [System] | $(check_system_updates) |"
|
||||
echo -e "| 12) [System] | $(check_system_updates) |"
|
||||
back_footer
|
||||
}
|
||||
|
||||
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
|
||||
@@ -67,9 +69,11 @@ function update_menu() {
|
||||
9)
|
||||
do_action "update_octoeverywhere" "update_ui";;
|
||||
10)
|
||||
do_action "update_crowsnest" "update_ui";;
|
||||
do_action "update_mobileraker" "update_ui";;
|
||||
11)
|
||||
do_action "update_system" "update_ui";;
|
||||
do_action "update_crowsnest" "update_ui";;
|
||||
12)
|
||||
do_action "upgrade_system_packages" "update_ui";;
|
||||
a)
|
||||
do_action "update_all" "update_ui";;
|
||||
B|b)
|
||||
@@ -123,6 +127,9 @@ function update_all() {
|
||||
[[ "${update_arr[*]}" =~ "octoeverywhere" ]] && \
|
||||
echo -e "| ${cyan}● OctoEverywhere${white} |"
|
||||
|
||||
[[ "${update_arr[*]}" =~ "mobileraker" ]] && \
|
||||
echo -e "| ${cyan}● Mobileraker${white} |"
|
||||
|
||||
[[ "${update_arr[*]}" =~ "system" ]] && \
|
||||
echo -e "| ${cyan}● System${white} |"
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -293,7 +295,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
|
||||
@@ -311,12 +313,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
|
||||
@@ -366,27 +368,78 @@ function create_required_folders() {
|
||||
done
|
||||
}
|
||||
|
||||
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
|
||||
log_warning "Failure determining package cache age, forcing update"
|
||||
cache_mtime=0
|
||||
fi
|
||||
|
||||
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 check_system_updates() {
|
||||
local updates_avail info_msg
|
||||
updates_avail=$(apt list --upgradeable 2>/dev/null | sed "1d")
|
||||
local updates_avail status
|
||||
if ! update_system_package_lists --silent; then
|
||||
status="${red}Update check failed! ${white}"
|
||||
else
|
||||
updates_avail="$(apt list --upgradeable 2>/dev/null | sed "1d")"
|
||||
|
||||
if [[ -n ${updates_avail} ]]; then
|
||||
info_msg="${yellow}System upgrade available!${white}"
|
||||
status="${yellow}System upgrade available!${white}"
|
||||
# add system to application_updates_available in kiauh.ini
|
||||
add_to_application_updates "system"
|
||||
else
|
||||
info_msg="${green}System up to date! ${white}"
|
||||
status="${green}System up to date! ${white}"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "${info_msg}"
|
||||
echo "${status}"
|
||||
}
|
||||
|
||||
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 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 update failed! Please watch for any errors printed above!"
|
||||
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