Merge remote-tracking branch 'upstream/dev' into dev
This commit is contained in:
commit
f0e15ceb81
8 changed files with 280 additions and 58 deletions
|
|
@ -2,20 +2,51 @@
|
|||
#
|
||||
## Wizard Kit: Wrapper for logout, reboot, & poweroff
|
||||
|
||||
# Unmount filesystems
|
||||
find /media -maxdepth 1 -mindepth 1 -type d \
|
||||
-exec udevil umount "{}" \;
|
||||
set -o errexit
|
||||
set -o errtrace
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# Flush write cache
|
||||
sudo sync
|
||||
# Functions
|
||||
function linux_power_cmd() {
|
||||
case "${1:-x}" in
|
||||
poweroff)
|
||||
sudo systemctl poweroff;;
|
||||
reboot)
|
||||
sudo systemctl reboot;;
|
||||
*)
|
||||
openbox --exit;;
|
||||
esac
|
||||
}
|
||||
|
||||
function macos_power_cmd() {
|
||||
case "${1:-x}" in
|
||||
poweroff)
|
||||
shutdown -h now;;
|
||||
reboot)
|
||||
shutdown -r now;;
|
||||
*)
|
||||
exit;;
|
||||
esac
|
||||
}
|
||||
|
||||
# "Main"
|
||||
if [[ -e "/.wk-live-macos" ]]; then
|
||||
# Flush write cache
|
||||
sync
|
||||
|
||||
# Perform requested action
|
||||
macos_power_cmd "${1:-x}"
|
||||
else
|
||||
# Unmount filesystems
|
||||
find /media -maxdepth 1 -mindepth 1 -type d \
|
||||
-exec udevil umount "{}" \;
|
||||
|
||||
# Flush write cache
|
||||
sudo sync
|
||||
|
||||
# Perform requested action
|
||||
linux_power_cmd "${1:-x}"
|
||||
fi
|
||||
|
||||
# Perform requested action
|
||||
case "${1:-x}" in
|
||||
poweroff)
|
||||
sudo systemctl poweroff;;
|
||||
reboot)
|
||||
sudo systemctl reboot;;
|
||||
*)
|
||||
openbox --exit;;
|
||||
esac
|
||||
exit 0
|
||||
|
|
|
|||
56
setup/macos/Catalina/Utilities.plist
Normal file
56
setup/macos/Catalina/Utilities.plist
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Buttons</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>BundlePath</key>
|
||||
<string>/System/Applications/Utilities/Terminal.app</string>
|
||||
<key>DescriptionKey</key>
|
||||
<string>Hardware Diagnostics</string>
|
||||
<key>Path</key>
|
||||
<string>/System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal</string>
|
||||
<key>TitleKey</key>
|
||||
<string>WizardKit: Hardware Diagnostics</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>BundlePath</key>
|
||||
<string>/System/Applications/Utilities/Disk Utility.app</string>
|
||||
<key>DescriptionKey</key>
|
||||
<string>Repair or erase a volume.</string>
|
||||
<key>Path</key>
|
||||
<string>/System/Applications/Utilities/Disk Utility.app/Contents/MacOS/Disk Utility</string>
|
||||
<key>TitleKey</key>
|
||||
<string>Disk Utility</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Menu</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>BundlePath</key>
|
||||
<string>/System/Applications/Utilities/Startup Security Utility.app</string>
|
||||
<key>Path</key>
|
||||
<string>/System/Applications/Utilities/Startup Security Utility.app/Contents/MacOS/Startup Security Utility</string>
|
||||
<key>TitleKey</key>
|
||||
<string>Startup Security Utility</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>BundlePath</key>
|
||||
<string>/System/Library/CoreServices/Applications/Network Utility.app</string>
|
||||
<key>Path</key>
|
||||
<string>/System/Library/CoreServices/Applications/Network Utility.app/Contents/MacOS/Network Utility</string>
|
||||
<key>TitleKey</key>
|
||||
<string>Network Utility</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>BundlePath</key>
|
||||
<string>/System/Applications/Utilities/Terminal.app</string>
|
||||
<key>Path</key>
|
||||
<string>/System/Applications/Utilities/Terminal.app/Contents/MacOS/Terminal</string>
|
||||
<key>TitleKey</key>
|
||||
<string>Terminal</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
BIN
setup/macos/com.apple.Terminal.plist
Normal file
BIN
setup/macos/com.apple.Terminal.plist
Normal file
Binary file not shown.
95
setup/macos/install-deps
Executable file
95
setup/macos/install-deps
Executable file
|
|
@ -0,0 +1,95 @@
|
|||
#!/bin/bash
|
||||
#
|
||||
|
||||
set -o errexit
|
||||
set -o errtrace
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
# Prep
|
||||
OS_VERSION="$(defaults read /Volumes/BaseSystem/System/Library/CoreServices/SystemVersion ProductVersion)"
|
||||
cd "$(mktemp -d)"
|
||||
|
||||
# Inconsolata
|
||||
echo "Installing Inconsolata..."
|
||||
curl -Lo inconsolata.zip https://fonts.google.com/download?family=Inconsolata
|
||||
unzip -d /Library/Fonts -j inconsolata.zip static/Inconsolata-Bold.ttf static/Inconsolata-Regular.ttf
|
||||
|
||||
# XQuartz
|
||||
echo "Installing XQuartz..."
|
||||
curl -Lo XQuartz.dmg https://github.com/XQuartz/XQuartz/releases/download/XQuartz-2.8.0/XQuartz-2.8.0.dmg
|
||||
XQUARTZ_DEV="$(hdiutil attach -mountpoint /Volumes/XQuartz XQuartz.dmg -nobrowse | grep -Eo '(/dev/disk[0-9]+)\b')"
|
||||
sudo installer -pkg /Volumes/XQuartz/Xquartz.pkg -target /
|
||||
hdiutil detach "${XQUARTZ_DEV}"
|
||||
|
||||
# Gnuplot
|
||||
echo "Installing Gnuplot..."
|
||||
curl -Lo gnuplot.pkg https://ariadne.ms.northwestern.edu/Download/Gnuplot/gnuplot-5.4.1.pkg
|
||||
sudo installer -pkg gnuplot.pkg -target /
|
||||
|
||||
# mprime
|
||||
echo "Installing mprime..."
|
||||
curl -Lo prime95.tar.gz http://www.mersenne.org/ftp_root/gimps/p95v298b7.MacOSX.noGUI.tar.gz
|
||||
tar -x -C /usr/local/bin -f prime95.tar.gz mprime
|
||||
|
||||
# smc
|
||||
echo "Installing smc..."
|
||||
curl -Lo smcfancontrol.zip https://www.eidac.de/smcfancontrol/smcfancontrol_2_6.zip
|
||||
unzip -d /usr/local/bin -j smcfancontrol.zip smcFanControl.app/Contents/Resources/smc
|
||||
|
||||
# Homebrew
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
if [[ "${OS_VERSION:0:5}" == "10.11" ]]; then
|
||||
# TODO: Maybe?
|
||||
true
|
||||
elif [[ "${OS_VERSION:0:5}" == "10.13" ]]; then
|
||||
# TODO: Add colordiff
|
||||
brew install --build-from-source \
|
||||
automake \
|
||||
lua \
|
||||
openssl@1.1 \
|
||||
gdbm \
|
||||
mpdecimal \
|
||||
utf8proc \
|
||||
berkeley-db \
|
||||
readline \
|
||||
perl \
|
||||
sqlite \
|
||||
tcl-tk \
|
||||
ruby
|
||||
brew install --build-from-source \
|
||||
bash \
|
||||
e2fsprogs \
|
||||
htop \
|
||||
pipes-sh \
|
||||
python \
|
||||
smartmontools \
|
||||
util-linux \
|
||||
vim \
|
||||
watch
|
||||
brew install \
|
||||
cmatrix \
|
||||
ddrescue \
|
||||
speedtest-cli \
|
||||
tmux
|
||||
elif [[ "${OS_VERSION:0:5}" == "10.15" ]]; then
|
||||
brew install \
|
||||
cmatrix \
|
||||
colordiff \
|
||||
ddrescue \
|
||||
dropbear \
|
||||
speedtest-cli \
|
||||
tmux \
|
||||
bash \
|
||||
e2fsprogs \
|
||||
htop \
|
||||
pipes-sh \
|
||||
python \
|
||||
smartmontools \
|
||||
util-linux \
|
||||
vim \
|
||||
watch
|
||||
fi
|
||||
|
||||
# Python3 Packages
|
||||
pip3 docopt mysql-connector NumPy psutil pylint pytz requests
|
||||
|
|
@ -2,33 +2,61 @@
|
|||
#
|
||||
## Init macOS env
|
||||
|
||||
# Set Locale
|
||||
LC_ALL=en_US.UTF-8; export LC_ALL
|
||||
LANG=en_US.UTF-8; export LANG
|
||||
|
||||
# Set PATH
|
||||
echo "Updating PATH..."
|
||||
for p in /usr{/local/opt/{e2fsprogs,ruby,util-linux},/local,}/{bin,sbin}; do
|
||||
# Update PATH
|
||||
for p in /usr/local/{,opt/{e2fsprogs,ruby,util-linux}/}{bin,sbin}; do
|
||||
PATH="${p}:${PATH}"
|
||||
done
|
||||
export PATH
|
||||
|
||||
# Create and mount RAMDisk
|
||||
if ! [ -d /Volumes/RAM_Disk ]; then
|
||||
if ! [[ -d /Volumes/RAM_Disk ]]; then
|
||||
echo "Creating RAM Disk..."
|
||||
diskutil erasevolume HFS+ RAM_Disk $(hdiutil attach -nomount ram://524288)
|
||||
RAM_DEV="$(hdiutil attach -nomount ram://524288)"
|
||||
diskutil quiet erasevolume HFS+ RAM_Disk ${RAM_DEV}
|
||||
diskutil unmount ${RAM_DEV}
|
||||
mkdir /Volumes/RAM_Disk
|
||||
mount -t hfs -o owners ${RAM_DEV} /Volumes/RAM_Disk
|
||||
fi
|
||||
cd /Volumes/RAM_Disk
|
||||
|
||||
# Connect to WiFi?
|
||||
if ! [[ -e /Volumes/RAM_Disk/.wifi ]]; then
|
||||
WIFI_NET="$(fgrep ':::' /.known_networks | head -1)"
|
||||
if ! ifconfig | grep -Eq '(((10|172)\.\d+|192.168)\.\d+\.\d+)' 2>/dev/null; then
|
||||
echo "Connecting to WiFi..."
|
||||
NET_DEV="$(/usr/sbin/networksetup \
|
||||
-listallhardwareports \
|
||||
| tr -d '\n' \
|
||||
| grep -Eo 'Wi-Fi.*?Device.*?(en\d+)' \
|
||||
| grep -Eo 'en(\d+)')"
|
||||
networksetup -setairportnetwork "${NET_DEV}" "${WIFI_NET%%:::*}" "${WIFI_NET##*:::}"
|
||||
touch /Volumes/RAM_Disk/.wifi
|
||||
sleep 1s
|
||||
fi
|
||||
fi
|
||||
|
||||
# Dropbear (SSH)
|
||||
if ! [[ -d /Volumes/RAM_Disk/.ssh ]]; then
|
||||
echo "Starting SSH server..."
|
||||
mkdir /Volumes/RAM_Disk/.ssh
|
||||
cp /.authorized_keys /Volumes/RAM_Disk/.ssh/authorized_keys
|
||||
chown -R 0:0 /Volumes/RAM_Disk/.ssh
|
||||
chmod 700 /Volumes/RAM_Disk/.ssh
|
||||
chmod 600 /Volumes/RAM_Disk/.ssh/authorized_keys
|
||||
dropbear -s
|
||||
fi
|
||||
|
||||
# Stay awake
|
||||
echo "Getting caffeinated..."
|
||||
caffeinate -id &
|
||||
|
||||
# Set time
|
||||
echo "Updating clock..."
|
||||
if ! sntp -Ss us.pool.ntp.org 2>/dev/null; then
|
||||
# Assuming we're running under an older version of macOS
|
||||
sntp -s us.pool.ntp.org 2>/dev/null
|
||||
if ! [[ -e /Volumes/RAM_Disk/.time_set ]]; then
|
||||
echo "Updating clock..."
|
||||
if ! sntp -Ss us.pool.ntp.org >/dev/null 2>&1; then
|
||||
# Assuming we're running under an older version of macOS
|
||||
sntp -s us.pool.ntp.org >/dev/null 2>&1
|
||||
fi
|
||||
touch /Volumes/RAM_Disk/.time_set
|
||||
fi
|
||||
|
||||
# Run cmd
|
||||
|
|
|
|||
|
|
@ -10,18 +10,21 @@ set -o pipefail
|
|||
# Prep
|
||||
echo "Initializing..."
|
||||
BASE_IMAGE="$1"
|
||||
IMAGE_DEV="$(hdiutil attach "${BASE_IMAGE}" | grep -Eo '(/dev/disk[0-9]+)\b')"
|
||||
OS_VERSION="$(ls /Volumes/*Base\ System | grep -E 'OS X|macOS' | sed -E 's/Install (OS X|macOS) (.*)\.app/\2/')"
|
||||
OUT_NAME="${HOME}/Desktop/WK ${OS_VERSION} ($(date +"%Y-%m-%d"))"
|
||||
IMAGE_DEV="$(hdiutil attach -mountpoint /Volumes/BaseSystem "${BASE_IMAGE}" -nobrowse | grep -Eo '(/dev/disk[0-9]+)\b')"
|
||||
OS_NAME="$(ls /Volumes/BaseSystem | grep -E 'OS X|macOS' | sed -E 's/Install (OS X|macOS) (.*)\.app/\2/')"
|
||||
OS_VERSION="$(defaults read /Volumes/BaseSystem/System/Library/CoreServices/SystemVersion ProductVersion)"
|
||||
OUT_NAME="${HOME}/Desktop/WK ${OS_NAME} ($(date +"%Y-%m-%d"))"
|
||||
WK_PATH="/Volumes/1201_UFD"
|
||||
|
||||
# Convert to a 4 GB R/W image
|
||||
echo "Creating read-write copy of the ${OS_VERSION} Base System image..."
|
||||
echo "Creating read-write copy of the ${OS_NAME} Base System image..."
|
||||
hdiutil create -srcdevice "${IMAGE_DEV}s1" -format UDSB "${OUT_NAME}.sparsebundle"
|
||||
hdiutil detach "${IMAGE_DEV}"
|
||||
hdiutil resize -size 4g "${OUT_NAME}.sparsebundle"
|
||||
hdiutil attach "${OUT_NAME}.sparsebundle"
|
||||
diskutil rename "OS X Base System" "1201_UFD"
|
||||
WK_IMAGE_DEV="$(hdiutil attach "${OUT_NAME}.sparsebundle" -nobrowse | grep -Eo '(/dev/disk[0-9]+)\b')"
|
||||
if ! diskutil rename "OS X Base System" "1201_UFD"; then
|
||||
diskutil rename "macOS Base System" "1201_UFD"
|
||||
fi
|
||||
|
||||
# Remove Install app
|
||||
echo "Removing Install app..."
|
||||
|
|
@ -29,10 +32,12 @@ rm -R "${WK_PATH}"/Install*.app
|
|||
|
||||
# Update Utilities menu
|
||||
echo "Updating Utilities menu..."
|
||||
if [[ "${OS_VERSION}" == "El Capitan" ]]; then
|
||||
if [[ "${OS_VERSION:0:5}" == "10.11" ]]; then
|
||||
cp -a "El Capitan/Utilities.plist" "${WK_PATH}/System/Installation/CDIS/OS X Utilities.app/Contents/Resources/Utilities.plist"
|
||||
else
|
||||
cp -a Utilities.plist "${WK_PATH}/System/Installation/CDIS/macOS Utilities.app/Contents/Resources/Utilities.plist"
|
||||
elif [[ "${OS_VERSION:0:5}" == "10.13" ]]; then
|
||||
cp -a "High Sierra/Utilities.plist" "${WK_PATH}/System/Installation/CDIS/macOS Utilities.app/Contents/Resources/Utilities.plist"
|
||||
elif [[ "${OS_VERSION:0:5}" == "10.15" ]]; then
|
||||
cp -a "Catalina/Utilities.plist" "${WK_PATH}/System/Installation/CDIS/macOS Utilities.app/Contents/Resources/Utilities.plist"
|
||||
fi
|
||||
|
||||
# 1201 CA
|
||||
|
|
@ -44,61 +49,68 @@ echo "Installing Hombrew..."
|
|||
mkdir -p "${WK_PATH}/usr/local/bin"
|
||||
ln -s python3 "${WK_PATH}/usr/local/bin/python"
|
||||
rsync -aS /opt/ "${WK_PATH}/opt"/
|
||||
rsync -aS --exclude='.git*' /usr/local/{Cellar,Frameworks,Homebrew,bin,etc,include,lib,libexec,opt,sbin,share,var} "${WK_PATH}/usr/local"/
|
||||
rsync -aS --exclude='.git*' /usr/local/{Cellar,Frameworks,Homebrew,bin,etc,include,lib,opt,sbin,share,var} "${WK_PATH}/usr/local"/
|
||||
if [[ "${OS_VERSION:3:2}" -lt "15" ]]; then
|
||||
rsync -aS --exclude='*.git' /usr/local/libexec "${WK_PATH}/usr/local"/
|
||||
fi
|
||||
|
||||
# Fonts
|
||||
echo "Installing Fonts..."
|
||||
cp -a /Library/Fonts/Inconsolata*ttf "${WK_PATH}/System/Library/Fonts"/
|
||||
|
||||
# iTerm2
|
||||
echo "Installing iTerm2..."
|
||||
if [[ "${OS_VERSION}" == "El Capitan" ]]; then
|
||||
rsync -aS /Applications/iTerm.app "${WK_PATH}/Applications"/
|
||||
rsync -aS "El Capitan/com.googlecode.iterm2.plist" "${WK_PATH}/var/root/Library/Preferences"/
|
||||
else
|
||||
rsync -aS /Applications/iTerm-2.app "${WK_PATH}/Applications"/
|
||||
rsync -aS com.googlecode.iterm2.plist "${WK_PATH}/var/root/Library/Preferences"/
|
||||
rsync -aS /usr/lib/lib{apr,expat,ffi}* /Volumes/1201_UFD/usr/lib/
|
||||
rsync -aS /System/Library/Frameworks/{MetalKit,Quartz*}.framework "${WK_PATH}/System/Library/Frameworks"/
|
||||
fi
|
||||
cp -a ../linux/include/airootfs/etc/skel/.tmux.conf "${WK_PATH}/etc/tmux.conf"
|
||||
rsync -aS /System/Library/Colors/System.clr "${WK_PATH}/System/Library/Colors"/
|
||||
rsync -aS /System/Library/Frameworks/{Scripting,ScriptingBridge,LocalAuthentication}.framework "${WK_PATH}/System/Library/Frameworks"/
|
||||
rsync -aS /usr/bin/locale "${WK_PATH}/usr/bin"/
|
||||
rsync -aLS /usr/share/locale/en_US.UTF-8 "${WK_PATH}/usr/share/locale"/
|
||||
|
||||
# pipes-sh
|
||||
echo "Installing pipes.sh..."
|
||||
cp -a /usr/bin/tput "${WK_PATH}/usr/bin"/
|
||||
|
||||
# Dropbear (SSH)
|
||||
echo "Installing Dropbear..."
|
||||
mkdir -p "${WK_PATH}/etc/dropbear"
|
||||
for t in rsa dss ecdsa ed21559; do
|
||||
dropbearkey -t "${t}" -f "${WK_PATH}/etc/dropbear_${t}_host_key"
|
||||
done
|
||||
ln -s /Volumes/RAM_Disk/.ssh "${WK_PATH}/var/root"/
|
||||
cp -a ../linux/authorized_keys "${WK_PATH}/.authorized_keys"
|
||||
|
||||
# Terminal
|
||||
echo "Installing Terminal Preferences..."
|
||||
rsync -aS com.apple.Terminal.plist "${WK_PATH}/var/root/Library/Preferences"/
|
||||
|
||||
# Timezones
|
||||
if [[ ! -d "/var/db/timezone" ]]; then
|
||||
if [[ ! -d "${WK_PATH}/var/db/timezone" ]]; then
|
||||
echo "Installing timezones..."
|
||||
rsync -aS /var/db/timezone "${WK_PATH}/var/db"/
|
||||
fi
|
||||
ln -sf /var/db/timezone/zoneinfo/US/Pacific "${WK_PATH}/etc/localtime"
|
||||
|
||||
# zsh
|
||||
echo "Installing zsh..."
|
||||
cp -a /bin/zsh "${WK_PATH}/bin"/
|
||||
cp -a zshenv "${WK_PATH}/etc"/
|
||||
rsync -aS /usr/lib/zsh "${WK_PATH}/usr/lib"/
|
||||
rsync -aS /usr/share/zsh "${WK_PATH}/usr/share"/
|
||||
rsync -aS /usr/local/share/zsh "${WK_PATH}/usr/local/share"/
|
||||
sed -Ei '' 's!^(root.*)/bin/sh!\1/bin/zsh!' "${WK_PATH}/etc/passwd"
|
||||
|
||||
# Misc
|
||||
cp -a ../linux/known_networks "${WK_PATH}/.known_networks"
|
||||
cp -a /bin/rsync "${WK_PATH}/bin"/
|
||||
cp -a aliases "${WK_PATH}/.aliases"
|
||||
cp -a bashrc "${WK_PATH}/etc/profile"
|
||||
cp -a vimrc "${WK_PATH}/.vimrc"
|
||||
cp -a zshrc "${WK_PATH}/etc/zshenv"
|
||||
|
||||
# WizardKit
|
||||
echo "Installing WizardKit env..."
|
||||
touch "${WK_PATH}/.wk-live-macos"
|
||||
ln -s /Volumes/RAM_Disk/Logs "${WK_PATH}/var/root/Logs"
|
||||
cp -a ../linux/profile_base/airootfs/etc/skel/.tmux.conf "${WK_PATH}/etc/tmux.conf"
|
||||
cp -a ../../images/macOS.png "${WK_PATH}/usr/local/wallpaper.png"
|
||||
rsync -aS /usr/bin/{env,killall} "${WK_PATH}/usr/bin"/
|
||||
rsync -aS live-macos-startup ../../scripts/ "${WK_PATH}/usr/local/bin"/
|
||||
|
||||
# Unmount sparsebundle
|
||||
hdiutil detach "${WK_IMAGE_DEV}"
|
||||
|
||||
# Convert to compressed read-only image
|
||||
# TODO
|
||||
#echo "Converting to read-only image..."
|
||||
#hdiutil convert -format UDZO -o "${OUT_NAME}.sparsebundle" "${OUT_NAME}.dmg"
|
||||
# TODO
|
||||
|
|
|
|||
Loading…
Reference in a new issue