This commit is contained in:
qiaofeng1227 2023-10-13 18:08:18 +08:00
parent 3bf1b05422
commit f55ad1cb7d
2 changed files with 7 additions and 5 deletions

View file

@ -12,16 +12,17 @@ on_change() {
cockpit_port=$(sudo docker exec -i websoft9-apphub apphub getconfig --section cockpit --key port)
sudo sed -i "s/ListenStream=[0-9]*/ListenStream=${cockpit_port}/" /lib/systemd/system/cockpit.socket
sudo systemctl daemon-reload
sudo systemctl restart cockpit
sudo systemctl restart cockpit.socket 2> /dev/null
sudo systemctl restart cockpit || exit 1
set_Firewalld
set -e
}
set_Firewalld(){
echo "Set cockpit service to Firewalld..."
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 --reload
sudo sed -i "s/port=\"[0-9]*\"/port=\"$cockpit_port\"/g" /etc/firewalld/services/cockpit.xml 2>/dev/nul
sudo sed -i "s/port=\"[0-9]*\"/port=\"$cockpit_port\"/g" /usr/lib/firewalld/services/cockpit.xml 2>/dev/nul
sudo firewall-cmd --reload 2>/dev/nul
}
# 循环,持续监控
@ -29,6 +30,7 @@ while true; do
# monitor /lib/systemd/system/cockpit.socket and config.ini, make sure config.ini port is the same with cockpit.socket
inotifywait -e modify -m $FILES | while read PATH EVENT FILE; do
echo "Set cockpit port by config.ini..."
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH
on_change
done
done

View file

@ -1,5 +1,5 @@
{
"version": "0.8.26-rc35",
"version": "0.8.26-rc36",
"plugins": {
"portainer": "0.0.6",
"nginx": "0.0.5",