From a2fc0dc734e7c45c5c3bb6e3fa1c29990eaa8e7d Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Tue, 1 Aug 2023 10:02:23 +0800 Subject: [PATCH] override improve and aitifacts add docs --- .github/workflows/upload_artifact.yml | 4 +- .../networkmanager.override.json | 28 ++++-- cockpit/menu_override/shell.override.json | 31 +----- cockpit/menu_override/storaged.override.json | 56 +++++------ cockpit/menu_override/systemd.override.json | 41 ++++---- cockpit/menu_override/users.override.json | 16 ++- install/install.sh | 49 +--------- install/update.sh | 98 +++++-------------- 8 files changed, 109 insertions(+), 214 deletions(-) diff --git a/.github/workflows/upload_artifact.yml b/.github/workflows/upload_artifact.yml index b0ddce46..1cb0aa8e 100644 --- a/.github/workflows/upload_artifact.yml +++ b/.github/workflows/upload_artifact.yml @@ -34,7 +34,9 @@ jobs: cp -r docker websoft9 cp -r cockpit websoft9 cp -r scripts websoft9 - cp CHANGELOG.md websoft9 + cp -r install websoft9 + cp -r docs websoft9 + cp *.md websoft9 cp version.json websoft9 zip -r websoft9-$version.zip websoft9 cp websoft9-$version.zip artifacts diff --git a/cockpit/menu_override/networkmanager.override.json b/cockpit/menu_override/networkmanager.override.json index 3151a0a0..9ca218d3 100644 --- a/cockpit/menu_override/networkmanager.override.json +++ b/cockpit/menu_override/networkmanager.override.json @@ -1,8 +1,5 @@ { - "name": "network", - "conditions": [ - {"path-exists": "/usr/share/dbus-1/system.d/org.freedesktop.NetworkManager.conf"} - ], + "menu": null, "tools": { "index": { "label": "Networking", @@ -31,13 +28,30 @@ ], "keywords": [ { - "matches": ["network", "interface", "bridge", "vlan", "bond", "team", "port", "mac", "ipv4", "ipv6"] + "matches": [ + "network", + "interface", + "bridge", + "vlan", + "bond", + "team", + "port", + "mac", + "ipv4", + "ipv6" + ] }, { - "matches": ["firewall", "firewalld", "zone", "tcp", "udp"], + "matches": [ + "firewall", + "firewalld", + "zone", + "tcp", + "udp" + ], "goto": "/network/firewall" } ] } } -} +} \ No newline at end of file diff --git a/cockpit/menu_override/shell.override.json b/cockpit/menu_override/shell.override.json index 45a3dd4f..b5bbf7eb 100644 --- a/cockpit/menu_override/shell.override.json +++ b/cockpit/menu_override/shell.override.json @@ -1,33 +1,6 @@ { - "requires": { - "cockpit": "239" - }, "locales": { "en-us": "English", "zh-cn": "中文(中国)" - }, - "bridges": [ - { - "privileged": true, - "environ": [ - "SUDO_ASKPASS=${libexecdir}/cockpit-askpass" - ], - "spawn": [ - "sudo", - "-k", - "-A", - "cockpit-bridge", - "--privileged" - ] - }, - { - "privileged": true, - "spawn": [ - "pkexec", - "--disable-internal-agent", - "cockpit-bridge", - "--privileged" - ] - } - ] -} + } +} \ No newline at end of file diff --git a/cockpit/menu_override/storaged.override.json b/cockpit/menu_override/storaged.override.json index eb1c4887..726a9ccc 100644 --- a/cockpit/menu_override/storaged.override.json +++ b/cockpit/menu_override/storaged.override.json @@ -1,12 +1,5 @@ { - "name": "storage", - "requires": { - "cockpit": "266" - }, - "conditions": [ - {"path-exists": "/usr/share/dbus-1/system.d/org.freedesktop.UDisks2.conf"} - ], - + "menu": null, "tools": { "index": { "label": "Storage", @@ -47,29 +40,30 @@ ], "keywords": [ { - "matches": ["filesystem", "partition", "nfs", "raid", "volume", "disk", "vdo", "iscsi", "drive", "mount", "unmount", "udisks", "mkfs", "format", "fstab", "lvm2", "luks", "encryption", "nbde", "tang"] + "matches": [ + "filesystem", + "partition", + "nfs", + "raid", + "volume", + "disk", + "vdo", + "iscsi", + "drive", + "mount", + "unmount", + "udisks", + "mkfs", + "format", + "fstab", + "lvm2", + "luks", + "encryption", + "nbde", + "tang" + ] } ] } - }, - - "config": { - "nfs_client_package": { - "rhel": "nfs-utils", "fedora": "nfs-utils", - "opensuse": "nfs-client", "opensuse-leap": "nfs-client", - "debian": "nfs-common", "ubuntu": "nfs-common", - "arch": "nfs-utils" - }, - "vdo_package": { "rhel": "vdo", "centos": "vdo" }, - "stratis_package": { "fedora": "stratisd", - "centos": "stratisd", - "arch": "stratisd", - "platform:el9": "stratisd" - }, - "nbde_root_help": { "fedora": true, - "centos": true, - "rhel": true - } - }, - "content-security-policy": "img-src 'self' data:" -} + } +} \ No newline at end of file diff --git a/cockpit/menu_override/systemd.override.json b/cockpit/menu_override/systemd.override.json index 1ef0c870..c64a86c5 100644 --- a/cockpit/menu_override/systemd.override.json +++ b/cockpit/menu_override/systemd.override.json @@ -1,22 +1,5 @@ { - "name": "system", - "requires": { - "cockpit": "265" - }, - "menu": { - "terminal": { - "label": "Terminal", - "keywords": [ - { - "matches": [ - "console", - "command", - "bash", - "shell" - ] - } - ] - }, + "tools": { "index": { "label": "Overview", "order": -2, @@ -74,9 +57,7 @@ "goto": "/metrics" } ] - } - }, - "tools": { + }, "logs": { "label": "Logs", "order": 20, @@ -106,10 +87,24 @@ ] } }, - "libexecdir": "${libexecdir}", + "menu": { + "terminal": { + "label": "Terminal", + "keywords": [ + { + "matches": [ + "console", + "command", + "bash", + "shell" + ] + } + ] + } + }, "preload": [ "index", "services" ], "content-security-policy": "img-src 'self' data:" -} +} \ No newline at end of file diff --git a/cockpit/menu_override/users.override.json b/cockpit/menu_override/users.override.json index 403b139b..7de3f6b9 100644 --- a/cockpit/menu_override/users.override.json +++ b/cockpit/menu_override/users.override.json @@ -1,4 +1,5 @@ { + "menu": null, "tools": { "index": { "label": "Accounts", @@ -11,9 +12,20 @@ ], "keywords": [ { - "matches": ["user", "password", "useradd", "passwd", "username", "login", "access", "roles", "ssh", "keys"] + "matches": [ + "user", + "password", + "useradd", + "passwd", + "username", + "login", + "access", + "roles", + "ssh", + "keys" + ] } ] } } -} +} \ No newline at end of file diff --git a/install/install.sh b/install/install.sh index b16f7fb0..a3a0f6f1 100644 --- a/install/install.sh +++ b/install/install.sh @@ -469,53 +469,10 @@ sudo docker restart websoft9-nginxproxymanager EditMenu(){ echo "Start to Edit Cockpit Menu ..." -if command -v jq > /dev/null; then - if [ -e /usr/share/cockpit/systemd ]; then - jq '. | .tools as $menu | .menu as $tools | .tools=$tools | .menu=$menu | del(.tools.services) | del(.menu.preload.services) | .menu.index = .tools.index | del(.tools.index) | .menu.index.order = -2' /usr/share/cockpit/systemd/manifest.json > /usr/share/cockpit/systemd/manifest.json.tmp - rm -rf /usr/share/cockpit/systemd/manifest.json - mv /usr/share/cockpit/systemd/manifest.json.tmp /usr/share/cockpit/systemd/manifest.json - cd /usr/share/cockpit/systemd && rm -rf services.js.gz services.html.gz services.css.gz services.js services.html services.css - fi - if [ -e /usr/share/cockpit/networkmanager ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/networkmanager/manifest.json - fi - if [ -e /usr/share/cockpit/storaged ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/storaged/manifest.json - fi - if [ -e /usr/share/cockpit/users ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/users/manifest.json - fi - jq '. | del(.locales."ca-es") | del(.locales."nb-no") | del(.locales."sk-sk") | del(.locales."tr-tr")| del(.locales."cs-cz") | del(.locales."de-de") | del(.locales."es-es") | del(.locales."fi-fi") | del(.locales."fr-fr") | del(.locales."it-it") | del(.locales."ja-jp") | del(.locales."pl-pl") | del(.locales."pt-br") | del(.locales."ru-ru") | del(.locales."sv-se") | del(.locales."uk-ua") | del(.locales."zh-tw") | del(.locales."he-il") | del(.locales."nl-nl") | del(.locales."ko-kr") | del(.locales."ka-ge")' /usr/share/cockpit/shell/manifest.json > /usr/share/cockpit/shell/manifest.json.tmp - rm -rf /usr/share/cockpit/shell/manifest.json - mv /usr/share/cockpit/shell/manifest.json.tmp /usr/share/cockpit/shell/manifest.json -else - echo "system have no jq, use cockpit menu ..." - if [ "$os_type" == 'CentOS' ] || [ "$os_type" == 'CentOS Stream' ] || [ "$os_type" == 'Fedora' ] || [ "$os_type" == 'OracleLinux' ] || [ "$os_type" == 'Redhat' ];then - sudo yum install epel-release -y 1>/dev/null 2>&1 - sudo yum install jq -y 1>/dev/null 2>&1 - if [ -e /usr/share/cockpit/systemd ]; then - jq '. | .tools as $menu | .menu as $tools | .tools=$tools | .menu=$menu | del(.tools.services) | del(.menu.preload.services) | .menu.index = .tools.index | del(.tools.index) | .menu.index.order = -2' /usr/share/cockpit/systemd/manifest.json > /usr/share/cockpit/systemd/manifest.json.tmp - rm -rf /usr/share/cockpit/systemd/manifest.json - mv /usr/share/cockpit/systemd/manifest.json.tmp /usr/share/cockpit/systemd/manifest.json - cd /usr/share/cockpit/systemd && rm -rf services.js.gz services.html.gz services.css.gz - fi - if [ -e /usr/share/cockpit/networkmanager ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/networkmanager/manifest.json - fi - if [ -e /usr/share/cockpit/storaged ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/storaged/manifest.json - fi - if [ -e /usr/share/cockpit/users ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/users/manifest.json - fi - - jq '. | del(.locales."ca-es") | del(.locales."nb-no") | del(.locales."sk-sk") | del(.locales."tr-tr")| del(.locales."cs-cz") | del(.locales."de-de") | del(.locales."es-es") | del(.locales."fi-fi") | del(.locales."fr-fr") | del(.locales."it-it") | del(.locales."ja-jp") | del(.locales."pl-pl") | del(.locales."pt-br") | del(.locales."ru-ru") | del(.locales."sv-se") | del(.locales."uk-ua") | del(.locales."zh-tw") | del(.locales."he-il") | del(.locales."nl-nl") | del(.locales."ko-kr") | del(.locales."ka-ge")' /usr/share/cockpit/shell/manifest.json > /usr/share/cockpit/shell/manifest.json.tmp - rm -rf /usr/share/cockpit/shell/manifest.json - mv /usr/share/cockpit/shell/manifest.json.tmp /usr/share/cockpit/shell/manifest.json - fi - -fi +# 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. -------------------------------------------------------" } diff --git a/install/update.sh b/install/update.sh index 7962989f..11ddd60a 100644 --- a/install/update.sh +++ b/install/update.sh @@ -212,90 +212,38 @@ fi EditMenu(){ echo "Start to Edit Cockpit Menu ..." -if command -v jq > /dev/null; then - if [ -e /usr/share/cockpit/systemd ]; then - rm -f /usr/share/cockpit/systemd/manifest.json.tmp - jq '. | .tools as $menu | .menu as $tools | .tools=$tools | .menu=$menu | del(.tools.services) | del(.menu.preload.services) | .menu.index = .tools.index | del(.tools.index) | .menu.index.order = -2' /usr/share/cockpit/systemd/manifest.json > /usr/share/cockpit/systemd/manifest.json.tmp - rm -rf /usr/share/cockpit/systemd/manifest.json - mv /usr/share/cockpit/systemd/manifest.json.tmp /usr/share/cockpit/systemd/manifest.json - cd /usr/share/cockpit/systemd && rm -rf services.js.gz services.html.gz services.css.gz services.js services.html services.css - - fi - if [ -e /usr/share/cockpit/networkmanager ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/networkmanager/manifest.json - fi - if [ -e /usr/share/cockpit/storaged ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/storaged/manifest.json - fi - if [ -e /usr/share/cockpit/users ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/users/manifest.json - fi - rm -f /usr/share/cockpit/shell/manifest.json.tmp - jq '. | del(.locales."ca-es") | del(.locales."nb-no") | del(.locales."sk-sk") | del(.locales."tr-tr")| del(.locales."cs-cz") | del(.locales."de-de") | del(.locales."es-es") | del(.locales."fi-fi") | del(.locales."fr-fr") | del(.locales."it-it") | del(.locales."ja-jp") | del(.locales."pl-pl") | del(.locales."pt-br") | del(.locales."ru-ru") | del(.locales."sv-se") | del(.locales."uk-ua") | del(.locales."zh-tw") | del(.locales."he-il") | del(.locales."nl-nl") | del(.locales."ko-kr") | del(.locales."ka-ge")' /usr/share/cockpit/shell/manifest.json > /usr/share/cockpit/shell/manifest.json.tmp - rm -rf /usr/share/cockpit/shell/manifest.json - mv /usr/share/cockpit/shell/manifest.json.tmp /usr/share/cockpit/shell/manifest.json - -else - echo "system have no jq, use cockpit menu ..." - if [ "$os_type" == 'CentOS' ] || [ "$os_type" == 'CentOS Stream' ] || [ "$os_type" == 'Fedora' ] || [ "$os_type" == 'OracleLinux' ] || [ "$os_type" == 'Redhat' ];then - sudo yum install epel-release -y 1>/dev/null 2>&1 - sudo yum install jq -y 1>/dev/null 2>&1 - if [ -e /usr/share/cockpit/systemd ]; then - rm -f /usr/share/cockpit/systemd/manifest.json.tmp - jq '. | .tools as $menu | .menu as $tools | .tools=$tools | .menu=$menu | del(.tools.services) | del(.menu.preload.services) | .menu.index = .tools.index | del(.tools.index) | .menu.index.order = -2' /usr/share/cockpit/systemd/manifest.json > /usr/share/cockpit/systemd/manifest.json.tmp - rm -rf /usr/share/cockpit/systemd/manifest.json - mv /usr/share/cockpit/systemd/manifest.json.tmp /usr/share/cockpit/systemd/manifest.json - cd /usr/share/cockpit/systemd && rm -rf services.js.gz services.html.gz services.css.gz - fi - if [ -e /usr/share/cockpit/networkmanager ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/networkmanager/manifest.json - fi - if [ -e /usr/share/cockpit/storaged ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/storaged/manifest.json - fi - if [ -e /usr/share/cockpit/users ]; then - sudo sed -i 's/menu/tools/g' /usr/share/cockpit/users/manifest.json - fi - rm -f /usr/share/cockpit/shell/manifest.json.tmp - jq '. | del(.locales."ca-es") | del(.locales."nb-no") | del(.locales."sk-sk") | del(.locales."tr-tr")| del(.locales."cs-cz") | del(.locales."de-de") | del(.locales."es-es") | del(.locales."fi-fi") | del(.locales."fr-fr") | del(.locales."it-it") | del(.locales."ja-jp") | del(.locales."pl-pl") | del(.locales."pt-br") | del(.locales."ru-ru") | del(.locales."sv-se") | del(.locales."uk-ua") | del(.locales."zh-tw") | del(.locales."he-il") | del(.locales."nl-nl") | del(.locales."ko-kr") | del(.locales."ka-ge")' /usr/share/cockpit/shell/manifest.json > /usr/share/cockpit/shell/manifest.json.tmp - rm -rf /usr/share/cockpit/shell/manifest.json - mv /usr/share/cockpit/shell/manifest.json.tmp /usr/share/cockpit/shell/manifest.json - fi - -fi +# 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. -------------------------------------------------------" } UpdateCockpit(){ echo "Parpare to update Cockpit to latest ..." -pkcon refresh -pkcon search cockpit | grep -i cockpit -if [[ $(pkcon search cockpit | grep -i cockpit | wc -l) -gt 1 ]]; then - echo "存在Cockpit更新可用" -else - echo "Cockpit is latest, not need to update" +if command -v apt > /dev/null;then + current_version=$(dpkg-query --showformat='${Version}' --show cockpit) + available_version=$(apt-cache policy cockpit | grep Candidate | awk '{print $2}') +elif command -v yum > /dev/null;then + current_version=$(rpm -q --queryformat '%{VERSION}' cockpit) + available_version=$(yum list available cockpit --quiet | grep cockpit | awk '{print $2}') +fi +if [[ $(echo -e "$current_version\n$available_version" | awk -F. '{ for(i=1; i<=NF; i++) { if($i != v2[i]) { if($i < v2[i]) exit 0; else exit 1; } } exit 0; }') == 0 ]]; then + echo "There is newer version on cockpit." + pkcon refresh + pkcon get-updates + pkcon update -y 'cockpit' 'cockpit-bridge' 'cockpit-packagekit' 'cockpit-storaged' 'cockpit-system' 'cockpit-ws' + EditMenu + sudo sed -i 's/ListenStream=9090/ListenStream=9000/' /lib/systemd/system/cockpit.socket + sudo systemctl daemon-reload + sudo systemctl restart cockpit.socket + echo "cockpit update finished." +else + echo "cockpit is latest, not need to upadate." fi - -pkcon refresh -pkcon get-updates -pkcon update -y -echo "cockpit update finished." -# update navigator(not update on official) -# if command -v apt > /dev/null;then -# sudo apt -y install --only-upgrade cockpit-navigator -# elif command -v dnf > /dev/null;then -# sudo dnf update -y cockpit-navigator -# elif command -v yum > /dev/null;then -# sudo yum update -y cockpit-navigator -# fi -# echo "Set cockpit port to 9000 ..." -# sudo sed -i 's/ListenStream=9090/ListenStream=9000/' /lib/systemd/system/cockpit.socket -# # uninstall plugins -# rm -rf /usr/share/cockpit/apps /usr/share/cockpit/selinux /usr/share/cockpit/kdump /usr/share/cockpit/sosreport /usr/share/cockpit/packagekit -# EditMenu }