mirror of
https://github.com/dw-0/kiauh.git
synced 2025-12-14 19:14:27 +05:00
add: user choice for dwc service (init.d or systemd)
This commit is contained in:
@@ -37,6 +37,38 @@ system_check_dwc2(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
get_user_selections_dwc2(){
|
get_user_selections_dwc2(){
|
||||||
|
#let user choose to install systemd or init.d service
|
||||||
|
unset INST_SYSTEMD
|
||||||
|
unset INST_INITD
|
||||||
|
while true; do
|
||||||
|
echo
|
||||||
|
top_border
|
||||||
|
echo -e "| Do you wan't to install dwc2-for-klipper-socket as |"
|
||||||
|
echo -e "| 1) Init.d Service |"
|
||||||
|
echo -e "| 2) Systemd Service |"
|
||||||
|
hr
|
||||||
|
echo -e "| Please use the appropriate option for your chosen |"
|
||||||
|
echo -e "| Linux distribution. If you are unsure what to pick, |"
|
||||||
|
echo -e "| please do a research before. |"
|
||||||
|
hr
|
||||||
|
echo -e "| In case you are using Raspberry Pi OS, either option |"
|
||||||
|
echo -e "| 1 or 2 will work. |"
|
||||||
|
bottom_border
|
||||||
|
read -p "${cyan}###### Please choose:${default} " action
|
||||||
|
case "$action" in
|
||||||
|
1)
|
||||||
|
INST_INITD="true"
|
||||||
|
INST_SYSTEMD="false"
|
||||||
|
break;;
|
||||||
|
2)
|
||||||
|
INST_INITD="false"
|
||||||
|
INST_SYSTEMD="true"
|
||||||
|
break;;
|
||||||
|
*)
|
||||||
|
print_unkown_cmd
|
||||||
|
print_msg && clear_msg;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
#user selection for printer.cfg
|
#user selection for printer.cfg
|
||||||
if [ "$PRINTER_CFG_FOUND" = "false" ]; then
|
if [ "$PRINTER_CFG_FOUND" = "false" ]; then
|
||||||
unset SEL_DEF_CFG
|
unset SEL_DEF_CFG
|
||||||
@@ -127,7 +159,11 @@ dwc2_setup(){
|
|||||||
cp -r ${SRCDIR}/kiauh/scripts/dwc2-for-klipper-socket-installer $DWC2FK_DIR/scripts
|
cp -r ${SRCDIR}/kiauh/scripts/dwc2-for-klipper-socket-installer $DWC2FK_DIR/scripts
|
||||||
ok_msg "Done!"
|
ok_msg "Done!"
|
||||||
status_msg "Starting service-installer ..."
|
status_msg "Starting service-installer ..."
|
||||||
$DWC2FK_DIR/scripts/install-octopi.sh
|
if [ "$INST_INITD" = "true" ] && [ "$INST_SYSTEMD" = "false" ]; then
|
||||||
|
$DWC2FK_DIR/scripts/install-octopi.sh
|
||||||
|
elif [ "$INST_INITD" = "false" ] && [ "$INST_SYSTEMD" = "true" ]; then
|
||||||
|
$DWC2FK_DIR/scripts/install-debian.sh
|
||||||
|
fi
|
||||||
ok_msg "Service installed!"
|
ok_msg "Service installed!"
|
||||||
#patch /etc/default/klipper to append the uds argument
|
#patch /etc/default/klipper to append the uds argument
|
||||||
patch_klipper_sysfile_dwc2
|
patch_klipper_sysfile_dwc2
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ remove_dwc2(){
|
|||||||
data_arr=(
|
data_arr=(
|
||||||
/etc/init.d/dwc
|
/etc/init.d/dwc
|
||||||
/etc/default/dwc
|
/etc/default/dwc
|
||||||
|
/etc/systemd/system/dwc.service
|
||||||
$DWC2FK_DIR
|
$DWC2FK_DIR
|
||||||
$DWC_ENV_DIR
|
$DWC_ENV_DIR
|
||||||
$DWC2_DIR
|
$DWC2_DIR
|
||||||
@@ -42,15 +43,24 @@ remove_dwc2(){
|
|||||||
if [ "$ERROR_MSG" = "" ]; then
|
if [ "$ERROR_MSG" = "" ]; then
|
||||||
if systemctl is-active dwc -q; then
|
if systemctl is-active dwc -q; then
|
||||||
status_msg "Stopping DWC2-for-Klipper-Socket Service ..."
|
status_msg "Stopping DWC2-for-Klipper-Socket Service ..."
|
||||||
sudo /etc/init.d/dwc stop && sudo systemctl disable dwc
|
sudo systemctl stop dwc && sudo systemctl disable dwc
|
||||||
ok_msg "Service stopped!"
|
ok_msg "Service stopped!"
|
||||||
fi
|
fi
|
||||||
|
#remove if init.d service
|
||||||
if [[ -e /etc/init.d/dwc || -e /etc/default/dwc ]]; then
|
if [[ -e /etc/init.d/dwc || -e /etc/default/dwc ]]; then
|
||||||
|
status_msg "Init.d Service found ..."
|
||||||
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
|
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
|
||||||
sudo rm -rf /etc/init.d/dwc /etc/default/dwc
|
sudo rm -rf /etc/init.d/dwc /etc/default/dwc
|
||||||
sudo update-rc.d -f dwc remove
|
sudo update-rc.d -f dwc remove
|
||||||
ok_msg "DWC2-for-Klipper-Socket Service removed!"
|
ok_msg "DWC2-for-Klipper-Socket Service removed!"
|
||||||
fi
|
fi
|
||||||
|
#remove if systemd service
|
||||||
|
if [ -e /etc/systemd/system/dwc.service ]; then
|
||||||
|
status_msg "Systemd Service found ..."
|
||||||
|
status_msg "Removing DWC2-for-Klipper-Socket Service ..."
|
||||||
|
sudo rm -rf /etc/systemd/system/dwc.service
|
||||||
|
ok_msg "DWC2-for-Klipper-Socket Service removed!"
|
||||||
|
fi
|
||||||
if [ -d $DWC2FK_DIR ]; then
|
if [ -d $DWC2FK_DIR ]; then
|
||||||
status_msg "Removing DWC2-for-Klipper-Socket directory ..."
|
status_msg "Removing DWC2-for-Klipper-Socket directory ..."
|
||||||
rm -rf $DWC2FK_DIR && ok_msg "Directory removed!"
|
rm -rf $DWC2FK_DIR && ok_msg "Directory removed!"
|
||||||
|
|||||||
Reference in New Issue
Block a user