44 lines
1.2 KiB
Bash
44 lines
1.2 KiB
Bash
#!/bin/bash
|
|
|
|
##########################################################################
|
|
# Shellscript : Script erstellt encrypted String [Username]
|
|
# Autor : Jobst Heinermann, macenterprise gmbh
|
|
# Copyright : macenterprise 2019
|
|
# Quelle : https://github.com/jamf/Encrypted-Script-Parameters
|
|
##########################################################################
|
|
|
|
#Funktionen
|
|
GenerateEncryptedString() {
|
|
local STRING="${1}"
|
|
local SALT=$(openssl rand -hex 8)
|
|
local K=$(openssl rand -hex 12)
|
|
local ENCRYPTED=$(echo "${STRING}" | openssl enc -aes256 -a -A -S "${SALT}" -k "${K}")
|
|
echo "folgende Daten als Parameter in Jamf Script übernehmen !"
|
|
echo ""
|
|
echo "Parameter 4: ${ENCRYPTED}"
|
|
echo ""
|
|
echo "Parameter 5: ${SALT}"
|
|
echo ""
|
|
echo "Parameter 6: ${K}"
|
|
|
|
}
|
|
|
|
ask () {
|
|
osascript <<EOF - 2>/dev/null
|
|
tell application "SystemUIServer"
|
|
activate
|
|
text returned of (display dialog "$1" default answer "")
|
|
end tell
|
|
EOF
|
|
}
|
|
|
|
#Variabeln
|
|
FNAME=$(ask 'Bitte den Namen des User eingeben') || exit
|
|
ENAME=$(GenerateEncryptedString "$FNAME")
|
|
FILE=/tmp/User.txt
|
|
APP=$(mdfind -onlyin / 'kMDItemCFBundleIdentifier == "com.apple.TextEdit"')
|
|
|
|
echo "$ENAME" > "$FILE"
|
|
open -a $APP "$FILE"
|
|
sleep 5
|
|
rm "$FILE" |