fix scripts with sudo

This commit is contained in:
2025-02-24 15:57:20 +01:00
parent f2467ad75e
commit f814f5aa29
7 changed files with 30 additions and 40 deletions

View File

@@ -2,20 +2,15 @@
set -e
if [ "$(id -u)" -ne 0 ]; then
echo "Please run this script as root: sudo $0"
exit 1
fi
# Check if Zsh is already installed
if command -v zsh &> /dev/null; then
echo "Zsh is already installed. Skipping installation."
else
echo "Updating package list..."
apt-get update
sudo apt-get update
echo "Installing Zsh..."
apt-get install -y zsh
sudo apt-get install -y zsh
if ! command -v zsh &> /dev/null; then
echo "Error: Zsh installation failed."
@@ -25,6 +20,6 @@ fi
echo "Changing default shell to Zsh for user ${SUDO_USER:-$USER}..."
zsh_path=$(command -v zsh)
chsh -s "$zsh_path" "${SUDO_USER:-$USER}"
sudo chsh -s "$zsh_path" "${SUDO_USER:-$USER}"
echo "Zsh installation and setup complete. Please log out and log back in for changes to take effect."