This commit is contained in:
Darren 2023-09-22 19:30:31 +08:00 committed by GitHub
parent 923a91e213
commit 58abf5f3b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 94 additions and 16 deletions

View File

@ -5,7 +5,11 @@ Cockpit is used for backend service gatway, we have not modify Cockpit core, jus
## Install ## Install
``` ```
# default install
wget https://websoft9.github.io/websoft9/install/install_cockpit.sh && bash install_cockpit.sh wget https://websoft9.github.io/websoft9/install/install_cockpit.sh && bash install_cockpit.sh
# define Cockpit port and install
wget https://websoft9.github.io/websoft9/install/install_cockpit.sh && bash install_cockpit.sh --port 9099
``` ```
## Development ## Development
@ -13,7 +17,8 @@ wget https://websoft9.github.io/websoft9/install/install_cockpit.sh && bash inst
Developer should improve these codes: Developer should improve these codes:
- Install and Upgrade Cockpit: */install/install_cockpit.sh* - Install and Upgrade Cockpit: */install/install_cockpit.sh*
- Override the default menus: */cockpit/menu_override*
- Cockipt configuration file: */cockpit/cockpit.conf*
> shell.override.json is used for Top menu of Cockpit - Override the default menus: */cockpit/menu_override*
> shell.override.json is used for Top menu of Cockpit
- Cockipt configuration file: */cockpit/cockpit.conf*

View File

@ -2,3 +2,4 @@
[WebService] [WebService]
AllowUnencrypted = true AllowUnencrypted = true
LoginTitle= Websoft9 - Linux AppStore

View File

