This commit is contained in:
Darren 2023-09-27 14:50:42 +08:00 committed by GitHub
parent 35885cc599
commit aa2d985186
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 800 additions and 708 deletions

View file

@ -34,23 +34,15 @@ You can see the sceenshoots below:
- Manage your Linux by GUI: Inspect and change network settings, Configure a firewall, Manage storage, Browse and search system logs, Inspect a systems hardware, Inspect and interact with systemd-based services, - Manage your Linux by GUI: Inspect and change network settings, Configure a firewall, Manage storage, Browse and search system logs, Inspect a systems hardware, Inspect and interact with systemd-based services,
- Supported languages: English, Chinese中文 - Supported languages: English, Chinese中文
# Install # Install & Upgrade
You should have root privileges user to install or upgrade Websoft9, if you use no-root user you can `sudo su` for it You should have root privileges user to install or upgrade Websoft9, if you use no-root user you can `sudo su` for it
## Installation
``` ```
wget https://websoft9.github.io/websoft9/install/install.sh && bash install.sh wget https://websoft9.github.io/websoft9/install/install.sh && bash install.sh
``` ```
After installation, access it by: **http://Internet IP:9000** and using **Linux user** for login After installation, access it by: **http://Internet IP:9000** and using **Linux user** for login
## Upgrade
```
curl https://websoft9.github.io/websoft9/install/update.sh | bash
```
# Contributing # Contributing

View file

@ -24,6 +24,7 @@ services:
- 9001-9999:9000 - 9001-9999:9000
volumes: volumes:
- portainer:/data - portainer:/data
- /data/compose:/data/compose
- /var/run/docker.sock:/var/run/docker.sock - /var/run/docker.sock:/var/run/docker.sock
#- /run/podman/podman.sock:/var/run/docker.sock #- /run/podman/podman.sock:/var/run/docker.sock
labels: labels:

View file

