This commit is contained in:
Darren 2023-10-10 11:34:04 +08:00 committed by GitHub
parent cd4aab48eb
commit eb52a69e5e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 13 deletions

View file

@ -1,8 +1,7 @@
[![](https://lab.frogg.it/lydra/yunohost/ansible-yunohost/badges/main/pipeline.svg)](https://lab.frogg.it/lydra/yunohost/ansible-yunohost/-/pipelines)
[![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0) [![License: GPL v3](https://img.shields.io/badge/License-GPL%20v3-blue.svg)](http://www.gnu.org/licenses/gpl-3.0)
[![GitHub last commit](https://img.shields.io/github/last-commit/LydraFr/ansible-yunohost)](https://github.com/LydraFr/ansible-yunohost) [![GitHub last commit](https://img.shields.io/github/last-commit/websoft9/websoft9)](https://github.com/websoft9/websoft9)
[![GitHub Release Date](https://img.shields.io/github/release-date/LydraFr/ansible-yunohost)](https://github.com/LydraFr/ansible-yunohost) [![GitHub Release Date](https://img.shields.io/github/release-date/websoft9/websoft9)](https://github.com/websoft9/websoft9)
[![GitHub Repo stars](https://img.shields.io/github/stars/LydraFr/ansible-yunohost?style=social)](https://github.com/LydraFr/ansible-yunohost) [![GitHub Repo stars](https://img.shields.io/github/stars/websoft9/websoft9?style=social)](https://github.com/websoft9/websoft9)
# What is Websoft9? # What is Websoft9?

View file

@ -165,20 +165,27 @@ Restart_Cockpit(){
sudo systemctl restart cockpit sudo systemctl restart cockpit
} }
Set_Firewall(){ Add_Firewalld(){
echo "$echo_prefix_cockpit Set firewall for cockpit access" echo "Add cockpit service to Firewalld..."
# cockpit.xml is not always the same path at Linux distributions
sudo sed -i "s/port=\"[0-9]*\"/port=\"$cockpit_port\"/g" /etc/firewalld/services/cockpit.xml
sudo sed -i "s/port=\"[0-9]*\"/port=\"$cockpit_port\"/g" /usr/lib/firewalld/services/cockpit.xml
sudo firewall-cmd --zone=public --add-service=cockpit --permanent
sudo firewall-cmd --zone=public --add-port=443/tcp --permanent
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload
}
Set_Firewalld(){
echo "$echo_prefix_cockpit Set firewalld for cockpit access"
if command -v firewall-cmd &> /dev/null; then if command -v firewall-cmd &> /dev/null; then
echo "Set firewall for Cockpit..." echo "Set firewall for Cockpit..."
if ! systemctl is-active --quiet firewalld; then if ! systemctl is-active --quiet firewalld; then
sudo systemctl start firewalld sudo systemctl start firewalld
sudo sed -i "s/port=\"[0-9]*\"/port=\"$cockpit_port\"/g" /etc/firewalld/services/cockpit.xml Add_Firewalld
sudo firewall-cmd --permanent --zone=public --add-service=cockpit
sudo firewall-cmd --reload
sudo systemctl stop firewalld sudo systemctl stop firewalld
else else
sudo sed -i "s/port=\"[0-9]*\"/port=\"$cockpit_port\"/g" /etc/firewalld/services/cockpit.xml Add_Firewalld
sudo firewall-cmd --permanent --zone=public --add-service=cockpit
sudo firewall-cmd --reload
fi fi
fi fi
} }
@ -318,7 +325,7 @@ Install_Cockpit(){
Restart_Cockpit Restart_Cockpit
fi fi
Set_Firewall Set_Firewalld
Set_Selinux Set_Selinux
Set_Cockpit Set_Cockpit
Edit_Menu Edit_Menu