@ -7,15 +7,47 @@ export PATH
## Cockpit build at redhat family: https://copr.fedorainfracloud.org/coprs/g/cockpit/cockpit-preview/monitor/ ## Cockpit build at redhat family: https://copr.fedorainfracloud.org/coprs/g/cockpit/cockpit-preview/monitor/
## PackageKit: https://www.freedesktop.org/software/PackageKit/ ## PackageKit: https://www.freedesktop.org/software/PackageKit/
## pkcon can read repositories at you system directly, it don't provide exra repository
## [apt show cockpit] or [apt install cockpit] show all additional packages ## [apt show cockpit] or [apt install cockpit] show all additional packages
## Ubuntu have backports at file /etc/apt/sources.list
# Command-line options
# ==========================================================
#
# --port <9000>
# Use the --port option to set Websoft9 cosole port. default is 9000, for example:
#
# $ sudo sh install_cockpit.sh --port 9001
############################################################
# Below vars export from install.sh
# $cockpit_port
# $install_path
############################################################
# 设置参数的默认值
port="9000"
# 获取参数值
while [[ $# -gt 0 ]]; do
case $1 in
--port)
port="$2"
shift 2
;;
*)
shift
;;
esac
done
# Below vars from install.sh
# cockpit_port
# install_path
# $cockpit_port is define at install.sh
if [ -z "$cockpit_port" ]; then if [ -z "$cockpit_port" ]; then
cockpit_port="9000" cockpit_port=$port
fi fi
echo_prefix_cockpit=$'\n[Cockpit] - ' echo_prefix_cockpit=$'\n[Cockpit] - '
@ -25,18 +57,31 @@ menu_overrides_github_page_url="https://websoft9.github.io/websoft9/cockpit/menu
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)
Install_PackageKit(){ Install_PackageKit(){
echo "$echo_prefix_cockpit Try to install pkcon" echo "$echo_prefix_cockpit Install PackageKit(pkcon) and Cockpit repository"
if command -v pkcon &> /dev/null; then if command -v pkcon &> /dev/null; then
echo "pkcon is at you system" echo "pkcon is at you system"
elif command -v yum &> /dev/null; then elif command -v yum &> /dev/null; then
if [ "$(cat /etc/redhat-release)" = "Redhat7" ]; then
sudo subscription-manager repos --enable rhel-7-server-extras-rpms
fi
sudo yum install PackageKit sudo yum install PackageKit
elif command -v dnf &> /dev/null; then elif command -v dnf &> /dev/null; then
sudo dnf install PackageKit sudo dnf install PackageKit
elif command -v apt &> /dev/null; then elif command -v apt &> /dev/null; then
if [ -f /etc/os-release ]; then
. /etc/os-release
if [ "$NAME" == "Debian" ]; then
echo "deb http://deb.debian.org/debian ${VERSION_CODENAME}-backports main" > /etc/apt/sources.list.d/backports.list
fi
fi
sudo apt update sudo apt update
sudo apt install packagekit sudo apt install packagekit
else else
echo "PackageKit not found, Cockpit can not install" echo "PackageKit not found, Cockpit can not install"
exit 1 exit 1
@ -47,6 +92,7 @@ Restart_Cockpit(){
echo "$echo_prefix_cockpit Restart Cockpit" echo "$echo_prefix_cockpit Restart Cockpit"
sudo systemctl daemon-reload sudo systemctl daemon-reload
sudo systemctl restart cockpit sudo systemctl restart cockpit
sudo systemctl restart cockpit.socket
} }
Set_Firewall(){ Set_Firewall(){
@ -74,12 +120,24 @@ Set_Cockpit(){
if [ -f "$install_path/cockpit/cockpit.conf" ]; then if [ -f "$install_path/cockpit/cockpit.conf" ]; then
cp -f "$install_path/cockpit/cockpit.conf" /etc/cockpit/cockpit.conf cp -f "$install_path/cockpit/cockpit.conf" /etc/cockpit/cockpit.conf
else else
echo "Download config from URL" echo "Download config from URL $cockpit_config_github_page_url"
curl -sSL $cockpit_config_github_page_url | sudo tee /etc/cockpit/cockpit.conf > /dev/null curl -sSL $cockpit_config_github_page_url | sudo tee /etc/cockpit/cockpit.conf > /dev/null
fi fi
echo "Change cockpit default port to $cockpit_port ..." echo "Change cockpit default port to $cockpit_port ..."
sudo sed -i "s/ListenStream=9090/ListenStream=$cockpit_port/" /lib/systemd/system/cockpit.socket sudo sed -i "s/ListenStream=9090/ListenStream=$cockpit_port/" /lib/systemd/system/cockpit.socket
# fwupd-refresh.service may push error for Cockpit menu, so disable it
if sudo systemctl is-active --quiet fwupd-refresh.service; then
echo "fwupd-refresh.service is already running. Stopping and disabling it..."
sudo systemctl stop fwupd-refresh.service
sudo systemctl disable fwupd-refresh.service
echo "fwupd-refresh.service stopped and disabled."
else
echo "fwupd-refresh.service is not running."
fi
} }
Download_Menu_Override(){ Download_Menu_Override(){
@ -118,7 +176,7 @@ Edit_Menu(){
Upgrade_Cockpit(){ Upgrade_Cockpit(){
echo "$echo_prefix_cockpit Prepare to upgrade Cockpit" echo "$echo_prefix_cockpit Prepare to upgrade Cockpit"
output=$(sudo pkcon update $cockpit_packages -y 2>&1) output=$(sudo pkcon update $cockpit_packages -y --allow-untrusted 2>&1)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Cockpit upgrade failed or not need upgrade..." echo "Cockpit upgrade failed or not need upgrade..."
else else
@ -137,7 +195,7 @@ Install_Cockpit(){
else else
echo "$echo_prefix_cockpit Prepare to install Cockpit" echo "$echo_prefix_cockpit Prepare to install Cockpit"
export DEBIAN_FRONTEND=noninteractive export DEBIAN_FRONTEND=noninteractive
sudo pkcon install $cockpit_packages -y sudo pkcon install $cockpit_packages -y --allow-untrusted
Restart_Cockpit Restart_Cockpit
fi fi
@ -147,11 +205,24 @@ Install_Cockpit(){
Restart_Cockpit Restart_Cockpit
} }
Test_Cockpit(){
echo "$echo_prefix_cockpit Test Cockpit console accessibility"
test_cmd="curl localhost:$cockpit_port"
if $test_cmd >/dev/null 2>&1; then
echo "Cockpit running OK..."
else
echo "Cockpit is not running..."
exit 1
fi
}
#### -------------- main() start here ------------------- #### #### -------------- main() start here ------------------- ####
Install_PackageKit Install_PackageKit
Install_Cockpit Install_Cockpit
Test_Cockpit
# release package memory # release package memory
sudo systemctl restart packagekit.service sudo systemctl restart packagekit.service

View File

@ -25,10 +25,11 @@ export PATH
# $ sudo sh install-docker.sh # $ sudo sh install-docker.sh
############################################################ ############################################################
# This script is # Below vars export from install.sh
# $force_install is define at install.sh # $force_install
############################################################ ############################################################
docker_packages="docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin" docker_packages="docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin"
docker_exist="command -v docker &> /dev/null && systemctl is-active --quiet docker" docker_exist="command -v docker &> /dev/null && systemctl is-active --quiet docker"