make bpytop a script (#1582)
This commit is contained in:
Родитель
83acb5dcee
Коммит
f6313c6f26
|
@ -0,0 +1,78 @@
|
|||
#!/bin/bash
|
||||
|
||||
# T&M Hansson IT AB © - 2020, https://www.hanssonit.se/
|
||||
|
||||
# shellcheck disable=2034,2059
|
||||
true
|
||||
SCRIPT_NAME="BPYTOP"
|
||||
SCRIPT_EXPLAINER="BPYTOP is an amazing alternative to ressource-monitor software like top or htop."
|
||||
# shellcheck source=lib.sh
|
||||
source /var/scripts/fetch_lib.sh || source <(curl -sL https://raw.githubusercontent.com/nextcloud/vm/master/lib.sh)
|
||||
|
||||
# Check for errors + debug code and abort if something isn't right
|
||||
# 1 = ON
|
||||
# 0 = OFF
|
||||
DEBUG=0
|
||||
debug_mode
|
||||
|
||||
# Must be root
|
||||
root_check
|
||||
|
||||
msg_box "$SCRIPT_EXPLAINER"
|
||||
|
||||
# Needed for snaps to run
|
||||
install_if_not snapd
|
||||
|
||||
# Check if bpytop is already installed
|
||||
if ! snap list | grep -q bpytop
|
||||
then
|
||||
# Ask for installing
|
||||
install_popup "$SCRIPT_NAME"
|
||||
else
|
||||
# Ask for removal or reinstallation
|
||||
reinstall_remove_menu "$SCRIPT_NAME"
|
||||
# Removal
|
||||
if [ -f /home/"$UNIXUSER"/.bash_aliases ]
|
||||
then
|
||||
sed -i "s|.*bpytop'||g" /home/"$UNIXUSER"/.bash_aliases
|
||||
fi
|
||||
if [ -f /root/.bash_aliases ]
|
||||
then
|
||||
sed -i "s|.*bpytop'||g" /root/.bash_aliases
|
||||
fi
|
||||
snap remove bpytop
|
||||
# Show successful uninstall if applicable
|
||||
removal_popup "$SCRIPT_NAME"
|
||||
fi
|
||||
|
||||
# Install it!
|
||||
if snap install bpytop
|
||||
then
|
||||
snap connect bpytop:mount-observe
|
||||
snap connect bpytop:network-control
|
||||
snap connect bpytop:hardware-observe
|
||||
snap connect bpytop:system-observe
|
||||
snap connect bpytop:process-control
|
||||
snap connect bpytop:physical-memory-observe
|
||||
hash -r
|
||||
msg_box "BPYTOP is now installed! Check out the amazing stats by runnning 'bpytop' from your CLI.
|
||||
You can check out their Gihub repo here: https://github.com/aristocratos/bpytop/blob/master/README.md"
|
||||
# Ask for aliases
|
||||
if [ -f /root/.bash_aliases ]
|
||||
then
|
||||
if yesno_box_yes "You you want to add an alias for bpytop to replace both htop and top?"
|
||||
then
|
||||
echo "alias top='bpytop'" >> /root/.bash_aliases
|
||||
echo "alias htop='bpytop'" >> /root/.bash_aliases
|
||||
if [ -d /home/"$UNIXUSER" ]
|
||||
then
|
||||
touch /home/"$UNIXUSER"/.bash_aliases
|
||||
chown "$UNIXUSER":"$UNIXUSER" /home/"$UNIXUSER"/.bash_aliases
|
||||
echo "alias top='bpytop'" >> /home/"$UNIXUSER"/.bash_aliases
|
||||
echo "alias htop='bpytop'" >> /home/"$UNIXUSER"/.bash_aliases
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
msg_box "It seems like the installation of BPYTOP failed. Please try again."
|
||||
fi
|
|
@ -75,35 +75,8 @@ case "$choice" in
|
|||
run_script APP netdata
|
||||
;;&
|
||||
*"BPYTOP"*)
|
||||
SUBTITLE="BPYTOP"
|
||||
msg_box "BPYTOP is an amazing alternative to ressource-monitor software like htop." "$SUBTITLE"
|
||||
install_if_not snapd
|
||||
if snap list | grep -q bpytop
|
||||
then
|
||||
if yesno_box_yes "It seems like BPYTOP is already installed.\nDo you want to uninstall it?" "$SUBTITLE"
|
||||
then
|
||||
print_text_in_color "$ICyan" "Uninstalling BPYTOP..."
|
||||
check_command snap remove bpytop
|
||||
msg_box "BPYTOP was successfully removed!" "$SUBTITLE"
|
||||
fi
|
||||
elif yesno_box_yes "Do you want to install BPYTOP?" "$SUBTITLE"
|
||||
then
|
||||
print_text_in_color "$ICyan" "Installing BPYTOP..."
|
||||
if snap install bpytop
|
||||
then
|
||||
snap connect bpytop:mount-observe
|
||||
snap connect bpytop:network-control
|
||||
snap connect bpytop:hardware-observe
|
||||
snap connect bpytop:system-observe
|
||||
snap connect bpytop:process-control
|
||||
snap connect bpytop:physical-memory-observe
|
||||
hash -r
|
||||
msg_box "BPYTOP is now installed! Check out the amazing stats by runnning 'bpytop' from your CLI.
|
||||
You can check out their Gihub repo here: https://github.com/aristocratos/bpytop/blob/master/README.md" "$SUBTITLE"
|
||||
else
|
||||
msg_box "It seems like the installation of BPYTOP failed. Please try again." "$SUBTITLE"
|
||||
fi
|
||||
fi
|
||||
print_text_in_color "$ICyan" "Downloading the BPYTOP script..."
|
||||
run_script APP bpytop
|
||||
;;&
|
||||
*"Midnight Commander"*)
|
||||
SUBTITLE="Midnight Commander"
|
||||
|
|
Загрузка…
Ссылка в новой задаче