mirror of
https://github.com/armbian/configng.git
synced 2026-01-06 10:37:41 -08:00
Add missing cockpit module (#342)
* add cockpit module * add json * unit-testing * fix test * modified: tests/MAN001.conf modified: tests/MAN002.conf * Show cockpit port Only problem here is that it shows it also when service is disabled --------- Co-authored-by: Igor Pecovnik <igor@armbian.com>
This commit is contained in:
@@ -1,2 +1,4 @@
|
||||
ENABLED=true
|
||||
PREINSTALL="./bin/armbian-config --api module_cockpit install" in order to satisfy test case
|
||||
CONDITION="[ -f /usr/bin/cockpit-bridge ]"
|
||||
RELEASE="bookworm:jammy:noble" run on specific or leave empty to run on all
|
||||
|
||||
4
tests/MAN002.conf
Normal file
4
tests/MAN002.conf
Normal file
@@ -0,0 +1,4 @@
|
||||
ENABLED=false
|
||||
PREINSTALL="./bin/armbian-config --api module_cockpit purge" in order to satisfy test case
|
||||
CONDITION="[ ! -f /usr/bin/cockpit-bridge ]"
|
||||
RELEASE="bookworm:jammy:noble" run on specific or leave empty to run on all
|
||||
@@ -612,7 +612,7 @@
|
||||
"status": "Stable",
|
||||
"author": "@armbian",
|
||||
"condition": "module_sonarr status"
|
||||
},
|
||||
},
|
||||
{
|
||||
"id": "SON003",
|
||||
"description": "Sonarr purge with data folder",
|
||||
@@ -1264,7 +1264,6 @@
|
||||
"author": "@igorpecovnik",
|
||||
"condition": "module_netdata status"
|
||||
}
|
||||
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -1273,47 +1272,13 @@
|
||||
"sub": [
|
||||
{
|
||||
"id": "MAN001",
|
||||
"description": "Install Cockpit web-based management tool",
|
||||
"about": "This operation will install Cockpit.\ncockpit cockpit-ws cockpit-system cockpit-storaged",
|
||||
"description": "Cockpit web-based management tool",
|
||||
"command": [
|
||||
"see_current_apt update",
|
||||
"pkg_install cockpit cockpit-ws cockpit-system cockpit-storaged "
|
||||
"see_menu module_cockpit"
|
||||
],
|
||||
"status": "Stable",
|
||||
"author": "@schwar3kat",
|
||||
"condition": "! pkg_installed cockpit"
|
||||
},
|
||||
{
|
||||
"id": "MAN002",
|
||||
"description": "Purge Cockpit web-based management tool",
|
||||
"about": "This operation will purge Cockpit.",
|
||||
"command": [
|
||||
"pkg_remove cockpit"
|
||||
],
|
||||
"status": "Stable",
|
||||
"author": "@schwar3kat",
|
||||
"condition": "pkg_installed cockpit"
|
||||
},
|
||||
{
|
||||
"id": "MAN003",
|
||||
"description": "Start Cockpit Service",
|
||||
"command": [
|
||||
"sudo systemctl enable --now cockpit.socket | show_infobox "
|
||||
],
|
||||
"status": "Stable",
|
||||
"author": "@schwar3kat",
|
||||
"condition": "pkg_installed cockpit && ! systemctl is-enabled cockpit.socket > /dev/null 2>&1"
|
||||
},
|
||||
{
|
||||
"id": "MAN004",
|
||||
"description": "Stop Cockpit Service",
|
||||
"command": [
|
||||
"systemctl stop cockpit cockpit.socket",
|
||||
"systemctl disable cockpit.socket | show_infobox "
|
||||
],
|
||||
"status": "Stable",
|
||||
"author": "@schwar3kat",
|
||||
"condition": "pkg_installed cockpit && systemctl is-enabled cockpit.socket > /dev/null 2>&1"
|
||||
"author": "@Tearran",
|
||||
"condition": ""
|
||||
},
|
||||
{
|
||||
"id": "MAN005",
|
||||
@@ -1357,7 +1322,7 @@
|
||||
"id": "NET003",
|
||||
"description": "iperf3 bandwidth measuring tool",
|
||||
"prompt": "This operation will install iperf3.",
|
||||
"command": [
|
||||
"command": [
|
||||
"pkg_install iperf3"
|
||||
],
|
||||
"status": "Stable",
|
||||
@@ -1428,4 +1393,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -41,17 +41,17 @@ function see_menu() {
|
||||
options=()
|
||||
while IFS= read -r line; do
|
||||
if [[ $line =~ ^[[:space:]]*([a-zA-Z0-9_-]+)[[:space:]]*-\s*(.*)$ ]]; then
|
||||
options+=("${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")
|
||||
options+=("${BASH_REMATCH[1]}" " - ${BASH_REMATCH[2]}")
|
||||
fi
|
||||
done <<< "$help_message"
|
||||
|
||||
# Display menu based on DIALOG tool
|
||||
case $DIALOG in
|
||||
"dialog")
|
||||
choice=$(dialog --title "${function_name^} Management" --menu "Choose an option:" 15 60 9 "${options[@]}" 2>&1 >/dev/tty)
|
||||
choice=$(dialog --title "${function_name^}" --menu "Choose an option:" 0 80 9 "${options[@]}" 2>&1 >/dev/tty)
|
||||
;;
|
||||
"whiptail")
|
||||
choice=$(whiptail --title "${function_name^} Management" --menu "Choose an option:" 15 60 9 "${options[@]}" 3>&1 1>&2 2>&3)
|
||||
choice=$(whiptail --title "${function_name^}" --menu "Choose an option:" 0 80 9 "${options[@]}" 3>&1 1>&2 2>&3)
|
||||
;;
|
||||
"read")
|
||||
echo "Available options:"
|
||||
|
||||
@@ -125,6 +125,9 @@ update_sub_submenu_data "Software" "DNS" "DNS003" "http://$LOCALIPADD:${module_o
|
||||
update_sub_submenu_data "Software" "Monitoring" "MON002" "http://$LOCALIPADD:${module_options["module_uptimekuma,port"]}"
|
||||
update_sub_submenu_data "Software" "Monitoring" "MON006" "http://$LOCALIPADD:${module_options["module_netdata,port"]}"
|
||||
|
||||
# Management
|
||||
update_sub_submenu_data "Software" "Management" "MAN001" "http://$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
|
||||
update_sub_submenu_data "Software" "Downloaders" "DEL002" "http://$LOCALIPADD:${module_options["module_deluge,port"]%% *}" # removing second port from url
|
||||
|
||||
104
tools/modules/software/module_cockpit.sh
Normal file
104
tools/modules/software/module_cockpit.sh
Normal file
@@ -0,0 +1,104 @@
|
||||
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,desc"]="Cockpit setup and service setting."
|
||||
["module_cockpit,status"]="Stable"
|
||||
["module_cockpit,doc_link"]="https://cockpit-project.org/guide/latest/"
|
||||
["module_cockpit,group"]="Management"
|
||||
["module_cockpit,port"]="9090"
|
||||
["module_cockpit,arch"]="x86-64 arm64 armhf"
|
||||
)
|
||||
|
||||
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"]} <command>"
|
||||
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."
|
||||
|
||||
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."
|
||||
;;
|
||||
"${commands[2]}")
|
||||
## remove cockpit
|
||||
systemctl disable cockpit cockpit.socket
|
||||
pkg_remove cockpit
|
||||
echo "Cockpit removed successfully."
|
||||
;;
|
||||
"${commands[3]}")
|
||||
## start cockpit
|
||||
|
||||
systemctl start cockpit.socket
|
||||
echo "Cockpit service started."
|
||||
;;
|
||||
"${commands[4]}")
|
||||
## stop cockpit
|
||||
|
||||
systemctl stop cockpit.socket
|
||||
echo "Cockpit service stopped."
|
||||
;;
|
||||
"${commands[5]}")
|
||||
## enable cockpit
|
||||
#systemctl enable cockpit
|
||||
systemctl enable cockpit.socket
|
||||
echo "Cockpit service enabled."
|
||||
;;
|
||||
"${commands[6]}")
|
||||
## disable cockpit
|
||||
#systemctl disable cockpit
|
||||
systemctl disable cockpit.socket
|
||||
echo "Cockpit service disabled."
|
||||
;;
|
||||
"${commands[7]}")
|
||||
## status cockpit
|
||||
#systemctl status cockpit
|
||||
systemctl status cockpit.socket
|
||||
;;
|
||||
"${commands[-1]}")
|
||||
## check cockpit status
|
||||
if [[ $(systemctl is-active cockpit.socket) == "active" ]]; then
|
||||
echo "Cockpit service is active."
|
||||
return 0
|
||||
elif [[ $(systemctl is-enabled cockpit.socket) == "disabled" ]]; then
|
||||
echo "Cockpit service is disabled."
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Invalid command. Try: '${module_options["module_cockpit,example"]}'"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user