diff --git a/reference.txt b/reference.txt index ab016e7..516484a 100644 --- a/reference.txt +++ b/reference.txt @@ -17,22 +17,66 @@ sudo docker run -d --name klipper --device /dev/ttyUSB0:/dev/ttyUSB0 -p 5001:80 sudo docker run -d --name klipper -p 5001:80 -p 7125:7125 -e PACKAGES="klipper moonraker fluidd" --privileged --cap-add SYS_ADMIN --security-opt seccomp=unconfined --cgroup-parent=docker.slice --cgroupns private --tmpfs /tmp --tmpfs /run --tmpfs /run/lock lrgex/klipper-docker:2.0 -docker run -d \ + +sudo docker run -d --name klipper --device /dev/ttyUSB0:/dev/ttyUSB0 -p 5001:80 -p 7125:7125 -v klipper-config:/home/lrgex/printer_data --privileged --cap-add SYS_ADMIN --security-opt seccomp=unconfined --cgroup-parent=docker.slice --cgroupns private --tmpfs /tmp --tmpfs /run --tmpfs /run/lock klipper + + +sudo docker run -d \ +-e KEEP_VERSIONS="2" \ +-v /mnt/fastshare/klipper:/backup \ +-v klipper-config:/source:ro \ +-v /var/run/docker.sock:/var/run/docker.sock \ +-e LOCAL_BACKUP="true" \ +-e TZ="Asia/Riyadh" \ +--restart no \ +--name backarosa-klipper lrgex/backarosa backup + + + + +sudo docker run -d \ +--name klipper \ +--device /dev/ttyUSB0:/dev/ttyUSB0 \ +-p 5001:80 \ +-p 7125:7125 \ +-e PACKAGES="klipper moonraker fluidd" \ +-v klipper-config:/home/lrgex \ +--privileged \ +--cap-add SYS_ADMIN \ +--security-opt seccomp=unconfined \ +--cgroup-parent=docker.slice \ +--cgroupns private \ +--tmpfs /tmp \ +--tmpfs /run \ +--tmpfs /run/lock \ +lrgex/klipper-docker + + +sudo docker run -d \ -e KEEP_VERSIONS="2" \ -v /mnt/backups/klipper:/backup \ -v klipper-config:/source:ro \ -v /var/run/docker.sock:/var/run/docker.sock \ -e LOCAL_BACKUP="true" \ -e TZ="Asia/Riyadh" \ --e CRON="0 8 * * *" \ ---restart always \ +--restart no \ --name backarosa-klipper lrgex/backarosa backup + +docker run --rm \ +-v /mnt/backups/klipper:/backup \ +-v klipper-config:/source \ +-e LOCAL_BACKUP="true" \ +-e TZ="Asia/Riyadh" \ +-e RESTORE_VERSION="0" \ +lrgex/backarosa restore + + version: '3.8' services: klipper: - image: lrgex/klipper-docker:2.0 + image: klipper container_name: klipper privileged: true cap_add: @@ -46,7 +90,7 @@ services: - /run - /run/lock volumes: - - klipper-config:/home/lrgex/klipper/printer_data + - klipper-config:/home/lrgex/printer_data ports: - "5001:80" - "7125:7125" @@ -59,9 +103,9 @@ services: image: lrgex/backarosa container_name: klipper-backarosa restart: always - command: /bin/sh -c "sleep 180 && backup" + command: backup volumes: - - /mnt/backups/klipper:/backup + - /mnt/fastshare/klipper:/backup - klipper-config:/source:ro - /var/run/docker.sock:/var/run/docker.sock environment: @@ -72,4 +116,4 @@ services: volumes: klipper-config: - + external: true \ No newline at end of file diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index 4b58ef4..a476fda 100644 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -49,7 +49,7 @@ for package in "${packages_array[@]}"; do if [ "${package}" = "fluidd" ] && [ ! -d "/home/lrgex/fluidd" ] && [ ! -d "/home/lrgex/mainsail" ]; then echo "Installing Fluidd with Kiauh..." su lrgex -c 'expect ./fluidd.exp' - elif [ -d "/home/lrgex/mainsail" ]; then + elif [ -d "/home/lrgex/mainsail" ] && [ "${package}" = "fluidd" ]; then echo -e "\e[31mMainsail detected, skipping Fluidd installation.\e[0m" echo -e "\e[31mIf you want to install Fluidd, please re run the container without the Mainsail package. .e.g [-e PACKAGES=\"klipper moonraker fluidd\"]\e[0m" sleep 5 @@ -58,7 +58,7 @@ for package in "${packages_array[@]}"; do if [ "${package}" = "mainsail" ] && [ ! -d "/home/lrgex/mainsail" ] && [ ! -d "/home/lrgex/fluidd" ]; then echo "Installing Mainsail with Kiauh..." su lrgex -c 'expect ./mainsail.exp' - elif [ -d "/home/lrgex/fluidd" ]; then + elif [ -d "/home/lrgex/fluidd" ] && [ "${package}" = "mainsail" ]; then echo -e "\e[31mFluidd detected, skipping Mainsail installation.\e[0m" echo -e "\e[31mIf you want to install Mainsail, please re run the container without the Fluidd package. .e.g [-e PACKAGES=\"klipper moonraker mainsail\"]\e[0m" sleep 5 diff --git a/test/fluidd.exp b/test/fluidd.exp index 88095ec..f57eb78 100644 --- a/test/fluidd.exp +++ b/test/fluidd.exp @@ -4,7 +4,7 @@ # Set timeout -set timeout 60 +set timeout 300 # Start your process spawn /opt/lrgex/kiauh/kiauh.sh @@ -18,23 +18,28 @@ expect { # using condition here to make a break for the loop created by exp_continue as i need to use the pattern 2 times one for pressing 1 and one for pressing q if {$menu} { send "1\r" + sleep 3 exp_continue } else { send "q\r" + sleep 3 exp_continue } } "*Installation Menu*" { if {$menu} { send "4\r" + sleep 3 exp_continue } else { send "b\r" + sleep 3 exp_continue } } "*Download the recommended macros? (Y/n)*" { send "y\r" + sleep 3 set menu 0 exp_continue } diff --git a/test/klipper.exp b/test/klipper.exp index 5abf939..b336e84 100644 --- a/test/klipper.exp +++ b/test/klipper.exp @@ -4,7 +4,7 @@ # Set timeout -set timeout 60 +set timeout 300 # Start your process spawn /opt/lrgex/kiauh/kiauh.sh @@ -18,31 +18,38 @@ expect { # using condition here to make a break for the loop created by exp_continue as i need to use the pattern 2 times one for pressing 1 and one for pressing q if {$menu} { send "1\r" + sleep 3 exp_continue } else { send "q\r" + sleep 3 exp_continue } } "*Installation Menu*" { if {$menu} { send "1\r" + sleep 3 exp_continue } else { send "b\r" + sleep 3 exp_continue } } "*Initializing Klipper installation*" { send "\r" + sleep 3 exp_continue } "*Setting up too many instances may crash your system*" { send "\r" + sleep 3 exp_continue } "*WARNING: Your current user is not in group:*" { send "y\r" + sleep 3 # Change the condition to stop interacting with menus set menu 0 exp_continue diff --git a/test/mainsail.exp b/test/mainsail.exp index c906b97..6013b17 100644 --- a/test/mainsail.exp +++ b/test/mainsail.exp @@ -4,7 +4,7 @@ # Set timeout -set timeout 60 +set timeout 300 # Start your process spawn /opt/lrgex/kiauh/kiauh.sh @@ -18,23 +18,28 @@ expect { # using condition here to make a break for the loop created by exp_continue as i need to use the pattern 2 times one for pressing 1 and one for pressing q if {$menu} { send "1\r" + sleep 3 exp_continue } else { send "q\r" + sleep 3 exp_continue } } "*Installation Menu*" { if {$menu} { send "3\r" + sleep 3 exp_continue } else { send "b\r" + sleep 3 exp_continue } } "*Download the recommended macros? (Y/n):*" { send "y\r" + sleep 3 set menu 0 exp_continue } diff --git a/test/moonraker.exp b/test/moonraker.exp index c871a8d..87e1626 100644 --- a/test/moonraker.exp +++ b/test/moonraker.exp @@ -4,7 +4,7 @@ # Set timeout -set timeout 60 +set timeout 300 # Start your process spawn /opt/lrgex/kiauh/kiauh.sh @@ -18,23 +18,28 @@ expect { # using condition here to make a break for the loop created by exp_continue as i need to use the pattern 2 times one for pressing 1 and one for pressing q if {$menu} { send "1\r" + sleep 3 exp_continue } else { send "q\r" + sleep 3 exp_continue } } "*Installation Menu*" { if {$menu} { send "2\r" + sleep 3 exp_continue } else { send "b\r" + sleep 3 exp_continue } } "*Initializing Moonraker installation*" { send "y\r" + sleep 3 set menu 0 exp_continue } diff --git a/test/test-entrypoint.sh b/test/test-entrypoint.sh index 7f290f9..a476fda 100644 --- a/test/test-entrypoint.sh +++ b/test/test-entrypoint.sh @@ -8,11 +8,20 @@ cat << "EOF" ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╦╔═┬ ┬┌─┐┌─┐┌─┐┬─┐ ╠╩╗│ │├─┘├─┘├┤ ├┬┘ -╩ ╩┴─┘┴┴ ┴ └─┘┴└─ v2.0 +╩ ╩┴─┘┴┴ ┴ └─┘┴└─ v2.3 EOF ##################### Starting code ##################### +##################### Backarosa ##################### +backarosa=$(grep -c "restore done" /opt/lrgex/flags) +if [ ! $backarosa ]; then + echo "Backuping klipper files..." + cp -r /home/lrgex /tmp/lrgex +fi + +##################### End Backarosa ##################### + # This script will run on every container start if ! systemctl is-enabled nginx > /dev/null 2>&1; then echo "Enabling NGINX..." @@ -40,7 +49,7 @@ for package in "${packages_array[@]}"; do if [ "${package}" = "fluidd" ] && [ ! -d "/home/lrgex/fluidd" ] && [ ! -d "/home/lrgex/mainsail" ]; then echo "Installing Fluidd with Kiauh..." su lrgex -c 'expect ./fluidd.exp' - elif [ -d "/home/lrgex/mainsail" ]; then + elif [ -d "/home/lrgex/mainsail" ] && [ "${package}" = "fluidd" ]; then echo -e "\e[31mMainsail detected, skipping Fluidd installation.\e[0m" echo -e "\e[31mIf you want to install Fluidd, please re run the container without the Mainsail package. .e.g [-e PACKAGES=\"klipper moonraker fluidd\"]\e[0m" sleep 5 @@ -49,7 +58,7 @@ for package in "${packages_array[@]}"; do if [ "${package}" = "mainsail" ] && [ ! -d "/home/lrgex/mainsail" ] && [ ! -d "/home/lrgex/fluidd" ]; then echo "Installing Mainsail with Kiauh..." su lrgex -c 'expect ./mainsail.exp' - elif [ -d "/home/lrgex/fluidd" ]; then + elif [ -d "/home/lrgex/fluidd" ] && [ "${package}" = "mainsail" ]; then echo -e "\e[31mFluidd detected, skipping Mainsail installation.\e[0m" echo -e "\e[31mIf you want to install Mainsail, please re run the container without the Fluidd package. .e.g [-e PACKAGES=\"klipper moonraker mainsail\"]\e[0m" sleep 5 @@ -57,6 +66,13 @@ for package in "${packages_array[@]}"; do fi done +if [ "${RESTORE}" = "true" ] && [ ! $backarosa ]; then + echo "Restoring klipper files..." + cp -r /tmp/lrgex /home/lrgex + rm -rf /tmp/lrgex + echo "restore done" >> /opt/lrgex/flags +fi + ##################### End code ##################### diff --git a/testfile2 b/testfile2 index c958d77..81d5868 100644 --- a/testfile2 +++ b/testfile2 @@ -84,7 +84,7 @@ RUN find /opt/lrgex/kiauh -type f -exec chmod +x {} \; \ # Set the default shell to bash instead of sh beacuse kiauh needs this terminal ENV TERM xterm -# ENV KLIPPER="" + # COPY scripts/docker-entrypoint.sh /usr/local/bin/ # RUN chmod +x /usr/local/bin/docker-entrypoint.sh