mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-21 23:20:23 +00:00
install
This commit is contained in:
parent
4da5ec3f8b
commit
10776537f8
4 changed files with 123 additions and 142 deletions
|
@ -30,7 +30,8 @@ export PATH
|
||||||
# $install_path
|
# $install_path
|
||||||
############################################################
|
############################################################
|
||||||
|
|
||||||
# 设置参数的默认值
|
# Install Cockpit at this port
|
||||||
|
# If Cockpit installed, maintain its origin port
|
||||||
port="9000"
|
port="9000"
|
||||||
|
|
||||||
# 获取参数值
|
# 获取参数值
|
||||||
|
@ -47,14 +48,10 @@ while [[ $# -gt 0 ]]; do
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
if [ -z "$cockpit_port" ]; then
|
|
||||||
cockpit_port=$port
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo_prefix_cockpit=$'\n[Cockpit] - '
|
echo_prefix_cockpit=$'\n[Cockpit] - '
|
||||||
cockpit_packages_install="cockpit cockpit-pcp cockpit-sosreport"
|
# package cockpit depends_on [cockpit-bridge,cockpit-ws,cockpit-system], but update cockpit the depends don't update
|
||||||
cockpit_packages_upgrade="cockpit cockpit-ws cockpit-bridge cockpit-system cockpit-ws cockpit-storaged cockpit-session-recording cockpit-doc cockpit-packagekit cockpit-pcp cockpit-sosreport"
|
cockpit_packages="cockpit cockpit-ws cockpit-bridge cockpit-system cockpit-pcp cockpit-storaged cockpit-networkmanager cockpit-session-recording cockpit-doc cockpit-packagekit cockpit-sosreport"
|
||||||
cockpit_plugin_delete="apps,machines,selinux,subscriptions,kdump,updates,playground,packagekit"
|
cockpit_plugin_delete="apps,machines,selinux,subscriptions,kdump,updates,playground,packagekit,session-recording"
|
||||||
menu_overrides_github_page_url="https://websoft9.github.io/websoft9/cockpit/menu_override"
|
menu_overrides_github_page_url="https://websoft9.github.io/websoft9/cockpit/menu_override"
|
||||||
cockpit_config_github_page_url="https://websoft9.github.io/websoft9/cockpit/cockpit.conf"
|
cockpit_config_github_page_url="https://websoft9.github.io/websoft9/cockpit/cockpit.conf"
|
||||||
cockpit_menu_overrides=(networkmanager.override.json shell.override.json storaged.override.json systemd.override.json users.override.json)
|
cockpit_menu_overrides=(networkmanager.override.json shell.override.json storaged.override.json systemd.override.json users.override.json)
|
||||||
|
@ -73,6 +70,22 @@ Pin: release a=$VERSION_CODENAME-backports
|
||||||
Pin-Priority: 1000
|
Pin-Priority: 1000
|
||||||
"
|
"
|
||||||
|
|
||||||
|
cockpit_exist() {
|
||||||
|
systemctl list-unit-files | grep -q "cockpit.service"
|
||||||
|
return $?
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if cockpit_exist; then
|
||||||
|
cockpit_port=$(grep -oP "(?<=^ListenStream=).*" "/lib/systemd/system/cockpit.socket")
|
||||||
|
echo "Maintain original port: $cockpit_port"
|
||||||
|
else
|
||||||
|
if [ -z "$cockpit_port" ]; then
|
||||||
|
cockpit_port="$port"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
check_ports() {
|
check_ports() {
|
||||||
local ports=("$@")
|
local ports=("$@")
|
||||||
|
|
||||||
|
@ -233,17 +246,18 @@ Upgrade_Cockpit(){
|
||||||
sudo dpkg --configure -a
|
sudo dpkg --configure -a
|
||||||
apt update -y
|
apt update -y
|
||||||
apt --fix-broken install
|
apt --fix-broken install
|
||||||
apt install -u $cockpit_packages_upgrade -y
|
apt install -u $cockpit_packages -y
|
||||||
else
|
else
|
||||||
sudo pkcon refresh > /dev/null
|
sudo pkcon refresh > /dev/null
|
||||||
sudo pkcon get-updates > /dev/null
|
sudo pkcon get-updates > /dev/null
|
||||||
sudo pkcon update $cockpit_packages_upgrade -y
|
sudo pkcon update $cockpit_packages -y
|
||||||
|
sudo pkcon install $cockpit_packages -y --allow-untrusted --allow-reinstall
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
Install_Cockpit(){
|
Install_Cockpit(){
|
||||||
|
|
||||||
if systemctl list-unit-files | grep -q cockpit.service; then
|
if cockpit_exist; then
|
||||||
Upgrade_Cockpit
|
Upgrade_Cockpit
|
||||||
Restart_Cockpit
|
Restart_Cockpit
|
||||||
else
|
else
|
||||||
|
@ -252,7 +266,7 @@ Install_Cockpit(){
|
||||||
export DEBIAN_FRONTEND=noninteractive
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
sudo pkcon refresh > /dev/null
|
sudo pkcon refresh > /dev/null
|
||||||
sudo pkcon get-updates > /dev/null
|
sudo pkcon get-updates > /dev/null
|
||||||
sudo pkcon install $cockpit_packages_install -y --allow-untrusted
|
sudo pkcon install $cockpit_packages -y --allow-untrusted --allow-reinstall
|
||||||
Restart_Cockpit
|
Restart_Cockpit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -73,8 +73,8 @@ export source_github_pages="https://websoft9.github.io/websoft9"
|
||||||
export tools_yum="git curl wget yum-utils jq bc unzip"
|
export tools_yum="git curl wget yum-utils jq bc unzip"
|
||||||
export tools_apt="git curl wget jq bc unzip"
|
export tools_apt="git curl wget jq bc unzip"
|
||||||
export docker_network="websoft9"
|
export docker_network="websoft9"
|
||||||
export urls="https://w9artifact.blob.core.windows.net/$channel/websoft9"
|
export artifact_url="https://w9artifact.blob.core.windows.net/$channel/websoft9"
|
||||||
echo Install from url: $urls
|
echo Install from url: $artifact_url
|
||||||
|
|
||||||
# Define common functions
|
# Define common functions
|
||||||
|
|
||||||
|
|
|
@ -3,119 +3,92 @@ PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
|
||||||
export PATH
|
export PATH
|
||||||
|
|
||||||
|
|
||||||
|
# Command-line options
|
||||||
|
# ==========================================================
|
||||||
|
#
|
||||||
|
# --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
|
||||||
|
#
|
||||||
|
# ==============================================================================
|
||||||
|
|
||||||
|
# get input and define vars
|
||||||
### -----------------------------------------------------###
|
while [[ $# -gt 0 ]]; do
|
||||||
|
case $1 in
|
||||||
InstallPlugins(){
|
--channel)
|
||||||
|
channel="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
# install plugins
|
*)
|
||||||
cd /usr/share/cockpit
|
shift
|
||||||
appstore_version=$(cat /data/apps/websoft9/version.json | jq .PLUGINS |jq .APPSTORE | tr -d '"')
|
;;
|
||||||
wget $urls/plugin/appstore/appstore-$appstore_version.zip
|
esac
|
||||||
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
|
done
|
||||||
echo "Nginx token:"$token
|
|
||||||
new_password=$(docker run --name pwgen backplane/pwgen 15)!
|
|
||||||
docker rm -f pwgen
|
if [ -z "$channel" ]; then
|
||||||
echo "Nginx init password:" $new_password >> /usr/password.txt
|
channel="release"
|
||||||
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
|
fi
|
||||||
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
|
if [ -z "$source_github_pages" ]; then
|
||||||
curl "http://$appmanage_ip:5000/AppUpdateUser?user_name=help@websoft9.com&password=$new_password"
|
source_github_pages="https://websoft9.github.io/websoft9"
|
||||||
echo "edit password success ..."
|
fi
|
||||||
while [ ! -d "/var/lib/docker/volumes/w9nginxproxymanager_nginx_data/_data/nginx/proxy_host" ]; do
|
|
||||||
sleep 1
|
if [ -z "$install_path" ]; then
|
||||||
done
|
install_path="/data/websoft9/source"
|
||||||
cp /data/apps/w9services/w9nginxproxymanager/initproxy.conf /var/lib/docker/volumes/w9nginxproxymanager_nginx_data/_data/nginx/proxy_host
|
fi
|
||||||
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
|
echo "Your installation parameters are as follows: "
|
||||||
sudo docker cp websoft9-appmanage:/usr/src/app/db/database.sqlite /usr
|
echo "--channel: $channel"
|
||||||
|
|
||||||
|
artifact_url="https://w9artifact.blob.core.windows.net/$channel/websoft9/plugin"
|
||||||
|
echo_prefix_cockpit=$'\n[Plugins] - '
|
||||||
|
|
||||||
|
|
||||||
|
version_json(){
|
||||||
|
|
||||||
|
if [ -f "$install_path/version.json" ]; then
|
||||||
|
echo "Find version file on your $install_path "
|
||||||
|
else
|
||||||
|
echo "Get version.json from $source_github_pages "
|
||||||
|
mydata=$(curl -s "$url")
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "URL does not exist or cannot be accessed."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "$mydata"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
mydata=$(cat "$install_path/version.json")
|
||||||
|
echo $mydata
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
install_plugins() {
|
||||||
|
echo "$echo_prefix_cockpit Start to install plugins"
|
||||||
|
data=$(version_json)
|
||||||
|
|
||||||
|
# 解析数据文件,获取 plugins 的子元素和对应的版本号
|
||||||
|
plugins=$(echo "$data" | jq -r '.plugins | keys_unsorted[]')
|
||||||
|
versions=$(echo "$data" | jq -r '.plugins | .[]')
|
||||||
|
|
||||||
InstallPlugins
|
# 定义数组变量
|
||||||
|
declare -a artifact_array
|
||||||
|
|
||||||
|
# 构建数组内容
|
||||||
|
readarray -t plugins_array <<<"$plugins"
|
||||||
|
readarray -t versions_array <<<"$versions"
|
||||||
|
|
||||||
|
for ((i=0; i<${#plugins_array[@]}; i++)); do
|
||||||
|
artifact_array+=("$artifact_url/${plugins_array[$i]}-${versions_array[$i]}")
|
||||||
|
done
|
||||||
|
|
||||||
|
# 打印数组元素
|
||||||
|
for element in "${artifact_array[@]}"; do
|
||||||
|
echo "$element"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
install_plugins
|
||||||
|
|
30
version.json
30
version.json
|
@ -1,20 +1,14 @@
|
||||||
{
|
{
|
||||||
"SERVICES": {
|
"version": "0.8.20",
|
||||||
"PORTAINER": "2.18.3",
|
"plugins": {
|
||||||
"NGINX": "2.10.3",
|
"portainer": "0.0.6",
|
||||||
"APPMANAGE": "0.8.17",
|
"nginx": "0.0.5",
|
||||||
"REDIS": "7.0.11"
|
"myapps": "0.0.8",
|
||||||
|
"appstore": "0.0.7",
|
||||||
|
"settings": "0.0.5",
|
||||||
|
"navigator": "0.5.10"
|
||||||
},
|
},
|
||||||
"PLUGINS": {
|
"OS": {
|
||||||
"PORTAINER": "0.0.6",
|
|
||||||
"NGINX": "0.0.5",
|
|
||||||
"MYAPPS": "0.0.8",
|
|
||||||
"APPSTORE": "0.0.7",
|
|
||||||
"SETTINGS": "0.0.5",
|
|
||||||
"NAVIGATOR": "0.5.10",
|
|
||||||
"LIBRARY": "0.5.4"
|
|
||||||
},
|
|
||||||
"OS_SUPPORT": {
|
|
||||||
"Fedora": [
|
"Fedora": [
|
||||||
"38",
|
"38",
|
||||||
"37"
|
"37"
|
||||||
|
@ -37,13 +31,13 @@
|
||||||
"8"
|
"8"
|
||||||
],
|
],
|
||||||
"Debian": [
|
"Debian": [
|
||||||
"11"
|
"11",
|
||||||
|
"10"
|
||||||
],
|
],
|
||||||
"Ubuntu": [
|
"Ubuntu": [
|
||||||
"22.04",
|
"22.04",
|
||||||
"20.04",
|
"20.04",
|
||||||
"18.04"
|
"18.04"
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
"VERSION": "0.8.20"
|
|
||||||
}
|
}
|
Loading…
Reference in a new issue