feat(octoeverywhere): implement update function #310

Merged
dw-0 merged 2 commits from oe-updater into master 2023-03-11 20:25:17 +01:00
2 changed files with 46 additions and 3 deletions
Showing only changes of commit 6e0351a924 - Show all commits

View File

@@ -70,6 +70,7 @@ function set_globals() {
MOONRAKER_OBICO_REPO="https://github.com/TheSpaghettiDetective/moonraker-obico.git"
#=============== OCTOEVERYWHERE ================#
OCTOEVERYWHERE_ENV="${HOME}/octoeverywhere-env"
OCTOEVERYWHERE_DIR="${HOME}/octoeverywhere"
OCTOEVERYWHERE_REPO="https://github.com/QuinnDamerell/OctoPrint-OctoEverywhere.git"

View File

@@ -273,9 +273,51 @@ function remove_octoeverywhere()
#===================================================#
function update_octoeverywhere() {
# Since our update might require new python packages or system packages, ask the user to use the
# moonraker update manager to do it, since that takes care of it.
print_error "Please use the Moonraker Update Manager from the Mainsail or Fluidd UI to update OctoEverywhere.\n Contact our support team if you need help! support@octoeverywhere.com"
do_action_service "stop" "octoeverywhere"
if [[ ! -d ${OCTOEVERYWHERE_DIR} ]]; then
clone_moonraker "${OCTOEVERYWHERE_DIR}"
QuinnDamerell commented 2023-03-11 00:16:41 +01:00 (Migrated from github.com)
Review

Will this handle the octoeveryhere-* other possible service names?

Will this handle the octoeveryhere-* other possible service names?
dw-0 commented 2023-03-11 08:37:52 +01:00 (Migrated from github.com)
Review

Yes, calling that function handles all services beginning with "octoeverywhere".

Yes, calling that function handles all services beginning with "octoeverywhere".
else
backup_before_update "octoeverywhere"
status_msg "Updating OctoEverywhere for Klipper ..."
cd "${OCTOEVERYWHERE_DIR}" && git pull
### read PKGLIST and install possible new dependencies
install_octoeverywhere_dependencies
### install possible new python dependencies
"${OCTOEVERYWHERE_ENV}"/bin/pip install -r "${OCTOEVERYWHERE_DIR}/requirements.txt"
fi
ok_msg "Update complete!"
QuinnDamerell commented 2023-03-11 00:19:49 +01:00 (Migrated from github.com)
Review

I don't know much about virtual environments, but I assume this installs into it? The only way I have interactive with virtual envs is by using the /bin/activate the script.

I don't know much about virtual environments, but I assume this installs into it? The only way I have interactive with virtual envs is by using the /bin/activate the script.
dw-0 commented 2023-03-11 08:39:29 +01:00 (Migrated from github.com)
Review

Correct, i added the evn you create during setup to the global variables and with that command i just run pip from that env and install possible new python deps into that specific env.

Correct, i added the evn you create during setup to the global variables and with that command i just run pip from that env and install possible new python deps into that specific env.
do_action_service "restart" "octoeverywhere"
}
function install_octoeverywhere_dependencies() {
local packages
local install_script="${OCTOEVERYWHERE_DIR}/install.sh"
### read PKGLIST from official install-script
status_msg "Reading dependencies..."
# shellcheck disable=SC2016
packages="$(grep "PKGLIST=" "${install_script}" | cut -d'"' -f2 | sed 's/\${PKGLIST}//g' | tr -d '\n')"
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
QuinnDamerell commented 2023-03-11 00:23:25 +01:00 (Migrated from github.com)
Review

This is great!

This is great!
### 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
}
#===================================================#