diff --git a/tools/include/images/MAN001.png b/tools/include/images/COC001.png similarity index 100% rename from tools/include/images/MAN001.png rename to tools/include/images/COC001.png diff --git a/tools/include/markdown/COC001-header.md b/tools/include/markdown/COC001-header.md new file mode 100644 index 000000000..cd2b967f5 --- /dev/null +++ b/tools/include/markdown/COC001-header.md @@ -0,0 +1,16 @@ +Cockpit is a web-based graphical interface for servers, intended for everyone. + +Here’s a subset of tasks you can perform on each host running Cockpit + +- inspect and change network settings +- configure a firewall +- manage storage (including RAID and LUKS partitions) +- create and manage virtual machines +- download and run containers +- browse and search system logs +- inspect a system’s hardware +- upgrade software +- manage user accounts +- inspect and interact with systemd-based services +- use a terminal on a remote server in your local web browser +- switch between multiple Cockpit servers \ No newline at end of file diff --git a/tools/include/markdown/MAN001-footer.md b/tools/include/markdown/MAN001-footer.md deleted file mode 100644 index 7eb05d6f8..000000000 --- a/tools/include/markdown/MAN001-footer.md +++ /dev/null @@ -1,11 +0,0 @@ -Introducing Cockpit -Cockpit is a web-based graphical interface for servers, intended for everyone, especially those who are: - -- new to Linux -(including Windows admins) -- familiar with Linux -and want an easy, graphical way to administer servers -- expert admins -who mainly use other tools but want an overview on individual systems - -Thanks to Cockpit intentionally using system APIs and commands, a whole team of admins can manage a system in the way they prefer, including the command line and utilities right alongside Cockpit. \ No newline at end of file diff --git a/tools/json/config.software.json b/tools/json/config.software.json index f3f7184cb..bd4ec7079 100644 --- a/tools/json/config.software.json +++ b/tools/json/config.software.json @@ -1304,14 +1304,24 @@ "description": "Remote Management tools", "sub": [ { - "id": "MAN001", - "description": "Cockpit web-based management tool", + "id": "COC001", + "description": "Cockpit OS and VM management tool", "command": [ - "see_menu module_cockpit" + "module_cockpit install" ], "status": "Stable", - "author": "@Tearran", - "condition": "" + "author": "@igorpecovnik", + "condition": "! module_cockpit status" + }, + { + "id": "COC002", + "description": "Remove Cockpit", + "command": [ + "module_cockpit remove" + ], + "status": "Stable", + "author": "@igorpecovnik", + "condition": "module_cockpit status" }, { "id": "MAN005", diff --git a/tools/modules/runtime/config.runtime.sh b/tools/modules/runtime/config.runtime.sh index 122305fa1..f2ea6586f 100644 --- a/tools/modules/runtime/config.runtime.sh +++ b/tools/modules/runtime/config.runtime.sh @@ -130,7 +130,7 @@ update_sub_submenu_data "Software" "Monitoring" "MON006" "http://$LOCALIPADD:${m update_sub_submenu_data "Software" "Monitoring" "GRA002" "http://$LOCALIPADD:${module_options["module_grafana,port"]}" # Management -update_sub_submenu_data "Software" "Management" "MAN001" "http://$LOCALIPADD:${module_options["module_cockpit,port"]}" +update_sub_submenu_data "Software" "Management" "COC002" "https://$LOCALIPADD:${module_options["module_cockpit,port"]}" # Downloaders update_sub_submenu_data "Software" "Downloaders" "DOW002" "http://$LOCALIPADD:${module_options["module_qbittorrent,port"]%% *}" # removing second port from url diff --git a/tools/modules/software/module_cockpit.sh b/tools/modules/software/module_cockpit.sh index f57129ca0..849003309 100644 --- a/tools/modules/software/module_cockpit.sh +++ b/tools/modules/software/module_cockpit.sh @@ -2,7 +2,7 @@ module_options+=( ["module_cockpit,author"]="@tearran" ["module_cockpit,maintainer"]="@igorpecovnik" ["module_cockpit,feature"]="module_cockpit" - ["module_cockpit,example"]="help install remove start stop enable disable status check" + ["module_cockpit,example"]="install remove status help" ["module_cockpit,desc"]="Cockpit setup and service setting." ["module_cockpit,status"]="Stable" ["module_cockpit,doc_link"]="https://cockpit-project.org/guide/latest/" @@ -14,91 +14,74 @@ module_options+=( function module_cockpit() { local title="cockpit" local condition=$(dpkg -s "cockpit" 2>/dev/null | sed -n "s/Status: //p") + # Convert the example string to an array local commands IFS=' ' read -r -a commands <<< "${module_options["module_cockpit,example"]}" case "$1" in + "${commands[0]}") - ## help/menu options for the module - echo -e "\nUsage: ${module_options["module_cockpit,feature"]} " - echo -e "Commands: ${module_options["module_cockpit,example"]}" - echo "Available commands:" - if [[ -z "$condition" ]]; then - echo -e " install\t- Install $title." - else - if [[ "$(systemctl is-active cockpit.socket 2>/dev/null)" == "active" ]]; then - echo -e "\tstop\t- Stop the $title service." - else - echo -e "\tstart\t- Start the $title service." - fi - if [[ $(systemctl is-enabled cockpit.socket) == "enabled" ]]; then - echo -e "\tdisable\t- Disable $title from starting on boot." - elif [[ $(systemctl is-enabled cockpit.socket) == "disabled" ]]; then - echo -e "\tenable\t- Enable $title to start on boot." + ## install cockpit + pkg_update + pkg_install cockpit cockpit-ws cockpit-system cockpit-storaged cockpit-machines dnsmasq virtinst qemu-kvm qemu-utils + + usermod -a -G libvirt libvirtdbus + usermod -a -G libvirt libvirt-qemu + + # add bridged networking if bridges exists on the system + for f in /sys/class/net/*; do + intf=$(basename $f) + if [[ $intf =~ ^br[0-9] ]]; then + cat <<- EOF > /etc/libvirt/kvm-hostbridge-${intf}.xml + + hostbridge-${intf} + + + + EOF + virsh net-define /etc/libvirt/kvm-hostbridge-${intf}.xml + virsh net-start hostbridge-${intf} + virsh net-autostart hostbridge-${intf} + fi + done + if $DIALOG --title " Reboot required " --yes-button "Reboot" --no-button "Cancel" --yesno \ + "A reboot is required to start $title properly. Shall we reboot now?" 7 34; then + reboot fi - echo -e "\tstatus\t- Show the status of the $title service." - echo -e "\tremove\t- Remove $title." - fi - echo + ;; "${commands[1]}") - ## install cockpit - pkg_update - pkg_install cockpit cockpit-ws cockpit-system cockpit-storaged - echo "Cockpit installed successfully." + ## remove cockpit + systemctl stop cockpit.socket 2>/dev/null + systemctl stop cockpit 2>/dev/null + systemctl disable cockpit 2>/dev/null + for bridge in $(grep hostbridge /etc/libvirt/kvm-hostbridge-br* | grep -o -P '(?<=name>).*(?=\" + echo -e "Commands: ${module_options["module_cockpit,example"]}" + echo "Available commands:" + echo -e "\tinstall\t- Install $title." + echo -e "\tremove\t- Remove $title." + echo -e "\tstatus\t- Status $title." + echo ;; *) - echo "Invalid command. Try: '${module_options["module_cockpit,example"]}'" + ${module_options["module_cockpit,feature"]} ${commands[3]} ;; esac } -