forked from RubinLab/epad-dist
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddToFirewall.sh
executable file
·27 lines (23 loc) · 1.11 KB
/
addToFirewall.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/bin/bash
echo "This script support only CentOs for now. If your os is different please add docker interface manually to your firewall trusted zone and restart docker."
echo "You can collect ePad docker network interface via docker inspect epad_lite --format='{{range .NetworkSettings.Networks}}{{.NetworkID}}{{end}}' command"
read -p "The script will add docker ePad network to your server trusted zone. Do you want to continue? (y/n) : " response
check_operating_system(){
local localvar_osname=""
echo "Checking your operating system..."
localvar_osname=$(cat /etc/os-release | grep "^NAME=" | cut -d"=" -f2)
if [[ -n $(echo $localvar_osname | grep "CentOs") ]]; then
echo "your os : $localvar_osname
updating firewall settings.
else
echo "your operating system \" $localvar_osname \" is not supported yet. Exiting. "
exit 1
fi
}
if [[ $response = "y" ]]; then
check_operating_system
networkID=$(docker inspect epad_lite --format='{{range .NetworkSettings.Networks}}{{.NetworkID}}{{end}}')
firewall-cmd --permanent --zone=trusted --add-interface="$networkID"
firewall-cmd --reload
systemctl restart docker
fi