Script & Deps updated
This commit is contained in:
parent
d3df81c908
commit
cc9c738de2
8 changed files with 33 additions and 66 deletions
|
|
@ -9,7 +9,7 @@ echo -e "\n ${LCY}Dependency and Privilege Check running...${CRS}\n"
|
|||
|
||||
### PRIVILEGES
|
||||
|
||||
if (( $(id -u) == 0 )); then
|
||||
if (( $(id -u) == 0 )); then ### AM I ROOT?
|
||||
echo -e " ${GRN}Privilege check passed...${CRS}\n"
|
||||
|
||||
else
|
||||
|
|
@ -30,7 +30,7 @@ else
|
|||
read -p " (Y/n) --> " install
|
||||
echo ""
|
||||
if [[ "$install" = "" || "$install" = "y" || "$install" = "Y" ]]; then
|
||||
sudo apt update && sudo apt install --install-suggests -y $pkgs --simulate ## DEV
|
||||
sudo apt update && sudo apt install --install-suggests -y $pkgs
|
||||
echo -e "\n ${GRN}Dependencies installed. Proceeding...${CRS}\n"
|
||||
break
|
||||
|
||||
|
|
@ -48,7 +48,7 @@ fi
|
|||
|
||||
###### HOST
|
||||
|
||||
onif=$(/sbin/ip route get 162.249.72.1 | awk '{print $5}' | cut -d/ -f1) ### GET ACTIVE NETWORK INTERFACE
|
||||
onif=$(/sbin/ip route get 162.249.72.1 | awk '{print $5}' | cut -d/ -f1) ### GET ACTIVE NETWORK INTERFACE
|
||||
|
||||
while true; do
|
||||
echo -e " ${YEL}What network interface will nginx be using?${CRS}"
|
||||
|
|
@ -63,7 +63,7 @@ while true; do
|
|||
fi
|
||||
done
|
||||
|
||||
ip4=$(/sbin/ip -o -4 addr list "$nif" | awk '{print $4}' | cut -d/ -f1) ### GET IP FOR CHOSEN INTERFACE
|
||||
ip4=$(/sbin/ip -o -4 addr list "$nif" | awk '{print $4}' | cut -d/ -f1) ### GET IP FOR CHOSEN INTERFACE
|
||||
echo -e "\n ${YEL}Current hostname : ${LCY}$HOSTNAME${CRS}"
|
||||
echo -e " ${YEL}Current ip address : ${LCY}$ip4 ${YEL}@ ${LCY}$nif${CRS}"
|
||||
echo -e "\n ${YEL}This information will be used to configure ${LCY}nginx.conf ${YEL}during the next steps.${CRS}"
|
||||
|
|
@ -75,8 +75,8 @@ while true; do
|
|||
break
|
||||
elif [[ "$conf_hostname" = "y" || "$conf_hostname" = "Y" ]]; then
|
||||
read -p " Enter new hostname --> " new_hostname
|
||||
sudo sed -i.backup "s/$HOSTNAME/$new_hostname/g" assets/test/hosts #/etc/hosts
|
||||
sudo sed -i.backup "s/$HOSTNAME/$new_hostname/g" assets/test/hostname #/etc/hostname
|
||||
sudo sed -i.backup "s/$HOSTNAME/$new_hostname/g" /etc/hosts
|
||||
sudo sed -i.backup "s/$HOSTNAME/$new_hostname/g" /etc/hostname
|
||||
echo -e "\n ${GRN}Host name changed to ${LCY}$new_hostname${CRS}"
|
||||
break
|
||||
else
|
||||
|
|
@ -84,7 +84,7 @@ while true; do
|
|||
fi
|
||||
done
|
||||
|
||||
###### CERTIFICATION
|
||||
###### CERTIFICATION & CONFIGURATION
|
||||
|
||||
while true; do
|
||||
echo -e "\n ${YEL}Configure SSL and create a self signed cetrificate?${CRS}"
|
||||
|
|
@ -108,9 +108,16 @@ while true; do
|
|||
:
|
||||
fi
|
||||
echo ""
|
||||
#sudo mkdir -p "$cert_path"
|
||||
#sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout "$cert_path"/"$cert_name".key -out "$cert_path"/"$cert_name".crt
|
||||
sudo mkdir -p "$cert_path"
|
||||
sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout "$cert_path"/"$cert_name".key -out "$cert_path"/"$cert_name".crt
|
||||
echo -e "\n ${GRN}SSL certificate files ${LCY}$cert_name.crt ${GRN}and ${LCY}$cert_name.key ${GRN}created and stored in ${LCY}$cert_path${CRS}\n"
|
||||
sudo chmod 644 "$cert_path"/"$cert_name".crt
|
||||
sudo chmod 600 "$cert_path"/"$cert_name".key
|
||||
sudo cp assets/config/nginx/nginx_SSL.conf /etc/nginx/sites-enabled/$HOSTNAME.conf
|
||||
sudo sed -i.backup "s/DOMAIN/$HOSTNAME.local/g" /etc/nginx/sites-enabled/$HOSTNAME.conf
|
||||
sudo sed -i "s/IPADDR/$ip4/g" /etc/nginx/sites-enabled/$HOSTNAME.conf
|
||||
sudo sed -i "s|CERTPATH|$cert_path/$cert_name|" /etc/nginx/sites-enabled/$HOSTNAME.conf
|
||||
sudo sed -i "s|KEYPATH|$cert_path/$cert_name|" /etc/nginx/sites-enabled/$HOSTNAME.conf
|
||||
break
|
||||
elif [[ "$installSSL" == "n" || "$installSSL" = "N" ]]; then
|
||||
echo -e "\n ${RED}Encryption disabled${CRS}\n"
|
||||
|
|
@ -121,16 +128,25 @@ while true; do
|
|||
|
||||
done
|
||||
|
||||
###### NGINX CONFIG
|
||||
###### MAINTENANCE
|
||||
|
||||
sudo nginx -t
|
||||
sudo systemctl restart NetworkManager
|
||||
sudo nginx -s reload
|
||||
|
||||
###### STATUS
|
||||
|
||||
|
||||
|
||||
|
||||
### DEV STATUS
|
||||
|
||||
#sudo cp -R assets/config/nginx/nginx.conf /etc/nginx/sites-enabled/
|
||||
## JEFF
|
||||
# utilise sed to edit config
|
||||
###### JEFF ######
|
||||
#
|
||||
# test nginx config
|
||||
# restart nginx
|
||||
## JEFF END
|
||||
#
|
||||
###### JEFF END ######
|
||||
|
||||
|
||||
echo -e "\n ${LGN}Script ran through...${CRS}"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue