Files
Klipper-docker/scripts/docker-entrypoint.sh

75 lines
3.7 KiB
Bash
Raw Normal View History

2023-11-13 14:28:28 +03:00
#!/bin/bash
cat << "EOF"
██╗ ██████╗ ██████╗ ███████╗██╗ ██╗
██║ ██╔══██╗██╔════╝ ██╔════╝╚██╗██╔╝
██║ ██████╔╝██║ ███╗█████╗ ╚███╔╝
██║ ██╔══██╗██║ ██║██╔══╝ ██╔██╗
███████╗██║ ██║╚██████╔╝███████╗██╔╝ ██╗
╚══════╝╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝
2023-11-15 15:25:33 +03:00
╦╔═┬ ┬┌─┐┌─┐┌─┐┬─┐ ╔╦╗┌─┐┌─┐┬┌─┌─┐┬─┐
╠╩╗│ │├─┘├─┘├┤ ├┬┘───║║│ ││ ├┴┐├┤ ├┬┘
╩ ╩┴─┘┴┴ ┴ └─┘┴└─ ═╩╝└─┘└─┘┴ ┴└─┘┴└─ v2.5
2023-11-13 14:28:28 +03:00
EOF
2023-11-13 21:31:30 +03:00
##################### Starting code #####################
2023-11-13 17:53:58 +03:00
# This script will run on every container start
if ! systemctl is-enabled nginx > /dev/null 2>&1; then
echo "Enabling NGINX..."
systemctl enable nginx
fi
if ! systemctl is-active nginx > /dev/null 2>&1; then
echo "Starting NGINX..."
systemctl start nginx
else
echo "NGINX is already running."
2023-11-13 14:28:28 +03:00
fi
2023-11-14 13:19:18 +03:00
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
2023-11-14 14:55:58 +03:00
if [ "${package}" = "fluidd" ] && [ ! -d "/home/lrgex/fluidd" ] && [ ! -d "/home/lrgex/mainsail" ]; then
2023-11-14 13:19:18 +03:00
echo "Installing Fluidd with Kiauh..."
su lrgex -c 'expect ./fluidd.exp'
2023-11-15 14:35:10 +03:00
elif [ -d "/home/lrgex/mainsail" ] && [ "${package}" = "fluidd" ]; then
2023-11-14 15:14:20 +03:00
echo -e "\e[31mMainsail detected, skipping Fluidd installation.\e[0m"
2023-11-14 15:21:09 +03:00
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"
2023-11-14 14:55:58 +03:00
sleep 5
2023-11-14 15:14:20 +03:00
break
2023-11-14 14:55:58 +03:00
fi
if [ "${package}" = "mainsail" ] && [ ! -d "/home/lrgex/mainsail" ] && [ ! -d "/home/lrgex/fluidd" ]; then
echo "Installing Mainsail with Kiauh..."
su lrgex -c 'expect ./mainsail.exp'
2023-11-15 14:35:10 +03:00
elif [ -d "/home/lrgex/fluidd" ] && [ "${package}" = "mainsail" ]; then
2023-11-14 15:14:20 +03:00
echo -e "\e[31mFluidd detected, skipping Mainsail installation.\e[0m"
2023-11-14 15:21:09 +03:00
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"
2023-11-14 14:55:58 +03:00
sleep 5
2023-11-14 15:14:20 +03:00
break
2023-11-14 13:19:18 +03:00
fi
done
2023-11-13 21:31:30 +03:00
##################### End code #####################
##################### Only for systemd #####################
# Start systemd /lib/systemd/systemd this for systemd to initialize, "log-level=info" is for debugging , "unit=sysinit.target" is for systemd to initialize AS IS for running the container with systemd
2023-11-13 17:53:58 +03:00
exec /lib/systemd/systemd log-level=info unit=sysinit.target
2023-11-13 14:28:28 +03:00
2023-11-13 21:31:30 +03:00
##################### End Only for systemd #####################
2023-11-14 13:19:18 +03:00
#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
2023-11-13 14:28:28 +03:00
#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 -