feature: initial commit for all new image changes
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
import Foundation
|
||||
import Security
|
||||
|
||||
let certInfo: CFDictionary
|
||||
|
||||
enum SecurityError: Error {
|
||||
case generalError
|
||||
}
|
||||
|
||||
func deleteCertificateFromKeyChain(_ certificateLabel: String) -> Bool {
|
||||
let delQuery: [NSString: Any] = [
|
||||
kSecClass: kSecClassCertificate,
|
||||
kSecAttrLabel: certificateLabel,
|
||||
]
|
||||
let delStatus: OSStatus = SecItemDelete(delQuery as CFDictionary)
|
||||
|
||||
return delStatus == errSecSuccess
|
||||
}
|
||||
|
||||
func saveCertificateToKeyChain(_ certificate: SecCertificate, certificateLabel: String) throws {
|
||||
SecKeychainSetPreferenceDomain(SecPreferencesDomain.system)
|
||||
deleteCertificateFromKeyChain(certificateLabel)
|
||||
|
||||
let setQuery: [NSString: AnyObject] = [
|
||||
kSecClass: kSecClassCertificate,
|
||||
kSecValueRef: certificate,
|
||||
kSecAttrLabel: certificateLabel as AnyObject,
|
||||
kSecAttrAccessible: kSecAttrAccessibleWhenUnlocked,
|
||||
]
|
||||
let addStatus: OSStatus = SecItemAdd(setQuery as CFDictionary, nil)
|
||||
|
||||
guard addStatus == errSecSuccess else {
|
||||
throw SecurityError.generalError
|
||||
}
|
||||
|
||||
var status = SecTrustSettingsSetTrustSettings(certificate, SecTrustSettingsDomain.admin, nil)
|
||||
}
|
||||
|
||||
func getCertificateFromString(stringData: String) throws -> SecCertificate {
|
||||
if let data = NSData(base64Encoded: stringData, options: NSData.Base64DecodingOptions.ignoreUnknownCharacters) {
|
||||
if let certificate = SecCertificateCreateWithData(kCFAllocatorDefault, data) {
|
||||
return certificate
|
||||
}
|
||||
}
|
||||
throw SecurityError.generalError
|
||||
}
|
||||
|
||||
if CommandLine.arguments.count > 1 {
|
||||
let fileURL = URL(fileURLWithPath: CommandLine.arguments[1])
|
||||
do {
|
||||
let certData = try Data(contentsOf: fileURL)
|
||||
let certificate = SecCertificateCreateWithData(nil, certData as CFData)
|
||||
if certificate != nil {
|
||||
print("Saving certificate")
|
||||
try? saveCertificateToKeyChain(certificate!, certificateLabel: "Test")
|
||||
} else {
|
||||
print("Certificate can't be read")
|
||||
}
|
||||
} catch {
|
||||
print("Unable to read the file \(CommandLine.arguments[1])")
|
||||
}
|
||||
} else {
|
||||
print("Usage: \(CommandLine.arguments[0]) [cert.file]")
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#! /usr/bin/expect -f
|
||||
|
||||
set timeout -1
|
||||
spawn sudo /usr/sbin/softwareupdate --restart --verbose --install "MACOSUPDATE"
|
||||
expect "Password*"
|
||||
send "[lindex $argv 0]\r"
|
||||
expect eof
|
||||
@@ -0,0 +1 @@
|
||||
[ -f $HOME/.bashrc ] && source $HOME/.bashrc
|
||||
@@ -0,0 +1,33 @@
|
||||
export LC_CTYPE=en_US.UTF-8
|
||||
export LC_ALL=en_US.UTF-8
|
||||
export LANG=en_US.UTF-8
|
||||
|
||||
export ANDROID_HOME=${HOME}/Library/Android/sdk
|
||||
export ANDROID_SDK_ROOT=${HOME}/Library/Android/sdk
|
||||
|
||||
export VM_ASSETS=/usr/local/opt/$USER/scripts
|
||||
|
||||
export NUNIT_BASE_PATH=/Library/Developer/nunit
|
||||
export NUNIT3_PATH=/Library/Developer/nunit/3.6.0
|
||||
|
||||
export AGENT_TOOLSDIRECTORY=$HOME/hostedtoolcache
|
||||
export RUNNER_TOOL_CACHE=$HOME/hostedtoolcache
|
||||
export ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE=$HOME/actionarchivecache
|
||||
|
||||
export PATH=/Library/Frameworks/Mono.framework/Versions/Current/Commands:$PATH
|
||||
export PATH=/Library/Frameworks/Python.framework/Versions/Current/bin:$PATH
|
||||
export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH
|
||||
export PATH=/usr/local/bin:/usr/local/sbin:~/bin:~/.yarn/bin:$PATH
|
||||
export PATH="/usr/local/opt/curl/bin:$PATH"
|
||||
export PATH=$HOME/.cargo/bin:$PATH
|
||||
|
||||
export RCT_NO_LAUNCH_PACKAGER=1
|
||||
export DOTNET_ROOT=$HOME/.dotnet
|
||||
export DOTNET_MULTILEVEL_LOOKUP=0
|
||||
|
||||
export HOMEBREW_NO_AUTO_UPDATE=1
|
||||
export HOMEBREW_NO_INSTALL_CLEANUP=1
|
||||
export HOMEBREW_CASK_OPTS="--no-quarantine"
|
||||
|
||||
export BOOTSTRAP_HASKELL_NONINTERACTIVE=1
|
||||
export BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1
|
||||
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
USERNAME="$1"
|
||||
OLD_PASSWD="$2"
|
||||
NEW_PASSWD="$3"
|
||||
UPDATE_LOGIN_KEYCHAIN="${4:-true}"
|
||||
|
||||
sudo /usr/sbin/sysadminctl -resetPasswordFor $USERNAME -newPassword "$NEW_PASSWD" -adminUser $USERNAME -adminPassword "$OLD_PASSWD"
|
||||
sudo /usr/bin/python3 /Users/$USERNAME/bootstrap/kcpassword.py "$NEW_PASSWD"
|
||||
sudo /usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser "$USERNAME"
|
||||
|
||||
if [[ $UPDATE_LOGIN_KEYCHAIN == "true" ]]; then
|
||||
/usr/bin/security set-keychain-password -o "$OLD_PASSWD" -p "$NEW_PASSWD" /Users/$USERNAME/Library/Keychains/login.keychain
|
||||
fi
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
BOOTSTRAP_PATH="$1"
|
||||
ProvisionerPackageUri="$2"
|
||||
ProvisionerScriptUri="$3"
|
||||
ScriptName="$4"
|
||||
ScriptParam="$5"
|
||||
Username="$6"
|
||||
arch=$(arch)
|
||||
|
||||
if [[ $arch == "arm64" ]]; then
|
||||
export PATH=/usr/bin:/usr/sbin:/usr/local/bin:/bin:/sbin:/opt/homebrew/bin
|
||||
else
|
||||
export PATH=/usr/bin:/usr/sbin:/usr/local/bin:/bin:/sbin
|
||||
fi
|
||||
|
||||
PROVISIONER_ROOT=/usr/local/opt/${Username}
|
||||
sudo mkdir -p ${PROVISIONER_ROOT}
|
||||
sudo chown ${Username} ${PROVISIONER_ROOT}
|
||||
|
||||
tee -a ${PROVISIONER_ROOT}/runprovisioner.sh > /dev/null <<\EOF
|
||||
#!/bin/bash
|
||||
|
||||
. ${HOME}/.bashrc
|
||||
|
||||
/usr/local/opt/$USER/provisioner/provisioner
|
||||
EOF
|
||||
|
||||
chmod +x $PROVISIONER_ROOT/runprovisioner.sh
|
||||
|
||||
aria2c \
|
||||
--enable-color=false \
|
||||
--file-allocation=none \
|
||||
-d ${BOOTSTRAP_PATH} "${ProvisionerPackageUri}" >> ${BOOTSTRAP_PATH}/download.log
|
||||
|
||||
aria2c \
|
||||
--enable-color=false \
|
||||
--file-allocation=none \
|
||||
-d ${BOOTSTRAP_PATH} "${ProvisionerScriptUri}" >> ${BOOTSTRAP_PATH}/download.log
|
||||
|
||||
chmod +x ${BOOTSTRAP_PATH}/${ScriptName}
|
||||
|
||||
# Install Provisioner with provided scripts
|
||||
eval "$BOOTSTRAP_PATH/$ScriptName $BOOTSTRAP_PATH/$ScriptParam $Username" 2>&1 | tee "$BOOTSTRAP_PATH/install.log"
|
||||
# State File
|
||||
touch $BOOTSTRAP_PATH/provisionerDone
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Port of Gavin Brock's Perl kcpassword generator to Python, by Tom Taylor
|
||||
# <[email protected]>.
|
||||
# Perl version: http://www.brock-family.org/gavin/perl/kcpassword.html
|
||||
# This script was taken from https://github.com/timsutton/osx-vm-templates/blob/master/scripts/support/set_kcpassword.py
|
||||
# Distributed by MIT license, license can be found at the bottom of this script
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
def encode_data(passwd):
|
||||
# The magic 11 bytes - these are just repeated
|
||||
# 0x7D 0x89 0x52 0x23 0xD2 0xBC 0xDD 0xEA 0xA3 0xB9 0x1F
|
||||
key = [125,137,82,35,210,188,221,234,163,185,31]
|
||||
key_len = len(key)
|
||||
|
||||
passwd = [ord(x) for x in list(passwd)]
|
||||
# pad passwd length out to an even multiple of key length
|
||||
r = len(passwd) % key_len
|
||||
if len(passwd) == 11:
|
||||
passwd += [0]
|
||||
elif (r > 0):
|
||||
passwd = passwd + [0] * (key_len - r)
|
||||
|
||||
for n in range(0, len(passwd), len(key)):
|
||||
ki = 0
|
||||
for j in range(n, min(n+len(key), len(passwd))):
|
||||
passwd[j] = passwd[j] ^ key[ki]
|
||||
ki += 1
|
||||
|
||||
return bytearray(passwd)
|
||||
|
||||
if __name__ == "__main__":
|
||||
runner_pwd_encoded = encode_data(sys.argv[1])
|
||||
fd = os.open('/etc/kcpassword', os.O_WRONLY | os.O_CREAT, 0o600)
|
||||
file = os.fdopen(fd, 'wb')
|
||||
file.truncate(0)
|
||||
file.write(runner_pwd_encoded)
|
||||
file.close()
|
||||
|
||||
"""
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2013-2017 Timothy Sutton
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
: <<-LICENSE_BLOCK
|
||||
setAutoLogin (20210911) - Copyright (c) 2021 Joel Bruner (https://github.com/brunerd)
|
||||
Licensed under the MIT License
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
LICENSE_BLOCK
|
||||
|
||||
USERNAME="${1}"
|
||||
PW="${2}"
|
||||
|
||||
kcpasswordEncode() {
|
||||
#ascii string
|
||||
local thisString="${1}"
|
||||
local i
|
||||
|
||||
#macOS cipher hex ascii representation array
|
||||
local cipherHex_array=( 7D 89 52 23 D2 BC DD EA A3 B9 1F )
|
||||
|
||||
#converted to hex representation with spaces
|
||||
local thisStringHex_array=( $(echo -n "${thisString}" | xxd -p -u | sed 's/../& /g') )
|
||||
|
||||
#get padding by subtraction if under 11
|
||||
local r=$(( ${#thisStringHex_array[@]} % 11 ))
|
||||
local padding=0
|
||||
if [ ${#thisStringHex_array[@]} -eq 11 ]; then
|
||||
local padding=1
|
||||
elif [ $r -gt 0 ]; then
|
||||
local padding=$(( 11 - $r ))
|
||||
fi
|
||||
|
||||
#cycle through each element of the array + padding
|
||||
for ((i=0; i < $(( ${#thisStringHex_array[@]} + ${padding})); i++)); do
|
||||
#use modulus to loop through the cipher array elements
|
||||
local charHex_cipher=${cipherHex_array[$(( $i % 11 ))]}
|
||||
|
||||
#get the current hex representation element
|
||||
local charHex=${thisStringHex_array[$i]}
|
||||
|
||||
#use $(( shell Aritmethic )) to ^ XOR the two 0x## values (extra padding is 0x00)
|
||||
#take decimal value and printf convert to two char hex value
|
||||
#use xxd to convert hex to actual value and append to the encodedString variable
|
||||
local encodedString+=$(printf "%02X" "$(( 0x${charHex_cipher} ^ 0x${charHex:-00} ))")
|
||||
done
|
||||
|
||||
#return the string without a newline
|
||||
echo -n "${encodedString}"
|
||||
}
|
||||
|
||||
#encode password and write file
|
||||
kcpasswordEncode "${PW}" | xxd -r -p > /etc/kcpassword
|
||||
|
||||
#ensure ownership and permissions (600)
|
||||
chown root:wheel /etc/kcpassword
|
||||
chmod u=rw,go= /etc/kcpassword
|
||||
|
||||
#turn on auto login
|
||||
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser -string "${USERNAME}"
|
||||
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUserScreenLocked -bool false
|
||||
echo "Auto login enabled for '${USERNAME}'"
|
||||
@@ -0,0 +1,53 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
# Select any Xamarin SDK versions as the default ones independently by specifying only those versions that need to be changed.
|
||||
# Examples:
|
||||
# 1. Change all versions: $VM_ASSETS/select-xamarin-sdkv-v2.sh --mono=6.12 --ios=14.8 --android=10.2 --mac=7.8
|
||||
# 2. Change default Mono and iOS only: $VM_ASSETS/select-xamarin-sdkv-v2.sh --mono=6.12 --ios=14.8
|
||||
# 3. Change default Android only: $VM_ASSETS/select-xamarin-sdkv-v2.sh --android=11.1
|
||||
|
||||
get_framework_path() {
|
||||
case $1 in
|
||||
--mono) echo '/Library/Frameworks/Mono.framework/Versions' ;;
|
||||
--ios) echo '/Library/Frameworks/Xamarin.iOS.framework/Versions' ;;
|
||||
--android) echo '/Library/Frameworks/Xamarin.Android.framework/Versions' ;;
|
||||
--mac) echo '/Library/Frameworks/Xamarin.Mac.framework/Versions' ;;
|
||||
*) ;;
|
||||
esac
|
||||
}
|
||||
|
||||
change_framework_version() {
|
||||
local framework=$1
|
||||
local version=$2
|
||||
|
||||
echo "Select $framework $version"
|
||||
|
||||
local countDigit=$(echo "${version}" | grep -o "\." | grep -c "\.")
|
||||
|
||||
if [[ countDigit -gt 1 ]]; then
|
||||
echo "[WARNING] It is not recommended to specify the exact framework version because your build can be broken with the next patch update. Consider using "major.minor" only format."
|
||||
fi
|
||||
|
||||
local framework_path=$(get_framework_path "$framework")
|
||||
|
||||
if [ -d "${framework_path}/${version}" ]; then
|
||||
sudo rm -f ${framework_path}/Current
|
||||
sudo ln -s "${framework_path}/${version}" "${framework_path}/Current"
|
||||
else
|
||||
echo "Invalid framework version ${framework_path}/${version}"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
for arg in "$@"; do
|
||||
key=$(echo $arg | cut -f1 -d=)
|
||||
value=$(echo $arg | cut -f2 -d=)
|
||||
|
||||
case $key in
|
||||
--mono | --ios | --android | --mac) change_framework_version $key $value ;;
|
||||
*)
|
||||
echo "Invalid parameter <${key}>"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash -e -o pipefail
|
||||
if [ -z "$1" ]; then
|
||||
echo "No Xamarin SDK specified."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
XAMARIN_SDK=$1
|
||||
|
||||
echo "Set Xamarin SDK to ${XAMARIN_SDK}"
|
||||
FOLDERS_LIST=(
|
||||
'/Library/Frameworks/Mono.framework/Versions'
|
||||
'/Library/Frameworks/Xamarin.iOS.framework/Versions'
|
||||
'/Library/Frameworks/Xamarin.Android.framework/Versions'
|
||||
'/Library/Frameworks/Xamarin.Mac.framework/Versions'
|
||||
)
|
||||
|
||||
for FOLDER in "${FOLDERS_LIST[@]}"
|
||||
do
|
||||
echo "Set Current folder for ${FOLDER}"
|
||||
sudo rm -f ${FOLDER}/Current
|
||||
sudo ln -s ${FOLDER}/${XAMARIN_SDK} ${FOLDER}/Current
|
||||
done
|
||||
Reference in New Issue
Block a user