script edited
This commit is contained in:
parent
a5815381e6
commit
0d61d3ea32
2 changed files with 67 additions and 51 deletions
|
|
@ -1,51 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
## SOME COLOR
|
|
||||||
CYN="\e[0;36m"
|
|
||||||
YEL="\e[0;33m"
|
|
||||||
RED="\e[0;31m"
|
|
||||||
GRN="\e[0;32m"
|
|
||||||
CRS="\e[0m"
|
|
||||||
|
|
||||||
### DEPENDENCY CHECK
|
|
||||||
|
|
||||||
bin="openssl"
|
|
||||||
|
|
||||||
echo -e "\n${CYN}Dependency and Privilege Check running...${CRS}\n"
|
|
||||||
|
|
||||||
if (( $(id -u) == 0 )); then
|
|
||||||
echo -e "${GRN}Privilege check passed...${CRS}\n"
|
|
||||||
|
|
||||||
else
|
|
||||||
echo -e "${RED}Privilege check failed... Please run script with sudo or as root!${CRS}\n"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if command -v "$bin" >/dev/null 2>&1; then
|
|
||||||
echo -e "${GRN}Dependency check passed...${CRS}\n"
|
|
||||||
|
|
||||||
else
|
|
||||||
echo -e "${YEL}$bin is not installed.${CRS}\n"
|
|
||||||
|
|
||||||
while true; do
|
|
||||||
read -p "Do you wish to install $bin via APT? (Y/n) : " install
|
|
||||||
|
|
||||||
if [[ "$install" = "" || "$install" = "y" || "$install" = "Y" ]]; then
|
|
||||||
touch /tmp/lomesInstallLog.txt
|
|
||||||
sudo apt update && sudo apt install --install-suggests -y $bin >/tmp/lomesInstallLog.txt
|
|
||||||
echo -e "\n${GRN}$bin installed. Proceeding...${CRS}\n"
|
|
||||||
break
|
|
||||||
|
|
||||||
elif [[ "$install" == "n" || "$install" = "N" ]]; then
|
|
||||||
echo -e "\n${RED}Dependencies not installed... Exiting!${CRS}\n"
|
|
||||||
exit 1
|
|
||||||
|
|
||||||
else
|
|
||||||
echo -e "\n${YEL}Invalid response... Try again...\n\nY = (Yes, install $bin)\nN = (No, don't install dependencies and exit)${CRS}\n "
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
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 ;
|
|
||||||
67
assets/shell/setup.sh
Executable file
67
assets/shell/setup.sh
Executable file
|
|
@ -0,0 +1,67 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
## SOME COLOR
|
||||||
|
CYN="\e[0;36m"
|
||||||
|
YEL="\e[0;33m"
|
||||||
|
RED="\e[0;31m"
|
||||||
|
GRN="\e[0;32m"
|
||||||
|
CRS="\e[0m"
|
||||||
|
|
||||||
|
### DEPENDENCY CHECK & INSTALLER
|
||||||
|
|
||||||
|
pkgs="openssl nginx"
|
||||||
|
|
||||||
|
echo -e "\n${CYN}Dependency and Privilege Check running...${CRS}\n"
|
||||||
|
|
||||||
|
if (( $(id -u) == 0 )); then
|
||||||
|
echo -e "${GRN}Privilege check passed...${CRS}\n"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "${RED}Privilege check failed... Please run script with sudo or as root!${CRS}\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v "$pkgs" >/dev/null 2>&1; then
|
||||||
|
echo -e "${GRN}Dependency check passed...${CRS}\n"
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "${YEL}Dependencies not met.${CRS}\n"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -p "Do you wish to install via APT? (Y/n) : " install
|
||||||
|
|
||||||
|
if [[ "$install" = "" || "$install" = "y" || "$install" = "Y" ]]; then
|
||||||
|
sudo apt update && sudo apt install --install-suggests -y $pkgs --simulate ## DEV
|
||||||
|
echo -e "\n${GRN}Dependencies installed. Proceeding...${CRS}\n"
|
||||||
|
break
|
||||||
|
|
||||||
|
elif [[ "$install" == "n" || "$install" = "N" ]]; then
|
||||||
|
echo -e "\n${RED}Missing dependencies... Exiting!${CRS}\n"
|
||||||
|
exit 1
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "\n${YEL}Invalid response... Try again...\n\nY = (Yes, install dependencies and continue)\nN = (No, don't install dependencies and exit)${CRS}\n "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
### NGINX SETUP
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
read -p "Enable SSL and create cetrificate? (Y/n) : " installSSL
|
||||||
|
if [[ "$installSSL" = "" || "$installSSL" = "y" || "$installSSL" = "Y" ]]; then
|
||||||
|
read -p "Enter path to certificates (Will be created if not present) : " cert_path
|
||||||
|
sudo mkdir -p "$cert_path"
|
||||||
|
echo "Folder created" ## DEV
|
||||||
|
read -p "Enter file name for certificates () : " cert_name
|
||||||
|
echo -e "\n${GRN}Nginx configured${CRS}\n"
|
||||||
|
break
|
||||||
|
|
||||||
|
else
|
||||||
|
echo -e "\n${YEL}Invalid response... Try again...\n\nY = (Yes, install SSL certificate and continue)\nN = (No, don't install SSL certificate and continue)${CRS}\n "
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
#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 ;
|
||||||
Loading…
Add table
Add a link
Reference in a new issue