This commit is contained in:
lrgex
2023-11-14 13:19:18 +03:00
parent 99c09d74ef
commit 50868379f0
6 changed files with 167 additions and 9 deletions

View File

@@ -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

View File

@@ -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 -

45
scripts/fluidd.exp Normal file
View File

@@ -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
}
}

View File

@@ -1 +0,0 @@
# an expect script

54
scripts/klipper.exp Normal file
View File

@@ -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
}
}

45
scripts/moonraker.exp Normal file
View File

@@ -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
}
}