From 897fa38fb6dcf176c67326263eae018bd22a14df Mon Sep 17 00:00:00 2001 From: Q-engineering Date: Sat, 16 Aug 2025 13:31:24 +0200 Subject: [PATCH] Update install_rtop.sh --- install_rtop.sh | 46 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 14 deletions(-) diff --git a/install_rtop.sh b/install_rtop.sh index 2e11da2..0d692de 100644 --- a/install_rtop.sh +++ b/install_rtop.sh @@ -6,6 +6,25 @@ if [ "$EUID" -ne 0 ]; then exit 1 fi +# Check if libQt5Widgets.so.5 is installed +if ! ldconfig -p | grep -q libQt5Widgets.so.5; then + echo "libQt5Widgets.so.5 is not found on your system." + read -p "Do you want to install it now? (y/n): " choice + case "$choice" in + y|Y ) + echo "Installing libqt5widgets5..." + apt-get update + apt-get install -y libqt5widgets5 + ;; + * ) + echo "libQt5Widgets.so.5 is required" + echo "Please install it with $ sudo apt-get install libqt5widgets5" + ;; + esac +else + echo "libQt5Widgets.so.5 is already installed." +fi + # Get the current non-root user CURRENT_USER=$(logname) @@ -23,8 +42,8 @@ fi # Copy rtop to /usr/local/bin if not already there if [ ! -f /usr/local/bin/rtop ]; then - sudo cp "$RTOP_PATH" /usr/local/bin/ - sudo chmod +x /usr/local/bin/rtop + cp "$RTOP_PATH" /usr/local/bin/ + chmod +x /usr/local/bin/rtop echo "rtop has been copied to /usr/local/bin." else echo "rtop is already present in /usr/local/bin." @@ -39,21 +58,21 @@ SUDOERS_FILE="/etc/sudoers.d/rtop_nopasswd" # Check if the file already exists if [ -f "$SUDOERS_FILE" ]; then echo "The sudoers file for rtop already exists. Updating it..." - echo "$SUDOERS_ENTRY" | sudo tee "$SUDOERS_FILE" > /dev/null + echo "$SUDOERS_ENTRY" | tee "$SUDOERS_FILE" > /dev/null else - echo "$SUDOERS_ENTRY" | sudo tee "$SUDOERS_FILE" > /dev/null + echo "$SUDOERS_ENTRY" | tee "$SUDOERS_FILE" > /dev/null fi # Set correct permissions for the file -sudo chmod 0440 "$SUDOERS_FILE" +chmod 0440 "$SUDOERS_FILE" # Create the wrapper script WRAPPER_SCRIPT="/usr/local/bin/rtop-wrapper" -echo "#!/bin/bash" | sudo tee "$WRAPPER_SCRIPT" > /dev/null -echo "sudo /usr/local/bin/rtop \"\$@\"" | sudo tee -a "$WRAPPER_SCRIPT" > /dev/null +echo "#!/bin/bash" | tee "$WRAPPER_SCRIPT" > /dev/null +echo "sudo /usr/local/bin/rtop \"\$@\"" | tee -a "$WRAPPER_SCRIPT" > /dev/null # Make the wrapper script executable -sudo chmod +x "$WRAPPER_SCRIPT" +chmod +x "$WRAPPER_SCRIPT" # Add the alias to the user's .bashrc BASHRC_FILE="/home/$CURRENT_USER/.bashrc" @@ -63,7 +82,7 @@ ALIAS_CMD="alias rtop='rtop-wrapper'" if grep -Fxq "$ALIAS_CMD" "$BASHRC_FILE"; then echo "The alias for rtop already exists in $BASHRC_FILE." else - echo "$ALIAS_CMD" | sudo tee -a "$BASHRC_FILE" > /dev/null + echo "$ALIAS_CMD" | tee -a "$BASHRC_FILE" > /dev/null echo "The alias for rtop has been added to $BASHRC_FILE." fi @@ -77,11 +96,11 @@ if [ -f "$ICON_SOURCE" ]; then # Check if the destination directory exists if [ ! -d "$ICON_DEST_DIR" ]; then # Create the destination directory - sudo mkdir -p "$ICON_DEST_DIR" + mkdir -p "$ICON_DEST_DIR" echo "Created directory $ICON_DEST_DIR." fi # Copy the icon to the destination directory - sudo cp "$ICON_SOURCE" "$ICON_DEST" + cp "$ICON_SOURCE" "$ICON_DEST" echo "Icon has been copied to $ICON_DEST." else echo "Warning: Icon not found at $ICON_SOURCE. The .desktop file will be created without an icon." @@ -89,7 +108,7 @@ fi # Create .desktop file for rtop DESKTOP_FILE="/usr/share/applications/rtop.desktop" -sudo tee "$DESKTOP_FILE" > /dev/null << EOF +tee "$DESKTOP_FILE" > /dev/null << EOF [Desktop Entry] Name=Rtop Comment=Remote system monitoring tool @@ -101,9 +120,8 @@ Categories=Utility; EOF # Ensure the .desktop file is executable -sudo chmod +x "$DESKTOP_FILE" +chmod +x "$DESKTOP_FILE" echo "Setup complete. A .desktop file has been created for rtop." echo "Please log out and log back in, or start a new shell session for changes to take effect." echo "You can now find rtop in your applications menu and pin it to the dock if desired." -