#!/bin/bash ################################################################################ # Shellscript : Support info # Autor : Andreas Vogel, NEXT Enterprise gmbh, 2022 ################################################################################ # set -x ################################### variables ################################## #get logged in user loggedInUser=$(scutil <<< "show State:/Users/ConsoleUser" | awk '/Name :/ && ! /loginwindow/{print $3}') if [[ -z ${loggedInUser} || ${loggedInUser} == "root" ]]; then echo "$(/bin/date +%Y-%m-%d\ %H:%M:%S) Info: No user logged in." exit 0 fi uid=$(id -u "${loggedInUser}") #icons for use with applescript display dialog icon="/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AllMyFiles.icns" serial=$(system_profiler SPHardwareDataType | grep 'Serial Number (system)' | awk '{print $NF}') lastreboot=$(date -jf "%s" "$(sysctl kern.boottime | awk -F'[= |,]' '{print $6}')" +"%d.%m.%Y %T") macos=$(sw_vers -productVersion) interface="$(route get default | grep interface | awk '{print $2}')" result=$(ifconfig $interface | grep -v "inet6" | grep "inet" | awk '{print $2}') ip=$result ################################### functions ################################## #Function to use applescript "display dialog" to display message to user and check which button (2 buttons) was clicked askforbutton2() { message=${1} title="Support Info" button1="close" #button2="close" launchctl asuser "${uid}" /usr/bin/osascript <<-EndOfScript button returned of Β¬ (display dialog "${message}" Β¬ buttons {"${button1}"} Β¬ default button "${button1}" with icon POSIX file "${icon}" with title "${title}") EndOfScript } ################################### execution ################################## while [[ ${exit} != "close" ]]; do if [[ $(sw_vers -buildVersion) > "19" ]]; then exit=$(askforbutton2 "π—‘π—²π˜π˜„π—Όπ—Ώπ—Έ\ \n====================================\ \nIP\t\t\t\t\t${ip}\ \n\ \nπ——π—²π˜ƒπ—Άπ—°π—²\ \n====================================\ \nHostname:\t\t\t$(hostname)\ \nSerial :\t\t\t\t${serial}\ \nCurrent user:\t\t\t${loggedInUser}\ \nmacOS:\t\t\t\t${macos}\ \nLast reboot:\t\t\t${lastreboot}") fi done ################################### end ######################################## exit 0