From b4d849f1352e930b7bdbda37765c3f272496d0b8 Mon Sep 17 00:00:00 2001 From: Darren <27513732@qq.com> Date: Tue, 19 Sep 2023 18:12:37 +0800 Subject: [PATCH] install_new.sh --- install/install_docker.sh | 5 +++++ install/install_new.sh | 27 ++++++++++++++++++--------- install/install_plugins.sh | 14 +++++++------- install/install_tools.sh | 8 ++++++++ systemd/README.md | 5 +++++ systemd/websoft9.service | 4 ++-- 6 files changed, 45 insertions(+), 18 deletions(-) create mode 100644 systemd/README.md diff --git a/install/install_docker.sh b/install/install_docker.sh index 8e34e684..ff797676 100644 --- a/install/install_docker.sh +++ b/install/install_docker.sh @@ -1,3 +1,8 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +InstallDocker InstallDocker(){ diff --git a/install/install_new.sh b/install/install_new.sh index 87714acf..29057d1e 100644 --- a/install/install_new.sh +++ b/install/install_new.sh @@ -1,35 +1,44 @@ #!/bin/bash +# Define PATH PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +# Export PATH export PATH -function error_exit { +# Define error_exit function +function error_exit { echo "$1" 1>&2 exit 1 } + +# Trap ERR signal and call error_exit function trap 'error_exit "Please push issue to: https://github.com/Websoft9/stackhub/issues"' ERR -# Define environments -install_path="/data" +# Define vars +install_path="/data/websoft9" urls="https://w9artifact.blob.core.windows.net/release/websoft9" if [[ "$1" == "dev" ]]; then - echo "update by dev artifacts" + echo "update by dev artifact" urls="https://w9artifact.blob.core.windows.net/dev/websoft9" fi +# Download and extract source code +wget $urls/websoft9.latest && unzip websoft9.latest $install_path + # Install runtime curl https://websoft9.github.io/websoft9/install/install_tools.sh | bash curl https://websoft9.github.io/websoft9/install/install_docker.sh | bash - # Install Cockpit and plugins curl https://websoft9.github.io/websoft9/install/install_cockpit.sh | bash curl https://websoft9.github.io/websoft9/install/install_plugins.sh | bash - # Install backend service -wget $urls/websoft9.latest && unzip websoft9.latest $install_path -cd websoft9/docker +cd $install_path/docker sudo docker network create websoft9 -sudo docker compose -p websoft9 up -d +sudo docker-compose -p websoft9 up -d # Install Systemd service +cd $install_path/websoft9/systemd +sudo systemctl daemon-reload +sudo systemctl enable websoft9.service +sudo systemctl start websoft9 \ No newline at end of file diff --git a/install/install_plugins.sh b/install/install_plugins.sh index 7a5af292..34de920e 100644 --- a/install/install_plugins.sh +++ b/install/install_plugins.sh @@ -1,12 +1,12 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +InstallPlugins + -urls="https://w9artifact.blob.core.windows.net/release/websoft9" -if [[ "$1" == "dev" ]]; then - echo "update by dev artifacts" - urls="https://w9artifact.blob.core.windows.net/dev/websoft9" -fi - - +### -----------------------------------------------------### InstallPlugins(){ diff --git a/install/install_tools.sh b/install/install_tools.sh index 8a682bb5..9f7d82a9 100644 --- a/install/install_tools.sh +++ b/install/install_tools.sh @@ -1,3 +1,11 @@ +#!/bin/bash +PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin +export PATH + +InstallTools + +### -----------------------------------------------------### + InstallTools(){ echo "Prepare to install Tools ..." diff --git a/systemd/README.md b/systemd/README.md new file mode 100644 index 00000000..efcc8c0d --- /dev/null +++ b/systemd/README.md @@ -0,0 +1,5 @@ +# Systemd + +This is the Websoft9 system service that run some proxy services on the host machine for Websoft9 to solve the problem that the API cannot handle. + +- Copy credentials from one other containers to apphub container \ No newline at end of file diff --git a/systemd/websoft9.service b/systemd/websoft9.service index 171e80c5..a96b6f67 100644 --- a/systemd/websoft9.service +++ b/systemd/websoft9.service @@ -5,8 +5,8 @@ After=network.target docker [Service] KillSignal=SIGQUIT -WorkingDirectory=/data/develop/stackhub/api -ExecStart=python3 uvicorn main:app --reload +WorkingDirectory=/data/websoft9 +ExecStart=bash send_credentials.sh Restart=always Type=notify NotifyAccess=all