mirror of
https://github.com/actions/runner-images.git
synced 2026-01-06 10:09:20 +08:00
[macOS] Migrating python 2 scripts to python 3 (#5115)
This commit is contained in:
committed by
GitHub
parent
009a1bea38
commit
c2797f37cd
@@ -4,17 +4,8 @@ OLD_PASSWD="$2"
|
||||
NEW_PASSWD="$3"
|
||||
UPDATE_LOGIN_KEYCHAIN="${4:-true}"
|
||||
|
||||
export PATH=/usr/bin:/usr/sbin:/usr/local/bin:/bin:/sbin
|
||||
|
||||
macosver="$(sw_vers | grep ProductVersion | awk {'print $2'})"
|
||||
|
||||
if [[ $macosver =~ 10.13.* ]]; then
|
||||
sudo /usr/bin/dscl . -passwd /Users/$USERNAME "$NEW_PASSWD"
|
||||
else
|
||||
sudo /usr/sbin/sysadminctl -resetPasswordFor $USERNAME -newPassword "$NEW_PASSWD" -adminUser $USERNAME -adminPassword "$OLD_PASSWD"
|
||||
fi
|
||||
|
||||
sudo /usr/bin/python /Users/$USERNAME/bootstrap/kcpassword.py "$NEW_PASSWD"
|
||||
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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# Port of Gavin Brock's Perl kcpassword generator to Python, by Tom Taylor
|
||||
# <tom@tomtaylor.co.uk>.
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
echo "Enabling automatic GUI login for the '$USERNAME' user.."
|
||||
|
||||
python $HOME/bootstrap/kcpassword.py "$PASSWORD"
|
||||
python3 $HOME/bootstrap/kcpassword.py "$PASSWORD"
|
||||
|
||||
/usr/bin/defaults write /Library/Preferences/com.apple.loginwindow autoLoginUser "$USERNAME"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
tee -a /usr/local/bin/change_hostname.sh > /dev/null <<\EOF
|
||||
#!/bin/bash -e -o pipefail
|
||||
|
||||
name="Mac-$(python -c 'from time import time; print int(round(time() * 1000))')"
|
||||
name="Mac-$(python3 -c 'from time import time; print(int(round(time() * 1000)))')"
|
||||
scutil --set HostName "${name}.local"
|
||||
scutil --set LocalHostName $name
|
||||
scutil --set ComputerName "${name}.local"
|
||||
|
||||
Reference in New Issue
Block a user