Files
Alte_Skripte/de.ing.change_shell.sh
2026-02-16 15:05:15 +01:00

67 lines
1.8 KiB
Bash

#!/bin/bash
##########################################################################
# Shellscript : Change Shell
# Autor : Michelle Tembaak, macenterprise GmbH, 09.01.2020
##########################################################################
user=$(stat -f '%Su')
#Dialogfenster
Button1=$(osascript -e 'display dialog "Möchtest du deine Shell ändern? Bitte beachte, dass dein Terminal geschlossen wird." with icon POSIX file "/Applications/Utilities/Terminal.app/Contents/Resources/Terminal.icns" with title "Change your Shell" buttons {"Ja", "abbrechen"} default button 2 ')
Auswahl=$(echo $Button1 | cut -d : -f 2)
#Prueft ob das Programm ausgefuehrt werden soll.
#Dialogfenster mit Auswahl der gewuenschten Shell
if [[ $Auswahl == 'abbrechen' ]]; then
echo "Abbruch"
else
echo "Ja"
killall Terminal
Button2=$(osascript -e 'return choose from list {"bash", "zsh", "tcsh", "csh", "ksh", "sh"} with Title "Wähle deine Shell" ')
fi
Shell=$(echo $Button2 | cut -d : -f 2)
#Prueft und stellt auf die Wunschshell um
case $Shell in
bash)
chsh -s /bin/bash $user
;;
zsh)
chsh -s /bin/zsh $user
;;
tcsh)
chsh -s /bin/tcsh $user
;;
csh)
chsh -s /bin/csh $user
;;
ksh)
chsh -s /bin/ksh $user
;;
sh)
chsh -s /bin/sh $user
;;
esac
#Prueft ob die Umstellung erfolgreich war
NewShell=$(dscl localhost -read /Local/Default/Users/$user shell | cut -d / -f 3)
if [[ $NewShell == $Shell ]]; then
$(osascript -e 'display dialog "
Deine Shell wurde umgestellt." with icon POSIX file "/Library/Application Support/JAMF/ING/ok-1976099_640.png" with title "Shell wurde umgestellt" ')
else
$(osascript -e 'display dialog "
Deine Shell wurde nicht umgestellt." with icon POSIX file "/Library/Application Support/JAMF/ING/France_road_sign_A14.svg.png" with title "Shell wurde nicht umgestellt" ')
fi
exit 0