@ -1,472 +1,253 @@
#!/bin/bash #!/bin/bash
# Define PATH
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
# Export PATH
export PATH export PATH
function error_exit {
echo "$1" 1>&2
exit 1
}
trap 'error_exit "Please push issue to: https://github.com/Websoft9/stackhub/issues"' ERR
urls="https://w9artifact.blob.core.windows.net/release/websoft9" # Command-line options
if [[ "$1" == "dev" ]]; then # ==============================================================================
echo "update by dev artifacts" #
urls="https://w9artifact.blob.core.windows.net/dev/websoft9" # --force <y|n>
fi # Use the --force option to ignore all interactive choices. default is n, for example:
#
# $ sudo sh install.sh --force n
#
# --port <9000>
# Use the --port option to set Websoft9 cosole port. default is 9000, for example:
#
# $ sudo sh install.sh --port 9001
#
# --channel <release|dev>
# Use the --channel option to install a release(production) or dev distribution. default is release, for example:
#
# $ sudo sh install.sh --channel release
#
# --path
# Use the --path option to for installation path for example:
#
# $ sudo sh install.sh --path "/data/websoft9/source"
#
# ==============================================================================
function get_os_type() {
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
elif type lsb_release >/dev/null 2>&1; then
OS=$(lsb_release -si)
else
OS=$(uname -s)
fi
if [[ "$OS" == "CentOS Linux" ]]; then # 设置参数的默认值
echo "CentOS" force="n"
elif [[ "$OS" == "CentOS Stream" ]]; then port="9000"
echo "CentOS Stream" channel="release"
elif [[ "$OS" == "Rocky Linux" ]]; then path="/data/websoft9/source"
echo "Rocky Linux"
elif [[ "$OS" == "Oracle Linux Server" ]]; then
echo "OracleLinux"
elif [[ "$OS" == "Debian GNU/Linux" ]]; then
echo "Debian"
elif [[ "$OS" == "Ubuntu" ]]; then
echo "Ubuntu"
elif [[ "$OS" == "Fedora Linux" ]]; then
echo "Fedora"
elif [[ "$OS" =~ "Red Hat Enterprise Linux" ]]; then
echo "Redhat"
else
echo $OS
fi
}
function get_os_version() { # 获取参数值
if [ -f /etc/os-release ]; then while [[ $# -gt 0 ]]; do
. /etc/os-release case $1 in
OS=$NAME --force)
VERSION=$VERSION_ID force="$2"
elif type lsb_release >/dev/null 2>&1; then shift 2
OS=$(lsb_release -si) ;;
VERSION=$(lsb_release -sr) --port)
else port="$2"
OS=$(uname -s) shift 2
VERSION=$(uname -r) ;;
fi --channel)
channel="$2"
shift 2
;;
--path)
path="$2"
shift 2
;;
*)
shift
;;
esac
done
echo $VERSION # 输出参数值
} echo "Your installation parameters are as follows: "
os_type=$(get_os_type) echo "--force: $force"
os_version=$(get_os_version) echo "--port: $port"
echo "--channel: $channel"
echo "--path: $path"
CheckEnvironment(){ # Define global vars
# export var can send it to subprocess
echo "---------------------------------- Welcome to install websoft9's appstore, it will take 3-5 minutes -------------------------------------------------------" export http_port=80
export https_port=443
export cockpit_port=$port
export force_install=$force
export install_path=$path
export systemd_path="/opt/websoft9/systemd"
export source_zip="websoft9-latest.zip"
export source_unzip="websoft9"
export source_github_pages="https://websoft9.github.io/websoft9"
export tools_yum="git curl wget yum-utils jq bc unzip"
export tools_apt="git curl wget jq bc unzip"
export docker_network="websoft9"
export artifact_url="https://w9artifact.blob.core.windows.net/$channel/websoft9"
echo Install from url: $artifact_url
echo "Check environment ..." # Define common functions
echo os_type: $os_type
echo os_version: $os_version
if [ $(id -u) != "0" ]; then
echo "Please change to root or 'sudo su' to up system privileges, and reinstall the script again ."
exit 1
fi
if [ $(getconf WORD_BIT) = '32' ] && [ $(getconf LONG_BIT) = '64' ] ; then install_tools(){
echo "64-bit operating system detected." echo_prefix_tools=$'\n[Tools] - '
else echo "$echo_prefix_tools Starting install necessary tool..."
echo "This script only works on 64-bit operating systems."
exit 1
fi
if [ "$os_type" == 'CentOS' ] ;then dnf --version >/dev/null 2>&1
if [ "$os_version" != "7" ]; then dnf_status=$?
echo "This app only supported on CentOS 7" yum --version >/dev/null 2>&1
exit 1 yum_status=$?
fi apt --version >/dev/null 2>&1
fi apt_status=$?
if [ "$os_type" == 'CentOS Stream' ] ;then if [ $dnf_status -eq 0 ]; then
if [ "$os_version" != "8" ] || [ "$os_version" != "9" ]; then dnf install $tools_yum -y
echo "This app only supported on CentOS Stream 8,9" elif [ $yum_status -eq 0 ]; then
exit 1 yum install $tools_yum -y
fi elif [ $apt_status -eq 0 ]; then
fi
if [ "$os_type" == 'Rocky Linux' ] ;then
if [ "${os_version:0:1}" == "8" ] || [ "${os_version:0:1}" == "9" ]; then
echo ""
else
echo "This app only supported on Rocky Linux 8"
exit 1
fi
fi
if [ "$os_type" == 'Fedora' ];then
if [ "$os_version" != "37" ]; then
echo "This app only supported on Fedora 37"
exit 1
fi
fi
if [ "$os_type" == 'Redhat' ];then
if [ "${os_version:0:1}" != "7" ] && [ "${os_version:0:1}" != "8" ] && [ "${os_version:0:1}" != "9" ]; then
echo "This app only supported on Redhat 7,8"
exit 1
fi
fi
if [ "$os_type" == 'Ubuntu' ];then
if [ "$os_version" != "22.04" ] && [ "$os_version" != "20.04" ] && [ "$os_version" != "18.04" ]; then
echo "This app only supported on Ubuntu 22.04,20.04,18.04"
exit 1
fi
fi
if [ "$os_type" == 'Debian' ];then
if [ "$os_version" != "11" ];then
echo "This app only supported on Debian 11"
exit 1
fi
fi
# Check port used
if netstat -tuln | grep -qE ':(80|443|9000)\s'; then
echo "Port 80,443,9000 is already in use."
exit 1
else
echo "Port 80,443, 9000 are free."
fi
}
InstallTools(){
echo "Prepare to install Tools ..."
if [ "$os_type" == 'CentOS' ] || [ "$os_type" == 'Rocky Linux' ] || [ "$os_type" == 'CentOS Stream' ] || [ "$os_type" == 'Fedora' ] || [ "$os_type" == 'OracleLinux' ] || [ "$os_type" == 'Redhat' ];then
sudo yum update -y
sudo yum install git curl wget yum-utils jq bc unzip -y
fi
if [ "$os_type" == 'Ubuntu' ] || [ "$os_type" == 'Debian' ] ;then
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
echo "Waiting for other software managers to finish..." echo "Waiting for other software managers to finish..."
sleep 5 sleep 5
done done
sudo apt update -y 1>/dev/null 2>&1 sudo apt update -y 1>/dev/null 2>&1
if command -v git > /dev/null;then apt install $tools_apt -y --assume-yes
echo "git installed ..."
else else
sudo apt install git -y echo "None of the required package managers are installed."
fi fi
if command -v curl > /dev/null;then }
echo "jcurlq installed ..."
download_source() {
echo_prefix_source=$'\n[Dowload Source] - '
echo "$echo_prefix_source Download Websoft9 source code from $artifact_url/$source_zip"
rm -rf websoft9-latest.zip*
if [ -d "$install_path" ]; then
echo "Directory $install_path already exists and installation will cover it."
else else
sudo apt install curl -y mkdir -p "$install_path"
fi
if command -v wget > /dev/null;then
echo "wget installed ..."
else
sudo apt install wget -y
fi
if command -v jq > /dev/null;then
echo "jq installed ..."
else
sudo apt install jq -y
fi fi
if command -v bc > /dev/null;then wget "$artifact_url/$source_zip"
echo "bc installed ..." if [ $? -ne 0 ]; then
else echo "Failed to download source package."
sudo apt install bc -y exit 1
fi fi
if command -v unzip > /dev/null;then
echo "unzip installed ..." sudo unzip -o "$source_zip" -d "$install_path" > /dev/null
else if [ $? -ne 0 ]; then
sudo apt install unzip -y echo "Failed to unzip source package."
exit 1
fi fi
cp -r $install_path/$source_unzip/* "$install_path"
if [ $? -ne 0 ]; then
echo "Move directory failed"
exit 1
fi fi
rm -rf "$source_zip" "$install_path/$source_unzip"
} }
InstallDocker(){
if command -v docker &> /dev/null
then
echo "Docker is installed, update..."
if command -v apt > /dev/null;then
sudo apt -y install --only-upgrade docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif command -v dnf > /dev/null;then
sudo dnf update -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif command -v yum > /dev/null;then
sudo yum update -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
fi
sudo systemctl start docker
sudo systemctl enable docker
if ! docker network inspect websoft9 > /dev/null 2>&1; then
sudo docker network create websoft9
fi
return
else
echo "Docker is not installed, start to install..."
fi
if [ "$os_type" == 'CentOS' ];then
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
fi
if [ "$os_type" == 'Ubuntu' ] || [ "$os_type" == 'Debian' ] ;then check_ports() {
apt-get update local ports=("$@")
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
echo "Waiting for other software managers to finish..." echo "Stop Websoft9 Proxy and Cockpit service for reserve ports..."
sleep 5 sudo docker stop websoft9-proxy || echo "docker stop websoft9-proxy failed "
sudo systemctl stop cockpit || echo "systemctl stop cockpit failed"
sudo systemctl stop cockpit.socket || echo "systemctl stop cockpit.socket failed"
for port in "${ports[@]}"; do
if netstat -tuln | grep ":$port " >/dev/null; then
echo "Port $port is in use, install failed"
exit
fi
done done
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
sleep 30
fi
if [ "$os_type" == 'OracleLinux' ] ;then
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
fi
if [ "$os_type" == 'Fedora' ] ;then
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo yum install device-mapper-persistent-data lvm2 docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-scan-plugin docker-ce-rootless-extras -y
fi
if [ "$os_type" == 'Redhat' ] ;then
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc -y 1>/dev/null 2>&1
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
fi
if [ "$os_type" == 'CentOS Stream' ] || [ "$os_type" == 'Rocky Linux' ];then
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc -y 1>/dev/null 2>&1
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
fi
sudo systemctl start docker
sudo systemctl enable docker
if ! docker network inspect websoft9 > /dev/null 2>&1; then
sudo docker network create websoft9
fi
echo "All ports are available"
} }
InstallCockpit(){ install_backends() {
echo "Prepare to install Cockpit ..." echo_prefix_backends=$'\n[Backend] - '
echo "$echo_prefix_backends Install backend docker services"
if [ "${os_type}" == 'Debian' ]; then cd "$install_path/docker"
VERSION_CODENAME=$(cat /etc/os-release |grep VERSION_CODENAME|cut -f2 -d"=") if [ $? -ne 0 ]; then
sudo echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" >/etc/apt/sources.list.d/backports.list echo "Failed to change directory."
sudo apt update exit 1
sudo apt install -t ${VERSION_CODENAME}-backports cockpit -y
sudo apt install cockpit-pcp cockpit-packagekit -y 1>/dev/null 2>&1
fi fi
if [ "${os_type}" == 'Ubuntu' ]; then sudo docker network inspect $docker_network >/dev/null 2>&1
if grep -q "^#.*deb http://mirrors.tencentyun.com/ubuntu.*backports" /etc/apt/sources.list; then if [ $? -eq 0 ]; then
echo "Add backports deb ..." echo "Docker network '$docker_network' already exists."
sudo sed -i 's/^#\(.*deb http:\/\/mirrors.tencentyun.com\/ubuntu.*backports.*\)/\1/' /etc/apt/sources.list
apt update
fi
VERSION_CODENAME=$(cat /etc/os-release |grep VERSION_CODENAME|cut -f2 -d"=")
sudo apt install -t ${VERSION_CODENAME}-backports cockpit -y
sudo apt install cockpit-pcp -y 1>/dev/null 2>&1
echo "Cockpit allow root user"
echo "" >/etc/cockpit/disallowed-users 1>/dev/null 2>&1
fi
if [ "${os_type}" == 'CentOS' ] || [ "$os_type" == 'OracleLinux' ]; then
sudo yum install cockpit -y
sudo yum install cockpit-pcp cockpit-packagekit -y 1>/dev/null 2>&1
sudo systemctl enable --now cockpit.socket
sudo firewall-cmd --permanent --zone=public --add-service=cockpit
sudo firewall-cmd --reload
fi
if [ "$os_type" == 'Fedora' ]; then
sudo dnf install cockpit -y
sudo dnf install cockpit-pcp cockpit-packagekit -y 1>/dev/null 2>&1
sudo systemctl enable --now cockpit.socket
sudo firewall-cmd --add-service=cockpit
sudo firewall-cmd --add-service=cockpit --permanent
fi
if [ "$os_type" == 'Redhat' ] ; then
sudo subscription-manager repos --enable rhel-7-server-extras-rpms 1>/dev/null 2>&1
sudo yum install cockpit -y
sudo yum install cockpit-pcp cockpit-packagekit -y 1>/dev/null 2>&1
sudo setenforce 0 1>/dev/null 2>&1
sudo sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config 1>/dev/null 2>&1
sudo systemctl enable --now cockpit.socket
sudo firewall-cmd --add-service=cockpit
sudo firewall-cmd --add-service=cockpit --permanent
fi
if [ "$os_type" == 'CentOS Stream' ]; then
sudo subscription-manager repos --enable rhel-7-server-extras-rpms 1>/dev/null 2>&1
sudo yum install cockpit -y
sudo yum install cockpit-pcp -y 1>/dev/null 2>&1
sudo systemctl enable --now cockpit.socket
sudo firewall-cmd --add-service=cockpit
sudo firewall-cmd --add-service=cockpit --permanent
sudo setenforce 0 1>/dev/null 2>&1
sudo sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config 1>/dev/null 2>&1
fi
file="/etc/cockpit/disallowed-users"
if [ -f "$file" ]; then
echo "" > "$file"
else else
echo "$file is not exist" sudo docker network create $docker_network
if [ $? -ne 0 ]; then
echo "Failed to create docker network."
exit 1
fi
fi
sudo docker compose down
sudo docker compose -p websoft9 pull
sudo docker compose -p websoft9 up -d
if [ $? -ne 0 ]; then
echo "Failed to start docker services."
exit 1
fi fi
echo "Set cockpit port to 9000 ..."
sudo sed -i 's/ListenStream=9090/ListenStream=9000/' /lib/systemd/system/cockpit.socket
} }
InstallPlugins(){
# download apps install_systemd() {
mkdir -p /data/apps && cd /data/apps echo_prefix_systemd=$'\n[Systemd] - '
wget $urls/websoft9-latest.zip echo "$echo_prefix_systemdInstall Systemd service"
unzip websoft9-latest.zip
cp -r /data/apps/websoft9/docker /data/apps/w9services
rm -f websoft9-latest.zip
# install plugins if [ ! -d "$systemd_path" ]; then
cd /usr/share/cockpit sudo mkdir -p "$systemd_path"
appstore_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .APPSTORE | tr -d '"') fi
wget $urls/plugin/appstore/appstore-$appstore_version.zip
unzip appstore-$appstore_version.zip
myapps_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .MYAPPS| tr -d '"') sudo cp -r $install_path/systemd/* "$systemd_path"
wget $urls/plugin/myapps/myapps-$myapps_version.zip sudo cp -f "$systemd_path/websoft9.service" /lib/systemd/system/
unzip myapps-$myapps_version.zip if [ $? -ne 0 ]; then
echo "Failed to copy Systemd service file."
portainer_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .PORTAINER | tr -d '"') exit 1
wget $urls/plugin/portainer/portainer-$portainer_version.zip fi
unzip portainer-$portainer_version.zip
nginx_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .NGINX | tr -d '"')
wget $urls/plugin/nginx/nginx-$nginx_version.zip
unzip nginx-$nginx_version.zip
settings_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .SETTINGS | tr -d '"')
wget $urls/plugin/settings/settings-$settings_version.zip
unzip settings-$settings_version.zip
# install navigator
navigator_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .NAVIGATOR | tr -d '"')
wget $urls/plugin/navigator/navigator-$navigator_version.zip
unzip navigator-$navigator_version.zip
rm -f *.zip
# install library
cd /data
library_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .LIBRARY | tr -d '"')
wget $urls/plugin/library/library-$library_version.zip
unzip library-$library_version.zip
rm -f library-$library_version.zip
# configure cockpit
cp /data/apps/websoft9/cockpit/cockpit.conf /etc/cockpit/cockpit.conf
#####ci-section#####
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl enable --now cockpit.socket if [ $? -ne 0 ]; then
sudo systemctl restart cockpit.socket echo "Failed to reload Systemd daemon."
exit 1
fi
sudo systemctl enable websoft9.service
if [ $? -ne 0 ]; then
echo "Failed to enable Systemd service."
exit 1
fi
sudo systemctl start websoft9
if [ $? -ne 0 ]; then
echo "Failed to start Systemd service."
exit 1
fi
} }
StartAppMng(){
echo "Start appmanage API ..."
cd /data/apps/w9services/w9redis && sudo docker compose up -d
cd /data/apps/w9services/w9appmanage && sudo docker compose up -d
public_ip=`bash /data/apps/websoft9/scripts/get_ip.sh` #--------------- main-----------------------------------------
echo $public_ip > /data/apps/w9services/w9appmanage/public_ip
appmanage_ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' websoft9-appmanage)
}
StartPortainer(){ echo "------ Welcome to install Websoft9, it will take 3-5 minutes ------"
check_ports $http_port $https_port $cockpit_port
install_tools
download_source
echo "Start Portainer ..." bash $install_path/install/install_docker.sh
cd /data/apps/w9services/w9portainer && sudo docker compose up -d bash $install_path/install/install_cockpit.sh
docker pull backplane/pwgen bash $install_path/install/install_plugins.sh
new_password=$(docker run --name pwgen backplane/pwgen 15)!
docker rm -f pwgen
portainer_ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' websoft9-portainer)
echo "Portainer init password:" $new_password >> /usr/password.txt
curl -X POST -H "Content-Type: application/json" -d '{"username":"admin", "Password":"'$new_password'"}' http://$portainer_ip:9000/api/users/admin/init
curl "http://$appmanage_ip:5000/AppUpdateUser?user_name=admin&password=$new_password"
} install_backends
install_systemd
InstallNginx(){ echo "-- Install success! Access Websoft9 console by: http://Internet IP:$cockpit_port and using Linux user for login ------"
echo "Install nginxproxymanager ..."
cd /data/apps/w9services/w9nginxproxymanager && sudo docker compose up -d
sleep 30
echo "edit nginxproxymanager password..."
nginx_ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' websoft9-nginxproxymanager)
login_data=$(curl -X POST -H "Content-Type: application/json" -d '{"identity":"admin@example.com","scope":"user", "secret":"changeme"}' http://$nginx_ip:81/api/tokens)
#token=$(echo $login_data | grep -Po '(?<="token":")[^"]*')
token=$(echo $login_data | jq -r '.token')
while [ -z "$token" ]; do
sleep 5
login_data=$(curl -X POST -H "Content-Type: application/json" -d '{"identity":"admin@example.com","scope":"user", "secret":"changeme"}' http://$nginx_ip:81/api/tokens)
token=$(echo $login_data | jq -r '.token')
done
echo "Nginx token:"$token
new_password=$(docker run --name pwgen backplane/pwgen 15)!
docker rm -f pwgen
echo "Nginx init password:" $new_password >> /usr/password.txt
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"email": "help@websoft9.com", "nickname": "admin", "is_disabled": false, "roles": ["admin"]}' http://$nginx_ip:81/api/users/1
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"type":"password","current":"changeme","secret":"'$new_password'"}' http://$nginx_ip:81/api/users/1/auth
sleep 3
curl "http://$appmanage_ip:5000/AppUpdateUser?user_name=help@websoft9.com&password=$new_password"
echo "edit password success ..."
while [ ! -d "/var/lib/docker/volumes/w9nginxproxymanager_nginx_data/_data/nginx/proxy_host" ]; do
sleep 1
done
cp /data/apps/w9services/w9nginxproxymanager/initproxy.conf /var/lib/docker/volumes/w9nginxproxymanager_nginx_data/_data/nginx/proxy_host
echo $public_ip
sudo sed -i "s/domain.com/$public_ip/g" /var/lib/docker/volumes/w9nginxproxymanager_nginx_data/_data/nginx/proxy_host/initproxy.conf
sudo docker restart websoft9-nginxproxymanager
sudo docker cp websoft9-appmanage:/usr/src/app/db/database.sqlite /usr
}
EditMenu(){
echo "Start to Edit Cockpit Menu ..."
# uninstall plugins
rm -rf /usr/share/cockpit/apps /usr/share/cockpit/selinux /usr/share/cockpit/kdump /usr/share/cockpit/sosreport /usr/share/cockpit/packagekit
cp -r /data/apps/websoft9/cockpit/menu_override/* /etc/cockpit
echo "---------------------------------- Install success! When installation completed, you can access it by: http://Internet IP:9000 and using Linux user for login to install a app by websoft9's appstore. -------------------------------------------------------"
}
CheckEnvironment
InstallTools
InstallDocker
InstallCockpit
InstallPlugins
StartAppMng
StartPortainer
InstallNginx
EditMenu

View file

@ -29,6 +29,8 @@ export PATH
# $cockpit_port # $cockpit_port
# $install_path # $install_path
############################################################ ############################################################
echo "cockpit_port:$cockpit_port"
echo "install_path:$install_path"
# Install Cockpit at this port # Install Cockpit at this port
# If Cockpit installed, maintain its origin port # If Cockpit installed, maintain its origin port
@ -159,8 +161,16 @@ Set_Firewall(){
echo "$echo_prefix_cockpit Set firewall for cockpit access" echo "$echo_prefix_cockpit Set firewall 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
sudo systemctl start firewalld
sudo firewall-cmd --permanent --zone=public --add-service=cockpit sudo firewall-cmd --permanent --zone=public --add-service=cockpit
sudo firewall-cmd --reload sudo firewall-cmd --reload
sudo systemctl stop firewalld
else
sudo firewall-cmd --permanent --zone=public --add-service=cockpit
sudo firewall-cmd --reload
fi
fi fi
if [ -f /etc/selinux/config ]; then if [ -f /etc/selinux/config ]; then

View file

@ -139,7 +139,7 @@ Set_Docker(){
if eval $docker_exist; then if eval $docker_exist; then
echo "$echo_prefix_docker Starting to Set docker..." echo "$echo_prefix_docker Starting to Set docker..."
sudo systemctl enable docker sudo systemctl enable docker
sudo systemctl start docker sudo systemctl restart docker
if ! docker network inspect websoft9 > /dev/null 2>&1; then if ! docker network inspect websoft9 > /dev/null 2>&1; then
sudo docker network create websoft9 sudo docker network create websoft9
fi fi

View file

@ -1,237 +0,0 @@
#!/bin/bash
# Define PATH
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
# Export PATH
export PATH
# Command-line options
# ==============================================================================
#
# --force <y|n>
# Use the --force option to ignore all interactive choices. default is n, for example:
#
# $ sudo sh install.sh --force n
#
# --port <9000>
# Use the --port option to set Websoft9 cosole port. default is 9000, for example:
#
# $ sudo sh install.sh --port 9001
#
# --channel <release|dev>
# Use the --channel option to install a release(production) or dev distribution. default is release, for example:
#
# $ sudo sh install.sh --channel release
#
# ==============================================================================
#!/bin/bash
# 设置参数的默认值
force="n"
port="9000"
channel="release"
# 获取参数值
while [[ $# -gt 0 ]]; do
case $1 in
--force)
force="$2"
shift 2
;;
--port)
port="$2"
shift 2
;;
--channel)
channel="$2"
shift 2
;;
*)
shift
;;
esac
done
# 输出参数值
echo "Your installation parameters are as follows: "
echo "--force: $force"
echo "--port: $port"
echo "--channel: $channel"
# Define global vars
# export var can send it to subprocess
export http_port=80
export https_port=443
export cockpit_port=$port
export force_install=$force
export install_path="/data/websoft9/source"
export systemd_path="/opt/websoft9/systemd"
export source_zip="websoft9-latest.zip"
export source_unzip="websoft9"
export source_github_pages="https://websoft9.github.io/websoft9"
export tools_yum="git curl wget yum-utils jq bc unzip"
export tools_apt="git curl wget jq bc unzip"
export docker_network="websoft9"
export artifact_url="https://w9artifact.blob.core.windows.net/$channel/websoft9"
echo Install from url: $artifact_url
# Define common functions
install_tools(){
echo_prefix_tools=$'\n[Tools] - '
echo "$echo_prefix_tools Starting install necessary tool..."
dnf --version >/dev/null 2>&1
dnf_status=$?
yum --version >/dev/null 2>&1
yum_status=$?
apt --version >/dev/null 2>&1
apt_status=$?
if [ $dnf_status -eq 0 ]; then
dnf install $tools_yum -y
elif [ $yum_status -eq 0 ]; then
yum install $tools_yum -y
elif [ $apt_status -eq 0 ]; then
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
echo "Waiting for other software managers to finish..."
sleep 5
done
sudo apt update -y 1>/dev/null 2>&1
apt install $tools_apt -y --assume-yes
else
echo "None of the required package managers are installed."
fi
}
download_source() {
echo_prefix_source=$'\n[Dowload Source] - '
echo "$echo_prefix_source Download Websoft9 source code from $artifact_url/$source_zip"
rm -rf websoft9-latest.zip*
if [ -d "$install_path" ]; then
echo "Directory $install_path already exists and installation will cover it."
else
mkdir -p "$install_path"
fi
wget "$artifact_url/$source_zip"
if [ $? -ne 0 ]; then
echo "Failed to download source package."
exit 1
fi
unzip -o "$source_zip" -d "$install_path"
if [ $? -ne 0 ]; then
echo "Failed to unzip source package."
exit 1
fi
mv -fn $install_path/$source_unzip/* "$install_path"
if [ $? -ne 0 ]; then
echo "Move directory failed"
exit 1
fi
rm -rf "$source_zip" "$install_path/$source_unzip"
}
check_ports() {
local ports=("$@")
for port in "${ports[@]}"; do
if netstat -tuln | grep ":$port " >/dev/null; then
echo "Port $port is in use, install failed"
exit
fi
done
echo "All ports are available"
}
install_backends() {
echo_prefix_backends=$'\n[Backend] - '
echo "$echo_prefix_backends Install backend docker services"
cd "$install_path/docker"
if [ $? -ne 0 ]; then
echo "Failed to change directory."
exit 1
fi
sudo docker network inspect $docker_network >/dev/null 2>&1
if [ $? -eq 0 ]; then
echo "Docker network '$docker_network' already exists."
else
sudo docker network create $docker_network
if [ $? -ne 0 ]; then
echo "Failed to create docker network."
exit 1
fi
fi
sudo docker compose -p websoft9 pull
sudo docker compose -p websoft9 up -d
if [ $? -ne 0 ]; then
echo "Failed to start docker services."
exit 1
fi
}
install_systemd() {
echo_prefix_systemd=$'\n[Systemd] - '
echo "$echo_prefix_systemdInstall Systemd service"
if [ ! -d "$systemd_path" ]; then
sudo mkdir -p "$systemd_path"
fi
sudo cp -r $install_path/systemd/* "$systemd_path"
sudo cp -f "$systemd_path/websoft9.service" /lib/systemd/system/
if [ $? -ne 0 ]; then
echo "Failed to copy Systemd service file."
exit 1
fi
sudo systemctl daemon-reload
if [ $? -ne 0 ]; then
echo "Failed to reload Systemd daemon."
exit 1
fi
sudo systemctl enable websoft9.service
if [ $? -ne 0 ]; then
echo "Failed to enable Systemd service."
exit 1
fi
sudo systemctl start websoft9
if [ $? -ne 0 ]; then
echo "Failed to start Systemd service."
exit 1
fi
}
#--------------- main-----------------------------------------
echo "------ Welcome to install Websoft9, it will take 3-5 minutes ------"
check_ports $http_port $https_port $cockpit_port
install_tools
download_source
bash $install_path/install/install_docker.sh
bash $install_path/install/install_cockpit.sh
bash $install_path/install/install_plugins.sh
install_backends
install_systemd
echo "-- Install success! Access Websoft9 console by: http://Internet IP:$cockpit_port and using Linux user for login ------"

73
install/uninstall.sh Normal file
View file

@ -0,0 +1,73 @@
#!/bin/bash
# Define PATH
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
# Export PATH
export PATH
# Command-line options
# ==============================================================================
#
# --cockpit
# Use the --cockpit option to remove cockpit:
#
# $ sudo sh install.sh --cockpit
#
# --files
# Use the --files option remove files have installed:
#
# $ sudo sh install.sh --cockpit
#
#
# ==============================================================================
install_path="/data/websoft9/source"
systemd_path="/opt/websoft9/systemd"
cockpit_plugin_path="/usr/share/cockpit"
cockpit_packages="cockpit cockpit-ws cockpit-bridge cockpit-system cockpit-pcp cockpit-storaged cockpit-networkmanager cockpit-session-recording cockpit-doc cockpit-packagekit cockpit-sosreport"
echo -e "\n---Remove Websoft9 backend service containers---"
sudo docker compose -p websoft9 down -v
echo -e "\n---Remove Websoft9 systemd service---"
sudo systemctl disable websoft9
sudo systemctl stop websoft9
rm -rf /lib/systemd/system/websoft9.service
handle_cockpit() {
echo -e "\n---Remove Cockpit---"
sudo systemctl stop cockpit.socket cockpit
for package in $cockpit_packages; do
sudo pkcon remove $package -y || true
done
}
handle_files() {
echo -e "\n---Remove files---"
sudo rm -rf $install_path/* $systemd_path/* $cockpit_plugin_path/*
}
for arg in "$@"
do
case $arg in
--cockpit)
handle_cockpit
shift
;;
--files)
handle_files
shift
;;
*)
echo "Unknown argument: $arg"
exit 1
;;
esac
done
echo -e "\nCongratulations, Websoft9 uninstall is complete!"

472
scripts/install-bk.sh Normal file
View file

@ -0,0 +1,472 @@
#!/bin/bash
PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
export PATH
function error_exit {
echo "$1" 1>&2
exit 1
}
trap 'error_exit "Please push issue to: https://github.com/Websoft9/stackhub/issues"' ERR
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
function get_os_type() {
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
elif type lsb_release >/dev/null 2>&1; then
OS=$(lsb_release -si)
else
OS=$(uname -s)
fi
if [[ "$OS" == "CentOS Linux" ]]; then
echo "CentOS"
elif [[ "$OS" == "CentOS Stream" ]]; then
echo "CentOS Stream"
elif [[ "$OS" == "Rocky Linux" ]]; then
echo "Rocky Linux"
elif [[ "$OS" == "Oracle Linux Server" ]]; then
echo "OracleLinux"
elif [[ "$OS" == "Debian GNU/Linux" ]]; then
echo "Debian"
elif [[ "$OS" == "Ubuntu" ]]; then
echo "Ubuntu"
elif [[ "$OS" == "Fedora Linux" ]]; then
echo "Fedora"
elif [[ "$OS" =~ "Red Hat Enterprise Linux" ]]; then
echo "Redhat"
else
echo $OS
fi
}
function get_os_version() {
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
VERSION=$VERSION_ID
elif type lsb_release >/dev/null 2>&1; then
OS=$(lsb_release -si)
VERSION=$(lsb_release -sr)
else
OS=$(uname -s)
VERSION=$(uname -r)
fi
echo $VERSION
}
os_type=$(get_os_type)
os_version=$(get_os_version)
CheckEnvironment(){
echo "---------------------------------- Welcome to install websoft9's appstore, it will take 3-5 minutes -------------------------------------------------------"
echo "Check environment ..."
echo os_type: $os_type
echo os_version: $os_version
if [ $(id -u) != "0" ]; then
echo "Please change to root or 'sudo su' to up system privileges, and reinstall the script again ."
exit 1
fi
if [ $(getconf WORD_BIT) = '32' ] && [ $(getconf LONG_BIT) = '64' ] ; then
echo "64-bit operating system detected."
else
echo "This script only works on 64-bit operating systems."
exit 1
fi
if [ "$os_type" == 'CentOS' ] ;then
if [ "$os_version" != "7" ]; then
echo "This app only supported on CentOS 7"
exit 1
fi
fi
if [ "$os_type" == 'CentOS Stream' ] ;then
if [ "$os_version" != "8" ] || [ "$os_version" != "9" ]; then
echo "This app only supported on CentOS Stream 8,9"
exit 1
fi
fi
if [ "$os_type" == 'Rocky Linux' ] ;then
if [ "${os_version:0:1}" == "8" ] || [ "${os_version:0:1}" == "9" ]; then
echo ""
else
echo "This app only supported on Rocky Linux 8"
exit 1
fi
fi
if [ "$os_type" == 'Fedora' ];then
if [ "$os_version" != "37" ]; then
echo "This app only supported on Fedora 37"
exit 1
fi
fi
if [ "$os_type" == 'Redhat' ];then
if [ "${os_version:0:1}" != "7" ] && [ "${os_version:0:1}" != "8" ] && [ "${os_version:0:1}" != "9" ]; then
echo "This app only supported on Redhat 7,8"
exit 1
fi
fi
if [ "$os_type" == 'Ubuntu' ];then
if [ "$os_version" != "22.04" ] && [ "$os_version" != "20.04" ] && [ "$os_version" != "18.04" ]; then
echo "This app only supported on Ubuntu 22.04,20.04,18.04"
exit 1
fi
fi
if [ "$os_type" == 'Debian' ];then
if [ "$os_version" != "11" ];then
echo "This app only supported on Debian 11"
exit 1
fi
fi
# Check port used
if netstat -tuln | grep -qE ':(80|443|9000)\s'; then
echo "Port 80,443,9000 is already in use."
exit 1
else
echo "Port 80,443, 9000 are free."
fi
}
InstallTools(){
echo "Prepare to install Tools ..."
if [ "$os_type" == 'CentOS' ] || [ "$os_type" == 'Rocky Linux' ] || [ "$os_type" == 'CentOS Stream' ] || [ "$os_type" == 'Fedora' ] || [ "$os_type" == 'OracleLinux' ] || [ "$os_type" == 'Redhat' ];then
sudo yum update -y
sudo yum install git curl wget yum-utils jq bc unzip -y
fi
if [ "$os_type" == 'Ubuntu' ] || [ "$os_type" == 'Debian' ] ;then
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
echo "Waiting for other software managers to finish..."
sleep 5
done
sudo apt update -y 1>/dev/null 2>&1
if command -v git > /dev/null;then
echo "git installed ..."
else
sudo apt install git -y
fi
if command -v curl > /dev/null;then
echo "jcurlq installed ..."
else
sudo apt install curl -y
fi
if command -v wget > /dev/null;then
echo "wget installed ..."
else
sudo apt install wget -y
fi
if command -v jq > /dev/null;then
echo "jq installed ..."
else
sudo apt install jq -y
fi
if command -v bc > /dev/null;then
echo "bc installed ..."
else
sudo apt install bc -y
fi
if command -v unzip > /dev/null;then
echo "unzip installed ..."
else
sudo apt install unzip -y
fi
fi
}
InstallDocker(){
if command -v docker &> /dev/null
then
echo "Docker is installed, update..."
if command -v apt > /dev/null;then
sudo apt -y install --only-upgrade docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif command -v dnf > /dev/null;then
sudo dnf update -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
elif command -v yum > /dev/null;then
sudo yum update -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
fi
sudo systemctl start docker
sudo systemctl enable docker
if ! docker network inspect websoft9 > /dev/null 2>&1; then
sudo docker network create websoft9
fi
return
else
echo "Docker is not installed, start to install..."
fi
if [ "$os_type" == 'CentOS' ];then
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
fi
if [ "$os_type" == 'Ubuntu' ] || [ "$os_type" == 'Debian' ] ;then
apt-get update
while fuser /var/lib/dpkg/lock >/dev/null 2>&1 ; do
echo "Waiting for other software managers to finish..."
sleep 5
done
curl -fsSL https://get.docker.com -o get-docker.sh && sh get-docker.sh
sleep 30
fi
if [ "$os_type" == 'OracleLinux' ] ;then
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
fi
if [ "$os_type" == 'Fedora' ] ;then
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/fedora/docker-ce.repo
sudo yum install device-mapper-persistent-data lvm2 docker-ce docker-ce-cli containerd.io docker-compose-plugin docker-scan-plugin docker-ce-rootless-extras -y
fi
if [ "$os_type" == 'Redhat' ] ;then
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc -y 1>/dev/null 2>&1
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
fi
if [ "$os_type" == 'CentOS Stream' ] || [ "$os_type" == 'Rocky Linux' ];then
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine podman runc -y 1>/dev/null 2>&1
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y
fi
sudo systemctl start docker
sudo systemctl enable docker
if ! docker network inspect websoft9 > /dev/null 2>&1; then
sudo docker network create websoft9
fi
}
InstallCockpit(){
echo "Prepare to install Cockpit ..."
if [ "${os_type}" == 'Debian' ]; then
VERSION_CODENAME=$(cat /etc/os-release |grep VERSION_CODENAME|cut -f2 -d"=")
sudo echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" >/etc/apt/sources.list.d/backports.list
sudo apt update
sudo apt install -t ${VERSION_CODENAME}-backports cockpit -y
sudo apt install cockpit-pcp cockpit-packagekit -y 1>/dev/null 2>&1
fi
if [ "${os_type}" == 'Ubuntu' ]; then
if grep -q "^#.*deb http://mirrors.tencentyun.com/ubuntu.*backports" /etc/apt/sources.list; then
echo "Add backports deb ..."
sudo sed -i 's/^#\(.*deb http:\/\/mirrors.tencentyun.com\/ubuntu.*backports.*\)/\1/' /etc/apt/sources.list
apt update
fi
VERSION_CODENAME=$(cat /etc/os-release |grep VERSION_CODENAME|cut -f2 -d"=")
sudo apt install -t ${VERSION_CODENAME}-backports cockpit -y
sudo apt install cockpit-pcp -y 1>/dev/null 2>&1
echo "Cockpit allow root user"
echo "" >/etc/cockpit/disallowed-users 1>/dev/null 2>&1
fi
if [ "${os_type}" == 'CentOS' ] || [ "$os_type" == 'OracleLinux' ]; then
sudo yum install cockpit -y
sudo yum install cockpit-pcp cockpit-packagekit -y 1>/dev/null 2>&1
sudo systemctl enable --now cockpit.socket
sudo firewall-cmd --permanent --zone=public --add-service=cockpit
sudo firewall-cmd --reload
fi
if [ "$os_type" == 'Fedora' ]; then
sudo dnf install cockpit -y
sudo dnf install cockpit-pcp cockpit-packagekit -y 1>/dev/null 2>&1
sudo systemctl enable --now cockpit.socket
sudo firewall-cmd --add-service=cockpit
sudo firewall-cmd --add-service=cockpit --permanent
fi
if [ "$os_type" == 'Redhat' ] ; then
sudo subscription-manager repos --enable rhel-7-server-extras-rpms 1>/dev/null 2>&1
sudo yum install cockpit -y
sudo yum install cockpit-pcp cockpit-packagekit -y 1>/dev/null 2>&1
sudo setenforce 0 1>/dev/null 2>&1
sudo sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config 1>/dev/null 2>&1
sudo systemctl enable --now cockpit.socket
sudo firewall-cmd --add-service=cockpit
sudo firewall-cmd --add-service=cockpit --permanent
fi
if [ "$os_type" == 'CentOS Stream' ]; then
sudo subscription-manager repos --enable rhel-7-server-extras-rpms 1>/dev/null 2>&1
sudo yum install cockpit -y
sudo yum install cockpit-pcp -y 1>/dev/null 2>&1
sudo systemctl enable --now cockpit.socket
sudo firewall-cmd --add-service=cockpit
sudo firewall-cmd --add-service=cockpit --permanent
sudo setenforce 0 1>/dev/null 2>&1
sudo sed -i 's/SELINUX=.*/SELINUX=disabled/' /etc/selinux/config 1>/dev/null 2>&1
fi
file="/etc/cockpit/disallowed-users"
if [ -f "$file" ]; then
echo "" > "$file"
else
echo "$file is not exist"
fi
echo "Set cockpit port to 9000 ..."
sudo sed -i 's/ListenStream=9090/ListenStream=9000/' /lib/systemd/system/cockpit.socket
}
InstallPlugins(){
# download apps
mkdir -p /data/apps && cd /data/apps
wget $urls/websoft9-latest.zip
unzip websoft9-latest.zip
cp -r /data/apps/websoft9/docker /data/apps/w9services
rm -f websoft9-latest.zip
# install plugins
cd /usr/share/cockpit
appstore_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .APPSTORE | tr -d '"')
wget $urls/plugin/appstore/appstore-$appstore_version.zip
unzip appstore-$appstore_version.zip
myapps_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .MYAPPS| tr -d '"')
wget $urls/plugin/myapps/myapps-$myapps_version.zip
unzip myapps-$myapps_version.zip
portainer_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .PORTAINER | tr -d '"')
wget $urls/plugin/portainer/portainer-$portainer_version.zip
unzip portainer-$portainer_version.zip
nginx_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .NGINX | tr -d '"')
wget $urls/plugin/nginx/nginx-$nginx_version.zip
unzip nginx-$nginx_version.zip
settings_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .SETTINGS | tr -d '"')
wget $urls/plugin/settings/settings-$settings_version.zip
unzip settings-$settings_version.zip
# install navigator
navigator_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .NAVIGATOR | tr -d '"')
wget $urls/plugin/navigator/navigator-$navigator_version.zip
unzip navigator-$navigator_version.zip
rm -f *.zip
# install library
cd /data
library_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .LIBRARY | tr -d '"')
wget $urls/plugin/library/library-$library_version.zip
unzip library-$library_version.zip
rm -f library-$library_version.zip
# configure cockpit
cp /data/apps/websoft9/cockpit/cockpit.conf /etc/cockpit/cockpit.conf
#####ci-section#####
sudo systemctl daemon-reload
sudo systemctl enable --now cockpit.socket
sudo systemctl restart cockpit.socket
}
StartAppMng(){
echo "Start appmanage API ..."
cd /data/apps/w9services/w9redis && sudo docker compose up -d
cd /data/apps/w9services/w9appmanage && sudo docker compose up -d
public_ip=`bash /data/apps/websoft9/scripts/get_ip.sh`
echo $public_ip > /data/apps/w9services/w9appmanage/public_ip
appmanage_ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' websoft9-appmanage)
}
StartPortainer(){
echo "Start Portainer ..."
cd /data/apps/w9services/w9portainer && sudo docker compose up -d
docker pull backplane/pwgen
new_password=$(docker run --name pwgen backplane/pwgen 15)!
docker rm -f pwgen
portainer_ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' websoft9-portainer)
echo "Portainer init password:" $new_password >> /usr/password.txt
curl -X POST -H "Content-Type: application/json" -d '{"username":"admin", "Password":"'$new_password'"}' http://$portainer_ip:9000/api/users/admin/init
curl "http://$appmanage_ip:5000/AppUpdateUser?user_name=admin&password=$new_password"
}
InstallNginx(){
echo "Install nginxproxymanager ..."
cd /data/apps/w9services/w9nginxproxymanager && sudo docker compose up -d
sleep 30
echo "edit nginxproxymanager password..."
nginx_ip=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' websoft9-nginxproxymanager)
login_data=$(curl -X POST -H "Content-Type: application/json" -d '{"identity":"admin@example.com","scope":"user", "secret":"changeme"}' http://$nginx_ip:81/api/tokens)
#token=$(echo $login_data | grep -Po '(?<="token":")[^"]*')
token=$(echo $login_data | jq -r '.token')
while [ -z "$token" ]; do
sleep 5
login_data=$(curl -X POST -H "Content-Type: application/json" -d '{"identity":"admin@example.com","scope":"user", "secret":"changeme"}' http://$nginx_ip:81/api/tokens)
token=$(echo $login_data | jq -r '.token')
done
echo "Nginx token:"$token
new_password=$(docker run --name pwgen backplane/pwgen 15)!
docker rm -f pwgen
echo "Nginx init password:" $new_password >> /usr/password.txt
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"email": "help@websoft9.com", "nickname": "admin", "is_disabled": false, "roles": ["admin"]}' http://$nginx_ip:81/api/users/1
curl -X PUT -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d '{"type":"password","current":"changeme","secret":"'$new_password'"}' http://$nginx_ip:81/api/users/1/auth
sleep 3
curl "http://$appmanage_ip:5000/AppUpdateUser?user_name=help@websoft9.com&password=$new_password"
echo "edit password success ..."
while [ ! -d "/var/lib/docker/volumes/w9nginxproxymanager_nginx_data/_data/nginx/proxy_host" ]; do
sleep 1
done
cp /data/apps/w9services/w9nginxproxymanager/initproxy.conf /var/lib/docker/volumes/w9nginxproxymanager_nginx_data/_data/nginx/proxy_host
echo $public_ip
sudo sed -i "s/domain.com/$public_ip/g" /var/lib/docker/volumes/w9nginxproxymanager_nginx_data/_data/nginx/proxy_host/initproxy.conf
sudo docker restart websoft9-nginxproxymanager
sudo docker cp websoft9-appmanage:/usr/src/app/db/database.sqlite /usr
}
EditMenu(){
echo "Start to Edit Cockpit Menu ..."
# uninstall plugins
rm -rf /usr/share/cockpit/apps /usr/share/cockpit/selinux /usr/share/cockpit/kdump /usr/share/cockpit/sosreport /usr/share/cockpit/packagekit
cp -r /data/apps/websoft9/cockpit/menu_override/* /etc/cockpit
echo "---------------------------------- Install success! When installation completed, you can access it by: http://Internet IP:9000 and using Linux user for login to install a app by websoft9's appstore. -------------------------------------------------------"
}
CheckEnvironment
InstallTools
InstallDocker
InstallCockpit
InstallPlugins
StartAppMng
StartPortainer
InstallNginx
EditMenu