Files
kiauh/scripts/update.sh

188 lines
6.0 KiB
Bash
Executable File

update_kiauh(){
if [ "$KIAUH_UPDATE_AVAIL" = "true" ]; then
status_msg "Updating KIAUH ..."
cd ${SRCDIR}/kiauh
### force reset kiauh before updating
git reset --hard
git pull && ok_msg "Update complete! Please restart KIAUH."
exit -1
fi
}
update_all(){
while true; do
if [ "${#update_arr[@]}" = "0" ]; then
CONFIRM_MSG="Everything is already up to date!"
echo; break
fi
echo
top_border
echo -e "| The following installations will be updated: |"
if [ "$KLIPPER_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Klipper${default} |"
fi
if [ "$DWC2FK_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● DWC2-for-Klipper-Socket${default} |"
fi
if [ "$DWC2_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Duet Web Control${default} |"
fi
if [ "$MOONRAKER_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Moonraker${default} |"
fi
if [ "$MAINSAIL_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Mainsail${default} |"
fi
if [ "$FLUIDD_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● Fluidd${default} |"
fi
if [ "$KLIPPERSCREEN_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● KlipperScreen${default} |"
fi
if [ "$SYS_UPDATE_AVAIL" = "true" ]; then
echo -e "| ${cyan}● System${default} |"
fi
bottom_border
if [ "${#update_arr[@]}" != "0" ]; then
read -p "${cyan}###### Do you want to proceed? (Y/n):${default} " yn
case "$yn" in
Y|y|Yes|yes|"")
for update in ${update_arr[@]}
do
$update
done
break;;
N|n|No|no)
break;;
*)
print_unkown_cmd
print_msg && clear_msg;;
esac
fi
done
}
update_klipper(){
klipper_service "stop"
if [ ! -d $KLIPPER_DIR ]; then
cd ${HOME} && git clone $KLIPPER_REPO
else
bb4u "klipper"
read_branch
save_klipper_state
status_msg "Updating $GET_BRANCH"
cd $KLIPPER_DIR
if [ "$DETACHED_HEAD" == "true" ]; then
git checkout $GET_BRANCH
unset DETACHED_HEAD
fi
### get current klippy-requirements.txt md5sum
KLIPPER_OLDREQ_MD5SUM="$(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1)"
### pull latest files from github
git pull
### read PKGLIST and install possible new dependencies
install_klipper_packages
### get possible new klippy-requirements.txt md5sum
KLIPPER_NEWREQ_MD5SUM="$(md5sum $KLIPPER_DIR/scripts/klippy-requirements.txt | cut -d " " -f1)"
### check for possible new dependencies and install them
if [[ $KLIPPER_NEWREQ_MD5SUM != $KLIPPER_OLDREQ_MD5SUM ]]; then
PYTHONDIR="${HOME}/klippy-env"
status_msg "New dependecies detected..."
### always rebuild the pythondir from scratch if new dependencies were detected
rm -rf ${PYTHONDIR}
virtualenv -p python2 ${PYTHONDIR}
$PYTHONDIR/bin/pip install -r $KLIPPER_DIR/scripts/klippy-requirements.txt
ok_msg "Dependencies have been installed!"
fi
ok_msg "Update complete!"
fi
klipper_service "restart"
}
update_dwc2fk(){
dwc_service "stop"
bb4u "dwc2"
if [ ! -d $DWC2FK_DIR ]; then
cd ${HOME} && git clone $DWC2FK_REPO
else
cd $DWC2FK_DIR && git pull
fi
dwc_service "start"
}
update_dwc2(){
bb4u "dwc2"
download_dwc_webui
}
update_mainsail(){
bb4u "mainsail"
status_msg "Updating Mainsail ..."
mainsail_setup
}
update_fluidd(){
bb4u "fluidd"
status_msg "Updating Fluidd ..."
fluidd_setup
}
update_moonraker(){
moonraker_service "stop"
bb4u "moonraker"
status_msg "Updating Moonraker ..."
cd $MOONRAKER_DIR
### get current moonraker-requirements.txt md5sum
MOONRAKER_OLDREQ_MD5SUM=$(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1)
### pull latest files from github
git pull
### read PKGLIST and install possible new dependencies
install_moonraker_packages
### get possible new moonraker-requirements.txt md5sum
MOONRAKER_NEWREQ_MD5SUM=$(md5sum $MOONRAKER_DIR/scripts/moonraker-requirements.txt | cut -d " " -f1)
### check for possible new dependencies and install them
if [[ $MOONRAKER_NEWREQ_MD5SUM != $MOONRAKER_OLDREQ_MD5SUM ]]; then
PYTHONDIR="${HOME}/moonraker-env"
status_msg "New dependecies detected..."
### always rebuild the pythondir from scratch if new dependencies were detected
rm -rf ${PYTHONDIR}
virtualenv -p /usr/bin/python3 ${PYTHONDIR}
ln -s /usr/lib/python3/dist-packages/gpiod* ${PYTHONDIR}/lib/python*/site-packages
${PYTHONDIR}/bin/pip install -r $MOONRAKER_DIR/scripts/moonraker-requirements.txt
ok_msg "Dependencies have been installed!"
fi
ok_msg "Update complete!"
moonraker_service "restart"
}
update_klipperscreen(){
stop_klipperscreen
cd $KLIPPERSCREEN_DIR
KLIPPERSCREEN_OLDREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1)
git pull origin master -q && ok_msg "Fetch successfull!"
git checkout -f origin/master && ok_msg "Checkout successfull"
#KLIPPERSCREEN_NEWREQ_MD5SUM=$(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt)
if [[ $(md5sum $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt | cut -d " " -f1) != $KLIPPERSCREEN_OLDREQ_MD5SUM ]]; then
status_msg "New dependecies detected..."
PYTHONDIR="${HOME}/.KlipperScreen-env"
$PYTHONDIR/bin/pip install -r $KLIPPERSCREEN_DIR/scripts/KlipperScreen-requirements.txt
ok_msg "Dependencies have been installed!"
fi
ok_msg "Update complete!"
start_klipperscreen
}
update_system(){
status_msg "Updating System ..."
sudo apt-get update && sudo apt-get upgrade -y
ok_msg "Update complete! Check the log above!"
ok_msg "KIAUH won't do any dist-upgrades!\n"
}