Push old repo
This commit is contained in:
219
macOS_magic.sh
Executable file
219
macOS_magic.sh
Executable file
@@ -0,0 +1,219 @@
|
||||
#!/usr/bin/env bash
|
||||
# sm @ DeZIM-Institut
|
||||
|
||||
# Name of new User
|
||||
read -p "Enter surname of new user: " -r NEW_USER
|
||||
|
||||
# Variable for setting a non-root install folder (to run the script, need to export this to .zshrc afterwards)
|
||||
# HOMEBREW_CASK_OPTS="--appdir=~/Applications"
|
||||
|
||||
# Set Homebrew paths...
|
||||
BREW_PATH="/opt/homebrew/bin:/opt/homebrew/sbin"
|
||||
|
||||
# Add packages if needed...
|
||||
PACKAGES=(
|
||||
coreutils
|
||||
gnu-sed
|
||||
gnu-tar
|
||||
gnu-indent
|
||||
gnu-which
|
||||
findutils
|
||||
gnutls
|
||||
git
|
||||
bat
|
||||
tmux
|
||||
readline
|
||||
zsh
|
||||
zsh-completions
|
||||
openssh
|
||||
python
|
||||
ruby
|
||||
samba
|
||||
ssh-copy-id
|
||||
speedtest-cli
|
||||
fish
|
||||
)
|
||||
|
||||
CASKS=(
|
||||
microsoft-office-businesspro # office programs
|
||||
slack # app for internal communication
|
||||
adobe-acrobat-reader # pdf reader and compressor
|
||||
firefox # web browser
|
||||
google-chrome # web browser
|
||||
keka # unarchiver/archiver
|
||||
1password # password manager
|
||||
zoom # app for meetings
|
||||
deepl # machine learning translator
|
||||
)
|
||||
|
||||
# Add applications if needed...
|
||||
OPTIONAL_CASKS=(
|
||||
microsoft-remote-desktop # RDP client
|
||||
iterm2 # terminal emulator
|
||||
docker # GUI for Docker
|
||||
rstudio # RStudio
|
||||
r # R Programming Languages
|
||||
zotero # Zotero
|
||||
utm # VMs
|
||||
veracrypt # encrypted containers
|
||||
)
|
||||
|
||||
# Installing Rosetta 2...
|
||||
echo "Checking for arm64 architecture..."
|
||||
if [[ "$(uname -m)" == "arm64" ]]; then
|
||||
echo "arm64 architecture detected. Installing Rosetta."
|
||||
softwareupdate --install-rosetta --agree-to-license
|
||||
fi
|
||||
|
||||
# Install Sophos
|
||||
chmod a+x "/Volumes/macOS_Magic/macOS_Magic/SophosInstall/Sophos Installer.app/Contents/MacOS/Sophos Installer"
|
||||
chmod a+x "/Volumes/macOS_Magic/macOS_Magic/SophosInstall/Sophos Installer.app/Contents/MacOS/tools/com.sophos.bootstrap.helper"
|
||||
sudo "/Volumes/macOS_Magic/macOS_Magic/SophosInstall/Sophos Installer.app/Contents/MacOS/Sophos Installer" --quiet
|
||||
# Sophos Connect
|
||||
sudo installer -package "/Volumes/macOS_Magic/macOS_Magic/VPN/Sophos_Connect.pkg" -target "/Volumes/Macintosh HD"
|
||||
|
||||
# Check for errors after executing commands
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Error installing Sophos. Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for Homebrew to be present, install if it's missing
|
||||
if ! command -v brew &>/dev/null; then
|
||||
echo "Installing Homebrew..."
|
||||
if /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"; then
|
||||
echo "Homebrew installation successful."
|
||||
else
|
||||
echo "Homebrew installation failed."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add Homebrew paths to .zshrc and .zprofile
|
||||
#sudo echo "export PATH=\"$BREW_PATH:\$PATH\"" >>"/Users/$NEW_USER/.zshrc"
|
||||
#sudo echo "export PATH=\"$BREW_PATH:\$PATH\"" >>"/Users/$NEW_USER/.zprofile"
|
||||
|
||||
# Source .zshrc to apply changes immediately
|
||||
# source "$HOME/.zshrc"
|
||||
|
||||
# Fixing permissions for specific subdirectories in /opt/homebrew (Apple Silicon)
|
||||
echo "Fixing permissions..."
|
||||
sudo chown -R $NEW_USER:admin /opt/homebrew/
|
||||
sudo chmod -R g+rwx /opt/homebrew/
|
||||
|
||||
# Security measure, install Casks which don't need root into ~/Applications, not /Applications
|
||||
echo "Adding a security measure to install apps which don't need to be on root and instead install them in their local path."
|
||||
sudo echo "export HOMEBREW_CASK_OPTS="--appdir=~/Applications"" >>"/Users/$NEW_USER/.zshrc"
|
||||
|
||||
echo "Activate Homebrew..."
|
||||
(echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/admin/.zprofile
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
|
||||
echo "Updating homebrew recipes..."
|
||||
brew update
|
||||
brew upgrade
|
||||
brew tap homebrew/cask
|
||||
brew tap homebrew/cask-fonts
|
||||
brew doctor
|
||||
|
||||
echo "Installing packages..."
|
||||
brew reinstall "${PACKAGES[@]}"
|
||||
|
||||
#echo "Enforcing macOS to use GNU tools..."
|
||||
sudo echo "export PATH="/opt/homebrew/opt/findutils/libexec/gnubin:$PATH"" >>"/Users/$NEW_USER/.zshrc"
|
||||
|
||||
echo "Installing apps..."
|
||||
brew reinstall --cask "${CASKS[@]}"
|
||||
|
||||
read -p "Install additional apps? [y/N] " -r
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
for cask in "${OPTIONAL_CASKS[@]}"; do
|
||||
read -p "Install $cask ? [y/N] " -r
|
||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||
if ! brew reinstall --cask $cask; then
|
||||
echo "Error installing $cask. Skipping..."
|
||||
sleep 1
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Cleaning up..."
|
||||
brew cleanup
|
||||
brew doctor
|
||||
|
||||
echo "Installing additional software... "
|
||||
# Clevertouch
|
||||
sudo cp -R "/Volumes/macOS_Magic/macOS_Magic/Clevertouch/Clevershare.app" "/Applications/"
|
||||
# DFN Phone
|
||||
sudo cp -R "/Volumes/macOS_Magic/macOS_Magic/DFN_Phone/"DFN VoIP-Centrex.app"" "/Applications/"
|
||||
# Installing the RICO Printer Drivers...
|
||||
sudo installer -package "/Volumes/macOS_Magic/macOS_Magic/Druckertreiber/Ricoh_IM_C3000_C3500_C4500_LIO_Driver.pkg" -target "/Volumes/Macintosh HD"
|
||||
|
||||
echo "Applying system settings..."
|
||||
|
||||
# Set hostname
|
||||
read -p "Enter hostname: " -r newhostname
|
||||
sudo scutil --set ComputerName "$newhostname"
|
||||
sudo scutil --set HostName "$newhostname"
|
||||
sudo scutil --set LocalHostName "$newhostname"
|
||||
sudo defaults write /Library/Preferences/SystemConfiguration/com.apple.smb.server NetBIOSName -string "$newhostname"
|
||||
|
||||
# Clear existing persistent apps in the Dock
|
||||
defaults write com.apple.dock persistent-apps -array
|
||||
|
||||
# Define an array of applications to add to the Dock
|
||||
dock_apps=(
|
||||
"/System/Library/CoreServices/Finder.app"
|
||||
"/System/Applications/Launchpad.app"
|
||||
"/Applications/Safari.app"
|
||||
"Applications/Firefox.app"
|
||||
"/Applications/Google Chrome.app"
|
||||
"/Applications/Microsoft Outlook.app"
|
||||
"/Applications/Slack.app"
|
||||
"/Applications/Notes.app"
|
||||
"/Applications/Microsoft Word.app"
|
||||
"/Applications/Microsoft PowerPoint.app"
|
||||
"/Applications/Microsoft Excel.app"
|
||||
"/Applications/1Password.app"
|
||||
"/Applications/Zoom.app"
|
||||
"/Applications/TeamViewer.app"
|
||||
"/Applications/Visual Studio Code.app"
|
||||
"/Applications/iTerm.app"
|
||||
"/System/Applications/System Settings.app"
|
||||
)
|
||||
|
||||
echo "Setting the new macOS Dock layout..."
|
||||
|
||||
# Loop through the applications and add them to the Dock
|
||||
for dockItem in "${dock_apps[@]}"; do
|
||||
defaults write com.apple.dock persistent-apps -array-add "<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString</key><string>$dockItem</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></dict>"
|
||||
done
|
||||
|
||||
# Disable Sound Effects on Boot
|
||||
sudo nvram SystemAudioVolume=" "
|
||||
|
||||
# Enable full disk encryption
|
||||
sudo fdesetup enable
|
||||
|
||||
# Reset Launchpad
|
||||
sudo defaults write com.apple.dock ResetLaunchPad -bool true
|
||||
|
||||
# automatic display sleep to 15 min
|
||||
sudo pmset displaysleep 15
|
||||
|
||||
# Show All File Extensions
|
||||
sudo defaults write -g AppleShowAllExtensions -bool true
|
||||
|
||||
# Quit Printer App After Print Jobs Complete
|
||||
sudo defaults write com.apple.print.PrintingPrefs "Quit When Finished" -bool true
|
||||
|
||||
# Restart the Dock to apply changes
|
||||
killall Dock
|
||||
|
||||
read -p "Reboot to apply changes? [Y/n] " -r
|
||||
if [[ $REPLY =~ ^[Yy]$ || $REPLY == "" ]]; then
|
||||
sudo reboot
|
||||
fi
|
||||
|
||||
echo "Bye!"
|
||||
Reference in New Issue
Block a user