LoMeS/assets/shell/create_certificate.sh

44 lines
1.2 KiB
Bash
Raw Normal View History

2025-10-08 08:39:41 +02:00
#!/bin/bash
2025-10-07 18:54:38 +02:00
2025-10-08 08:39:41 +02:00
### DEPENDENCY CHECK
2025-10-07 18:54:38 +02:00
2025-10-08 09:16:54 +02:00
bin="openssl"
2025-10-07 18:54:38 +02:00
2025-10-08 08:39:41 +02:00
echo -e "\nDependency and Privilege Check running...\n"
if (( $(id -u) == 0 )); then
echo -e "Privilege check passed...\n"
else
echo -e "Privilege check failed... Please run script with sudo or as root!\n"
exit 1
2025-10-07 18:54:38 +02:00
fi
2025-10-08 08:39:41 +02:00
if command -v "$bin" >/dev/null 2>&1; then
echo -e "Dependency check passed...\n"
else
echo -e "$bin is not installed.\n"
2025-10-08 09:02:41 +02:00
while true; do
2025-10-08 10:35:10 +02:00
read -p "Do you wish to install $bin via APT? (Y/n) : " install
2025-10-08 10:21:50 +02:00
if [[ "$install" = "" || "$install" = "y" || "$install" = "Y" ]]; then
2025-10-08 10:20:00 +02:00
sudo apt update && sudo apt install --install-suggests -y $bin
2025-10-08 09:02:41 +02:00
echo -e "\n$bin installed. Proceeding...\n"
2025-10-08 09:22:00 +02:00
break
2025-10-08 09:02:41 +02:00
2025-10-08 09:15:20 +02:00
elif [[ "$install" == "n" || "$install" = "N" ]]; then
2025-10-08 09:02:41 +02:00
echo -e "Dependencies not installed... Exiting"
2025-10-08 09:15:20 +02:00
exit 1
2025-10-08 09:02:41 +02:00
else
2025-10-08 10:35:10 +02:00
echo -e "Invalid response... Try again...\n\nY = (Yes install $bin)\nN = (No, don't install dependencies and exit)\n "
2025-10-08 09:02:41 +02:00
fi
done
2025-10-08 08:39:41 +02:00
fi
#sudo mkdir -p /etc/nginx/ssl ;
#sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/meshpi.key -out /etc/nginx/ssl/meshpi.crt ;