mirror of
https://github.com/Websoft9/websoft9.git
synced 2025-01-23 09:20:20 +08:00
apphub 0.0.5
This commit is contained in:
parent
d13d58f297
commit
0b891bede6
@ -1,6 +1,6 @@
|
|||||||
FROM python:3.10-bullseye AS buildstage
|
FROM python:3.10-bullseye AS buildstage
|
||||||
LABEL maintainer="Websoft9<help@websoft9.com>"
|
LABEL maintainer="Websoft9<help@websoft9.com>"
|
||||||
LABEL version="0.0.4"
|
LABEL version="0.0.5"
|
||||||
|
|
||||||
ENV LIBRARY_VERSION=v0.5.8
|
ENV LIBRARY_VERSION=v0.5.8
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ WORKDIR /websoft9
|
|||||||
|
|
||||||
COPY --from=buildstage /media/data ./media
|
COPY --from=buildstage /media/data ./media
|
||||||
COPY --from=buildstage /library ./library
|
COPY --from=buildstage /library ./library
|
||||||
COPY --from=buildstage /websoft9/appmanage_new ./apphub
|
COPY --from=buildstage /websoft9/apphub ./apphub
|
||||||
COPY --from=buildstage /swagger-ui/dist ./apphub/swagger-ui
|
COPY --from=buildstage /swagger-ui/dist ./apphub/swagger-ui
|
||||||
|
|
||||||
RUN apt update && apt install git jq iproute2 supervisor -y && \
|
RUN apt update && apt install git jq iproute2 supervisor -y && \
|
||||||
|
@ -1,9 +1,34 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
|
|
||||||
# monitor /lib/systemd/system/cockpit.socket and config.ini, make sure config.ini port is the same with cockpit.socket
|
# 监控的文件
|
||||||
while true; do
|
FILES="/lib/systemd/system/cockpit.socket /var/lib/docker"
|
||||||
inotifywait -e modify /lib/systemd/system/cockpit.socket
|
cockpit_port="9000"
|
||||||
# 当文件修改时,执行你需要的操作
|
|
||||||
done
|
|
||||||
|
|
||||||
|
# 监控文件发生变动时需要做的事情
|
||||||
|
on_change() {
|
||||||
|
set +e
|
||||||
|
# TODO 从配置文件中获取端口号 apphub need add getconfig cli
|
||||||
|
cockpit_port =$(docker exec -it websoft9-apphub apphub getconfig cockpit port)
|
||||||
|
sudo sed -i "s/ListenStream=[0-9]*/ListenStream=${cockpit_port}/" /lib/systemd/system/cockpit.socket
|
||||||
|
sudo systemctl daemon-reload
|
||||||
|
sudo systemctl restart cockpit
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
# 循环,持续监控
|
||||||
|
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..."
|
||||||
|
on_change
|
||||||
|
done
|
||||||
|
done
|
||||||
|
@ -3,15 +3,33 @@
|
|||||||
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
set -e
|
set -e
|
||||||
trap "sleep 1; continue" ERR
|
trap "sleep 1; continue" ERR
|
||||||
try_times=100
|
try_times=20
|
||||||
counter=1
|
counter=1
|
||||||
|
|
||||||
|
deployment_username="admin"
|
||||||
portainer_username="admin"
|
|
||||||
credential_path="/var/websoft9/credential"
|
credential_path="/var/websoft9/credential"
|
||||||
apphub_container_name="websoft9-apphub"
|
containers=("websoft9-git" "websoft9-deployment" "websoft9-proxy")
|
||||||
|
|
||||||
copy_credential() {
|
for container in ${containers[@]}; do
|
||||||
|
temp_file=$(mktemp)
|
||||||
|
echo "Copying /var/websoft9/credential from $container to $temp_file"
|
||||||
|
docker cp $container:$credential_path $temp_file
|
||||||
|
# Check if temp_file is JSON format
|
||||||
|
if jq -e . >/dev/null 2>&1 <<< "$(cat "$temp_file")"; then
|
||||||
|
# If it is JSON format, use it directly
|
||||||
|
username=$(jq -r '.username' $temp_file)
|
||||||
|
password=$(jq -r '.password' $temp_file)
|
||||||
|
else
|
||||||
|
# If it is not JSON format, get the content and convert it to JSON
|
||||||
|
content=$(cat "$temp_file")
|
||||||
|
username="$deployment_username"
|
||||||
|
password="$content"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$temp_file"
|
||||||
|
done
|
||||||
|
|
||||||
|
get_credential() {
|
||||||
|
|
||||||
# 设置参数的默认值
|
# 设置参数的默认值
|
||||||
source_container=
|
source_container=
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
|
|
||||||
/bin/bash send_credentials.sh
|
/bin/bash send_credentials.sh
|
||||||
/bin/bash set_hosts.sh
|
/bin/bash set_hosts.sh
|
||||||
/bin/bash crontab.sh
|
/bin/bash crontab.sh &
|
Loading…
Reference in New Issue
Block a user