From 50868379f06c10223a33cf10e57d7c8d8c672cae Mon Sep 17 00:00:00 2001 From: lrgex Date: Tue, 14 Nov 2023 13:19:18 +0300 Subject: [PATCH] v2.0.0 --- Dockerfile | 9 ++---- scripts/docker-entrypoint.sh | 22 +++++++++++++-- scripts/fluidd.exp | 45 ++++++++++++++++++++++++++++++ scripts/kiauh.exp | 1 - scripts/klipper.exp | 54 ++++++++++++++++++++++++++++++++++++ scripts/moonraker.exp | 45 ++++++++++++++++++++++++++++++ 6 files changed, 167 insertions(+), 9 deletions(-) create mode 100644 scripts/fluidd.exp delete mode 100644 scripts/kiauh.exp create mode 100644 scripts/klipper.exp create mode 100644 scripts/moonraker.exp diff --git a/Dockerfile b/Dockerfile index e2f1b4c..577ab24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -76,19 +76,16 @@ WORKDIR /opt/lrgex/kiauh COPY scripts/ /opt/lrgex/kiauh/ # Make files in /opt/lrgex/kiauh executable -RUN find /opt/lrgex/kiauh -type f -exec chmod +x {} \; +RUN find /opt/lrgex/kiauh -type f -exec chmod +x {} \; \ + && git config --global --add safe.directory /opt/lrgex/kiauh # Set the default shell to bash instead of sh beacuse kiauh needs this terminal ENV TERM xterm -COPY scripts/docker-entrypoint.sh /usr/local/bin/ -RUN chmod +x /usr/local/bin/docker-entrypoint.sh - - # Enable systemd init system in the container VOLUME [ "/tmp", "/run", "/run/lock" ] # Set the entrypoint -ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"] +ENTRYPOINT ["/opt/lrgex/kiauh/docker-entrypoint.sh"] # sudo docker run -d --name klipper -p 8562:80 --privileged --cap-add SYS_ADMIN --security-opt seccomp=unconfined --cgroup-parent=docker.slice --cgroupns private --tmpfs /tmp --tmpfs /run --tmpfs /run/lock klipper \ No newline at end of file diff --git a/scripts/docker-entrypoint.sh b/scripts/docker-entrypoint.sh index 457443b..d89700d 100644 --- a/scripts/docker-entrypoint.sh +++ b/scripts/docker-entrypoint.sh @@ -8,7 +8,7 @@ cat << "EOF" ╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝ ╦╔═┬ ┬┌─┐┌─┐┌─┐┬─┐ ╠╩╗│ │├─┘├─┘├┤ ├┬┘ -╩ ╩┴─┘┴┴ ┴ └─┘┴└─ v1.5.1 +╩ ╩┴─┘┴┴ ┴ └─┘┴└─ v2.0.0 EOF ##################### Starting code ##################### @@ -25,6 +25,24 @@ else echo "NGINX is already running." fi +packages_str=$PACKAGES +IFS=' ' read -r -a packages_array <<< "$packages_str" + +for package in "${packages_array[@]}"; do + if [ "${package}" = "klipper" ] && [ ! -d "/home/lrgex/klipper" ]; then + echo "Installing Klipper with Kiauh..." + su lrgex -c 'expect ./klipper.exp' + fi + if [ "${package}" = "moonraker" ] && [ ! -d "/home/lrgex/moonraker" ]; then + echo "Installing Moonraker with Kiauh..." + su lrgex -c 'expect ./moonraker.exp' + fi + if [ "${package}" = "fluidd" ] && [ ! -d "/home/lrgex/fluidd" ]; then + echo "Installing Fluidd with Kiauh..." + su lrgex -c 'expect ./fluidd.exp' + fi +done + ##################### End code ##################### @@ -39,5 +57,5 @@ exec /lib/systemd/systemd log-level=info unit=sysinit.target -exec "$@" & wait # This is needed to run other scripts or commands when running the container like docker run -it --rm backarosa:latest /bin/bash, backup,restore,container_start,container_stop ..etc +#exec "$@" & wait # This is needed to run other scripts or commands when running the container like docker run -it --rm backarosa:latest /bin/bash, backup,restore,container_start,container_stop ..etc #so when you run the container it will run only one command from scripts folder and exit, however commands in line 3 and 4 will run on every docker run - mandatory hard coded - \ No newline at end of file diff --git a/scripts/fluidd.exp b/scripts/fluidd.exp new file mode 100644 index 0000000..88095ec --- /dev/null +++ b/scripts/fluidd.exp @@ -0,0 +1,45 @@ +#!/usr/bin/expect + +# expect used tcl syntax which is very indetaion and spaces sensitive keep that in mind + + +# Set timeout +set timeout 60 + +# Start your process +spawn /opt/lrgex/kiauh/kiauh.sh + +# Initialize a variable to control the menu interaction +set menu 1 + +# Single expect block with multiple patterns +expect { + "*Main Menu*" { + # 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" + exp_continue + } else { + send "q\r" + exp_continue + } + } + "*Installation Menu*" { + if {$menu} { + send "4\r" + exp_continue + } else { + send "b\r" + exp_continue + } + } + "*Download the recommended macros? (Y/n)*" { + send "y\r" + set menu 0 + exp_continue + } + timeout { + puts "Operation timed out" + exit 1 + } +} \ No newline at end of file diff --git a/scripts/kiauh.exp b/scripts/kiauh.exp deleted file mode 100644 index 923768e..0000000 --- a/scripts/kiauh.exp +++ /dev/null @@ -1 +0,0 @@ -# an expect script diff --git a/scripts/klipper.exp b/scripts/klipper.exp new file mode 100644 index 0000000..5abf939 --- /dev/null +++ b/scripts/klipper.exp @@ -0,0 +1,54 @@ +#!/usr/bin/expect + +# expect used tcl syntax which is very indetaion and spaces sensitive keep that in mind + + +# Set timeout +set timeout 60 + +# Start your process +spawn /opt/lrgex/kiauh/kiauh.sh + +# Initialize a variable to control the menu interaction +set menu 1 + +# Single expect block with multiple patterns +expect { + "*Main Menu*" { + # 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" + exp_continue + } else { + send "q\r" + exp_continue + } + } + "*Installation Menu*" { + if {$menu} { + send "1\r" + exp_continue + } else { + send "b\r" + exp_continue + } + } + "*Initializing Klipper installation*" { + send "\r" + exp_continue + } + "*Setting up too many instances may crash your system*" { + send "\r" + exp_continue + } + "*WARNING: Your current user is not in group:*" { + send "y\r" + # Change the condition to stop interacting with menus + set menu 0 + exp_continue + } + timeout { + puts "Operation timed out" + exit 1 + } +} \ No newline at end of file diff --git a/scripts/moonraker.exp b/scripts/moonraker.exp new file mode 100644 index 0000000..c871a8d --- /dev/null +++ b/scripts/moonraker.exp @@ -0,0 +1,45 @@ +#!/usr/bin/expect + +# expect used tcl syntax which is very indetaion and spaces sensitive keep that in mind + + +# Set timeout +set timeout 60 + +# Start your process +spawn /opt/lrgex/kiauh/kiauh.sh + +# Initialize a variable to control the menu interaction +set menu 1 + +# Single expect block with multiple patterns +expect { + "*Main Menu*" { + # 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" + exp_continue + } else { + send "q\r" + exp_continue + } + } + "*Installation Menu*" { + if {$menu} { + send "2\r" + exp_continue + } else { + send "b\r" + exp_continue + } + } + "*Initializing Moonraker installation*" { + send "y\r" + set menu 0 + exp_continue + } + timeout { + puts "Operation timed out" + exit 1 + } +} \ No newline at end of file