Script changed
This commit is contained in:
parent
c9223ecffc
commit
eee7ee410c
7 changed files with 101 additions and 19 deletions
1
assets/test/hostname
Normal file
1
assets/test/hostname
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
bla
|
||||||
1
assets/test/hostname.backup
Normal file
1
assets/test/hostname.backup
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
cor3unit
|
||||||
7
assets/test/hosts
Normal file
7
assets/test/hosts
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
127.0.0.1 localhost
|
||||||
|
127.0.1.1 bla.lan bla
|
||||||
|
|
||||||
|
# The following lines are desirable for IPv6 capable hosts
|
||||||
|
::1 localhost ip6-localhost ip6-loopback
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
||||||
7
assets/test/hosts.backup
Normal file
7
assets/test/hosts.backup
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
127.0.0.1 localhost
|
||||||
|
127.0.1.1 cor3unit.lan cor3unit
|
||||||
|
|
||||||
|
# The following lines are desirable for IPv6 capable hosts
|
||||||
|
::1 localhost ip6-localhost ip6-loopback
|
||||||
|
ff02::1 ip6-allnodes
|
||||||
|
ff02::2 ip6-allrouters
|
||||||
33
assets/test/nginx.conf
Normal file
33
assets/test/nginx.conf
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
###########################################################
|
||||||
|
### ###
|
||||||
|
### MESHPI NGINX CONFIG ###
|
||||||
|
### ###
|
||||||
|
###########################################################
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name DOMAIN IPADDR;
|
||||||
|
return 301 https://$host$request_uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 443 ssl;
|
||||||
|
server_name DOMAIN IPADDR;
|
||||||
|
|
||||||
|
ssl_certificate CERTPATH;
|
||||||
|
ssl_certificate_key CERTPATH;
|
||||||
|
|
||||||
|
ssl_protocols TLSv1.2 TLSv1.3;
|
||||||
|
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||||
|
|
||||||
|
ssl_session_cache shared:SSL:10m;
|
||||||
|
ssl_session_timeout 10m;
|
||||||
|
|
||||||
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ =404;
|
||||||
|
root /var/www/html;
|
||||||
|
index index.html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,2 +1,3 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
sed -i.bak "s/DOMAIN/$HOSTNAME.local/g" nginx.conf
|
||||||
|
|
@ -48,20 +48,50 @@ fi
|
||||||
|
|
||||||
###### HOST
|
###### HOST
|
||||||
|
|
||||||
ip4=$(/sbin/ip -o -4 addr list eth0 | awk '{print $4}' | cut -d/ -f1)
|
onif=$(/sbin/ip route get 162.249.72.1 | awk '{print $5}' | cut -d/ -f1)
|
||||||
echo -e " ${YEL}Current hostname : ${LCY}$HOSTNAME${CRS}"
|
ip4=$(/sbin/ip -o -4 addr list "$onif" | awk '{print $4}' | cut -d/ -f1)
|
||||||
|
############################# add interface fail safe
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
echo -e " ${YEL}What network interface will nginx be using?${CRS}"
|
||||||
|
read -p " current = "$onif" --> " nif
|
||||||
|
if ! [ "$nif" ]; then
|
||||||
|
nif="$onif"
|
||||||
|
break
|
||||||
|
elif [ $? -eq 0 ]; then ############################### JEFF
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo -e "\n ${LRD}Interface not found... Try again!${CRS}\n"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo -e "\n ${YEL}Current hostname : ${LCY}$HOSTNAME${CRS}"
|
||||||
echo -e " ${YEL}Current ip address : ${LCY}$ip4${CRS}"
|
echo -e " ${YEL}Current ip address : ${LCY}$ip4${CRS}"
|
||||||
echo -e "\n ${YEL}This information will be used to configure ${LCY}nginx.conf ${YEL}during the next steps.${CRS}"
|
echo -e "\n ${YEL}This information will be used to configure ${LCY}nginx.conf ${YEL}during the next steps.${CRS}"
|
||||||
read -p " Would you like to change the hostname? (y/N) --> " conf_host_ip
|
|
||||||
|
|
||||||
# ask for network interface
|
while true; do
|
||||||
# ask to change hostname in /etc/hosts & /etc/hostname
|
|
||||||
|
read -p " Would you like to change the hostname? (y/N) --> " conf_hostname
|
||||||
|
if [[ "$conf_hostname" = "" || "$conf_hostname" = "n" || "$conf_hostname" = "N" ]]; then
|
||||||
|
new_hostname=$HOSTNAME
|
||||||
|
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
|
||||||
|
echo -e "\n ${GRN}Host name changed to ${LCY}$new_hostname${CRS}"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo -e "\n ${YEL}Invalid response... Try again...\n\n Y = (Yes, set new hostname)\n N = (No, leave as is)${CRS}\n "
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
###### CERTIFICATION
|
###### CERTIFICATION
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
echo -e "\n ${YEL}Configure SSL and create a self signed cetrificate?${CRS}"
|
echo -e "\n ${YEL}Configure SSL and create a self signed cetrificate?${CRS}"
|
||||||
read -p " (Y/n) --> " installSSL
|
read -p " (Y/n) --> " installSSL
|
||||||
|
|
||||||
if [[ "$installSSL" = "" || "$installSSL" = "y" || "$installSSL" = "Y" ]]; then
|
if [[ "$installSSL" = "" || "$installSSL" = "y" || "$installSSL" = "Y" ]]; then
|
||||||
echo -e " ${YEL}Enter path to certificates folder${CRS}"
|
echo -e " ${YEL}Enter path to certificates folder${CRS}"
|
||||||
read -p " default = /etc/nginx/ssl --> " cert_path
|
read -p " default = /etc/nginx/ssl --> " cert_path
|
||||||
|
|
@ -72,7 +102,6 @@ while true; do
|
||||||
else
|
else
|
||||||
:
|
:
|
||||||
fi
|
fi
|
||||||
echo ""
|
|
||||||
echo -e " ${YEL}Enter file name for certificate and key${CRS}"
|
echo -e " ${YEL}Enter file name for certificate and key${CRS}"
|
||||||
read -p " default = $HOSTNAME --> " cert_name
|
read -p " default = $HOSTNAME --> " cert_name
|
||||||
if ! [ "$cert_name" ]; then
|
if ! [ "$cert_name" ]; then
|
||||||
|
|
@ -86,13 +115,16 @@ while true; do
|
||||||
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"
|
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"
|
||||||
break
|
break
|
||||||
elif [[ "$installSSL" == "n" || "$installSSL" = "N" ]]; then
|
elif [[ "$installSSL" == "n" || "$installSSL" = "N" ]]; then
|
||||||
echo -e "\n${RED} No encryption established${CRS}\n"
|
echo -e "\n ${RED}Encryption disabled${CRS}\n"
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
echo -e "\n ${YEL}Invalid response... Try again...\n\n Y = (Yes, configure SSL certificate and continue)\n N = (No, leave unencrypted and continue)${CRS}\n "
|
echo -e "\n ${YEL}Invalid response... Try again...\n\n Y = (Yes, configure SSL certificate and continue)\n N = (No, leave unencrypted and continue)${CRS}\n "
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
|
###### NGINX CONFIG
|
||||||
|
|
||||||
|
|
||||||
### DEV STATUS
|
### DEV STATUS
|
||||||
|
|
||||||
|
|
@ -103,4 +135,4 @@ while true; do
|
||||||
# restart nginx
|
# restart nginx
|
||||||
## JEFF END
|
## JEFF END
|
||||||
|
|
||||||
echo -e "${GRN}\nScript ran through...${CRS}"
|
echo -e "\n ${LGN}Script ran through...${CRS}"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue