mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-15 03:24:29 +05:00
add: support for new dwc-for-klipper-socket by @Stephan3
This will replace the previous installer for dwc2-for-klipper without substitution. dwc2-for-klipper won't be maintained anymore.
This commit is contained in:
@@ -4,11 +4,10 @@ install_dwc2(){
|
||||
#ask user for customization
|
||||
get_user_selections_dwc2
|
||||
#dwc2 main installation
|
||||
tornado_setup
|
||||
stop_klipper
|
||||
dwc2_setup
|
||||
#setup config
|
||||
write_printer_cfg_dwc2
|
||||
write_custom_printer_cfg_dwc2
|
||||
#execute customizations
|
||||
disable_octoprint
|
||||
create_reverse_proxy "dwc2"
|
||||
@@ -22,7 +21,6 @@ install_dwc2(){
|
||||
|
||||
system_check_dwc2(){
|
||||
status_msg "Initializing DWC2 installation ..."
|
||||
stop_klipper
|
||||
check_for_folder_dwc2
|
||||
#check for existing printer.cfg
|
||||
locate_printer_cfg
|
||||
@@ -42,46 +40,26 @@ get_user_selections_dwc2(){
|
||||
#user selection for printer.cfg
|
||||
if [ "$PRINTER_CFG_FOUND" = "false" ]; then
|
||||
unset SEL_DEF_CFG
|
||||
unset SEL_CUS_CFG
|
||||
while true; do
|
||||
echo
|
||||
top_border
|
||||
echo -e "| ${red}WARNING! - No printer.cfg was found!${default} |"
|
||||
hr
|
||||
echo -e "| You can now either select to create a printer.cfg |"
|
||||
echo -e "| with the default entries (1), customize the settings |"
|
||||
echo -e "| before writing them (2) or you can skip the creation |"
|
||||
echo -e "| of a printer.cfg at all. |"
|
||||
echo -e "| KIAUH can create a minimal printer.cfg with only the |"
|
||||
echo -e "| necessary config entries if you wish. |"
|
||||
echo -e "| |"
|
||||
echo -e "| Please keep in mind that DWC2 will ONLY load if you |"
|
||||
echo -e "| have a correctly defined printer.cfg. Any missing |"
|
||||
echo -e "| option or error will prevent DWC2 from loading and |"
|
||||
echo -e "| you need to check klippy.log to resolve the error. |"
|
||||
echo -e "| |"
|
||||
echo -e "| ${red}Neither option 1 or 2 of this script will create a |"
|
||||
echo -e "| fully working printer.cfg for you!${default} |"
|
||||
hr
|
||||
echo -e "| 1) [Create default configuration] |"
|
||||
echo -e "| 2) [Create custom configuration] |"
|
||||
echo -e "| 3) ${red}[Skip]${default} |"
|
||||
echo -e "| Please be aware, that this option will ${red}NOT${default} create a |"
|
||||
echo -e "| fully working printer.cfg for you! |"
|
||||
bottom_border
|
||||
read -p "${cyan}###### Please select:${default} " choice
|
||||
case "$choice" in
|
||||
1)
|
||||
echo -e "###### > Create default configuration"
|
||||
read -p "${cyan}###### Create a default printer.cfg? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
echo -e "###### > Yes"
|
||||
SEL_DEF_CFG="true"
|
||||
SEL_CUS_CFG="false"
|
||||
break;;
|
||||
2)
|
||||
echo -e "###### > Create custom configuration"
|
||||
N|n|No|no)
|
||||
echo -e "###### > No"
|
||||
SEL_DEF_CFG="false"
|
||||
SEL_CUS_CFG="true"
|
||||
break;;
|
||||
3)
|
||||
echo -e "###### > Skip"
|
||||
SEL_DEF_CFG="false"
|
||||
SEL_CUS_CFG="false"
|
||||
echo "${red}Skipping ...${default}"
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
@@ -130,21 +108,8 @@ get_user_selections_dwc2(){
|
||||
|
||||
check_for_folder_dwc2(){
|
||||
#check for needed folder
|
||||
if [ ! -d $DWC2_DIR/web ]; then
|
||||
mkdir -p $DWC2_DIR/web
|
||||
fi
|
||||
}
|
||||
|
||||
tornado_setup(){
|
||||
if [ "$(cd $KLIPPY_ENV_DIR/bin/ && $_/pip list 2>/dev/null | grep "tornado" | cut -d" " -f9)" = "5.1.1" ]; then
|
||||
ok_msg "Tornado 5.1.1 is already installed! Continue..."
|
||||
else
|
||||
status_msg "Installing Tornado 5.1.1 ..."
|
||||
cd ${HOME}
|
||||
PYTHONDIR="${HOME}/klippy-env"
|
||||
virtualenv ${PYTHONDIR}
|
||||
${PYTHONDIR}/bin/pip install tornado==5.1.1
|
||||
ok_msg "Tornado 5.1.1 successfully installed!"
|
||||
if [ ! -d $DWC2_DIR ]; then
|
||||
mkdir -p $DWC2_DIR
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -154,20 +119,43 @@ dwc2_setup(){
|
||||
dependency_check
|
||||
#get dwc2-for-klipper
|
||||
cd ${HOME}
|
||||
status_msg "Cloning DWC2-for-Klipper repository ..."
|
||||
status_msg "Cloning DWC2-for-Klipper-Socket repository ..."
|
||||
git clone $DWC2FK_REPO
|
||||
ok_msg "DWC2-for-Klipper successfully cloned!"
|
||||
#create a web_dwc2.py symlink if not already existing
|
||||
if [ -d $KLIPPER_DIR/klippy/extras ] && [ ! -e $KLIPPER_DIR/klippy/extras/web_dwc2.py ]; then
|
||||
status_msg "Creating web_dwc2.py Symlink ..."
|
||||
ln -s $DWC2FK_DIR/web_dwc2.py $KLIPPER_DIR/klippy/extras/web_dwc2.py
|
||||
ok_msg "Symlink created!"
|
||||
#copy installers from kiauh srcdir to dwc-for-klipper-socket
|
||||
status_msg "Copy installers to $DWC2FK_DIR"
|
||||
cp -r ${SRCDIR}/kiauh/scripts/dwc2-for-klipper-socket-installer $DWC2FK_DIR/scripts
|
||||
ok_msg "Done!"
|
||||
status_msg "Starting service-installer ..."
|
||||
$DWC2FK_DIR/scripts/install-octopi.sh
|
||||
ok_msg "Service installed!"
|
||||
#patch /etc/default/klipper to append the uds argument
|
||||
patch_klipper_sysfile_dwc2
|
||||
#download Duet Web Control
|
||||
download_dwc2_webui
|
||||
}
|
||||
|
||||
patch_klipper_sysfile_dwc2(){
|
||||
status_msg "Checking /etc/default/klipper for necessary entries ..."
|
||||
#patching new UDS argument to /etc/default/klipper
|
||||
if ! grep -q -- "-a /tmp/klippy_uds" $KLIPPER_SERVICE2; then
|
||||
status_msg "Patching unix domain socket to /etc/default/klipper ..."
|
||||
#append the new argument to /tmp/klippy.log argument
|
||||
sudo sed -i "/KLIPPY_ARGS/s/\.log/\.log -a \/tmp\/klippy_uds/" $KLIPPER_SERVICE2
|
||||
ok_msg "Patching done!"
|
||||
else
|
||||
ok_msg "No patching needed!"
|
||||
fi
|
||||
ok_msg "Check complete!"
|
||||
echo
|
||||
}
|
||||
|
||||
download_dwc2_webui(){
|
||||
#get Duet Web Control
|
||||
GET_DWC2_URL=`curl -s https://api.github.com/repositories/28820678/releases/latest | grep browser_download_url | cut -d'"' -f4`
|
||||
cd $DWC2_DIR/web
|
||||
cd $DWC2_DIR
|
||||
status_msg "Downloading DWC2 Web UI ..."
|
||||
wget -q $GET_DWC2_URL
|
||||
wget $GET_DWC2_URL
|
||||
ok_msg "Download complete!"
|
||||
status_msg "Unzipping archive ..."
|
||||
unzip -q -o *.zip
|
||||
@@ -177,7 +165,7 @@ dwc2_setup(){
|
||||
done
|
||||
ok_msg "Done!"
|
||||
status_msg "Writing DWC version to file ..."
|
||||
echo $GET_DWC2_URL | cut -d/ -f8 > $DWC2_DIR/web/version
|
||||
echo $GET_DWC2_URL | cut -d/ -f8 > $DWC2_DIR/version
|
||||
ok_msg "Done!"
|
||||
status_msg "Do a little cleanup ..."
|
||||
rm -rf DuetWebControl-SD.zip
|
||||
@@ -198,11 +186,6 @@ setup_printer_config_dwc2(){
|
||||
create_default_dwc2_printer_cfg
|
||||
locate_printer_cfg
|
||||
fi
|
||||
if [ "$SEL_CUS_CFG" = "true" ]; then
|
||||
#get user input for custom config
|
||||
create_custom_dwc2_printer_cfg
|
||||
locate_printer_cfg
|
||||
fi
|
||||
}
|
||||
|
||||
read_printer_cfg_dwc2(){
|
||||
@@ -211,9 +194,6 @@ read_printer_cfg_dwc2(){
|
||||
if [ ! $(grep '^\[virtual_sdcard\]$' $PRINTER_CFG) ]; then
|
||||
VSD="false"
|
||||
fi
|
||||
if [ ! $(grep '^\[web_dwc2\]$' $PRINTER_CFG) ]; then
|
||||
WEB_DWC2="false"
|
||||
fi
|
||||
#check for a SAVE_CONFIG entry
|
||||
if [[ $(grep "$SC" $PRINTER_CFG) ]]; then
|
||||
SC_LINE=$(grep -n "$SC" $PRINTER_CFG | cut -d ":" -f1)
|
||||
@@ -226,9 +206,6 @@ read_printer_cfg_dwc2(){
|
||||
|
||||
write_printer_cfg_dwc2(){
|
||||
unset write_entries
|
||||
if [ "$WEB_DWC2" = "false" ]; then
|
||||
write_entries+=("[web_dwc2]\nprinter_name: my_printer\nlisten_adress: 0.0.0.0\nlisten_port: 4750\nweb_path: dwc2/web")
|
||||
fi
|
||||
if [ "$VSD" = "false" ]; then
|
||||
write_entries+=("[virtual_sdcard]\npath: ~/sdcard")
|
||||
fi
|
||||
@@ -255,17 +232,9 @@ write_printer_cfg_dwc2(){
|
||||
ok_msg "Done!"
|
||||
}
|
||||
|
||||
write_custom_printer_cfg_dwc2(){
|
||||
#create custom config
|
||||
if [ "$PRINTER_CFG_FOUND" = "false" ] && [ "$CONFIRM_CUSTOM_CFG" = "true" ]; then
|
||||
touch $PRINTER_CFG
|
||||
echo -e "$DWC2_CFG" >> $PRINTER_CFG
|
||||
fi
|
||||
}
|
||||
|
||||
create_default_dwc2_printer_cfg(){
|
||||
#create default config
|
||||
if [ "$PRINTER_CFG_FOUND" = "false" ] && [ "$SEL_CUS_CFG" = "true" ]; then
|
||||
if [ "$PRINTER_CFG_FOUND" = "false" ] && [ "$SEL_DEF_CFG" = "true" ]; then
|
||||
touch $PRINTER_CFG
|
||||
cat <<DEFAULT_DWC2_CFG >> $PRINTER_CFG
|
||||
##########################
|
||||
@@ -281,11 +250,6 @@ max_z_accel: 100
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
|
||||
[web_dwc2]
|
||||
printer_name: my_printer
|
||||
listen_adress: 0.0.0.0
|
||||
listen_port: 4750
|
||||
web_path: dwc2/web
|
||||
##########################
|
||||
DEFAULT_DWC2_CFG
|
||||
fi
|
||||
@@ -294,57 +258,6 @@ DEFAULT_DWC2_CFG
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
create_custom_dwc2_printer_cfg(){
|
||||
echo
|
||||
top_border
|
||||
echo -e "| Please fill in custom values for the following |"
|
||||
echo -e "| configuration options. If you are unsure what to put |"
|
||||
echo -e "| in, keep the pre-entered values. |"
|
||||
bottom_border
|
||||
echo -e "${cyan}"
|
||||
read -e -p "Printer name: " -i "my_printer" PRINTER_NAME
|
||||
read -e -p "Listen adress: " -i "0.0.0.0" LISTEN_ADRESS
|
||||
read -e -p "Listen port: " -i "4750" LISTEN_PORT
|
||||
read -e -p "Web path: " -i "dwc2/web" WEB_PATH
|
||||
echo -e "${default}"
|
||||
DWC2_CFG=$(cat <<DWC2
|
||||
##########################
|
||||
### CREATED WITH KIAUH ###
|
||||
##########################
|
||||
[virtual_sdcard]
|
||||
path: ~/sdcard
|
||||
|
||||
[web_dwc2]
|
||||
printer_name: $PRINTER_NAME
|
||||
listen_adress: $LISTEN_ADRESS
|
||||
listen_port: $LISTEN_PORT
|
||||
web_path: $WEB_PATH
|
||||
##########################
|
||||
DWC2
|
||||
)
|
||||
echo "The following lines will be written:"
|
||||
echo -e "$DWC2_CFG"
|
||||
while true; do
|
||||
echo
|
||||
read -p "${cyan}###### Confirm (Y) or start over (n)? (Y/n):${default} " yn
|
||||
case "$yn" in
|
||||
Y|y|Yes|yes|"")
|
||||
CONFIRM_CUSTOM_CFG="true"
|
||||
break;;
|
||||
N|n|No|no)
|
||||
CONFIRM_CUSTOM_CFG="false"
|
||||
create_custom_dwc2_printer_cfg
|
||||
break;;
|
||||
*)
|
||||
print_unkown_cmd
|
||||
print_msg && clear_msg;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
#############################################################
|
||||
#############################################################
|
||||
|
||||
dwc2_reverse_proxy_dialog(){
|
||||
unset SET_REVERSE_PROXY
|
||||
echo
|
||||
|
||||
Reference in New Issue
Block a user