-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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 <[email protected]>
- Loading branch information
1 parent
85bd37f
commit de9ab05
Showing
6 changed files
with
123 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} | ||
|