diff --git a/scripts/launch-in-tmux b/scripts/launch-in-tmux index 8deaa52a..de9483a8 100755 --- a/scripts/launch-in-tmux +++ b/scripts/launch-in-tmux @@ -9,19 +9,19 @@ if [[ -e "/.wk-live-macos" ]]; then fi function ask() { - while :; do - read -p "$1 [Y/N] " -r answer - if echo "$answer" | grep -Eiq '^(y|yes|sure)$'; then - return 0 - elif echo "$answer" | grep -Eiq '^(n|no|nope)$'; then - return 1 - fi - done + while :; do + read -p "$1 [Y/N] " -r answer + if echo "$answer" | grep -Eiq '^(y|yes|sure)$'; then + return 0 + elif echo "$answer" | grep -Eiq '^(n|no|nope)$'; then + return 1 + fi + done } function err () { - echo "$0:" "$@" >&2 - return 1 + echo "$0:" "$@" >&2 + return 1 } function launch_in_tmux() { @@ -31,44 +31,44 @@ function launch_in_tmux() { [[ -n "${TMUX_CMD:-}" ]] || return $(err "Required variable missing (TMUX_CMD)") # Check for running session - if tmux "${tmux_args[@]}" list-session | grep -q "$SESSION_NAME"; then - echo "WARNING: tmux session $SESSION_NAME already exists." - echo "" - if ask "Connect to current session?"; then - if [[ -n "${TMUX:-}" ]]; then - # Running inside TMUX, switch to session - tmux "${tmux_args[@]}" switch-client -t "$SESSION_NAME" - if ! jobs %% >/dev/null 2>&1; then - # No running jobs, try exiting abandoned tmux session - exit 0 - fi - else - # Running outside TMUX, attach to session - tmux "${tmux_args[@]}" attach-session -t "$SESSION_NAME" - fi - return 0 - elif ask "Kill current session and start new session?"; then - tmux "${tmux_args[@]}" kill-session -t "$SESSION_NAME" || \ - die "Failed to kill session: $SESSION_NAME" + if tmux "${tmux_args[@]}" list-session 2>&1 | grep -q "$SESSION_NAME"; then + echo "WARNING: tmux session $SESSION_NAME already exists." + echo "" + if ask "Connect to current session?"; then + if [[ -n "${TMUX:-}" ]]; then + # Running inside TMUX, switch to session + tmux "${tmux_args[@]}" switch-client -t "$SESSION_NAME" + if ! jobs %% >/dev/null 2>&1; then + # No running jobs, try exiting abandoned tmux session + exit 0 + fi else - echo "Aborted." - return 1 + # Running outside TMUX, attach to session + tmux "${tmux_args[@]}" attach-session -t "$SESSION_NAME" fi + return 0 + elif ask "Kill current session and start new session?"; then + tmux "${tmux_args[@]}" kill-session -t "$SESSION_NAME" || \ + die "Failed to kill session: $SESSION_NAME" + else + echo "Aborted." + return 1 + fi fi # Start session if [[ -n "${TMUX:-}" ]]; then - # Running inside TMUX, save current session/window names - ORIGINAL_SESSION_NAME="$(tmux "${tmux_args[@]}" display-message -p '#S')" - ORIGINAL_WINDOW_NAME="$(tmux "${tmux_args[@]}" display-message -p '#W')" - tmux "${tmux_args[@]}" rename-session "$SESSION_NAME" - tmux "${tmux_args[@]}" rename-window "$WINDOW_NAME" - "$TMUX_CMD" "$@" - # Restore previous session/window names - tmux "${tmux_args[@]}" rename-session "${ORIGINAL_SESSION_NAME}" - tmux "${tmux_args[@]}" rename-window "${ORIGINAL_WINDOW_NAME}" + # Running inside TMUX, save current session/window names + ORIGINAL_SESSION_NAME="$(tmux "${tmux_args[@]}" display-message -p '#S')" + ORIGINAL_WINDOW_NAME="$(tmux "${tmux_args[@]}" display-message -p '#W')" + tmux "${tmux_args[@]}" rename-session "$SESSION_NAME" + tmux "${tmux_args[@]}" rename-window "$WINDOW_NAME" + "$TMUX_CMD" "$@" + # Restore previous session/window names + tmux "${tmux_args[@]}" rename-session "${ORIGINAL_SESSION_NAME}" + tmux "${tmux_args[@]}" rename-window "${ORIGINAL_WINDOW_NAME}" else - # Running outside TMUX, start/attach to session - tmux "${tmux_args[@]}" new-session -s "$SESSION_NAME" -n "$WINDOW_NAME" "$TMUX_CMD" "$@" + # Running outside TMUX, start/attach to session + tmux "${tmux_args[@]}" new-session -s "$SESSION_NAME" -n "$WINDOW_NAME" "$TMUX_CMD" "$@" fi } diff --git a/setup/macos/install-deps b/setup/macos/install-deps index 7112394f..492d693c 100755 --- a/setup/macos/install-deps +++ b/setup/macos/install-deps @@ -29,7 +29,11 @@ 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 +if [[ "${OS_VERSION:3:2}" -ge "15" ]]; then + curl -Lo prime95.tar.gz http://www.mersenne.org/ftp_root/gimps/p95v298b7.MacOSX.noGUI.tar.gz +else + curl -Lo prime95.tar.gz http://www.mersenne.org/ftp_root/gimps/p95v287.MacOSX.noGUI.tar.gz +fi sudo tar -x -C /usr/local/bin -f prime95.tar.gz mprime # smc diff --git a/setup/macos/live-macos-startup b/setup/macos/live-macos-startup index 2196b681..7b5d3e7b 100755 --- a/setup/macos/live-macos-startup +++ b/setup/macos/live-macos-startup @@ -7,7 +7,7 @@ for p in /usr/local/{,opt/{e2fsprogs,ruby,util-linux}/}{bin,sbin}; do PATH="${p}:${PATH}" done -# Create and mount RAMDisk +# Create and mount RAM_Disk if ! [[ -d /Volumes/RAM_Disk ]]; then echo "Creating RAM Disk..." RAM_DEV="$(hdiutil attach -nomount ram://524288)" @@ -30,7 +30,7 @@ if ! [[ -e /Volumes/RAM_Disk/.wifi ]]; then | grep -Eo 'en(\d+)')" networksetup -setairportnetwork "${NET_DEV}" "${WIFI_NET%%:::*}" "${WIFI_NET##*:::}" touch /Volumes/RAM_Disk/.wifi - sleep 5s + sleep 8s fi fi diff --git a/setup/macos/update-base-image b/setup/macos/update-base-image index 2f4e5712..d51e06aa 100755 --- a/setup/macos/update-base-image +++ b/setup/macos/update-base-image @@ -14,6 +14,7 @@ IMAGE_DEV="$(hdiutil attach -mountpoint /Volumes/BaseSystem "${BASE_IMAGE}" -nob 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"))" +TIMEZONE="$(fgrep LINUX_TIME_ZONE ../../scripts/wk/cfg/main.py | cut -d '=' -f 2 | sed "s/'//g")" WK_PATH="/Volumes/1201_UFD" # Convert to a 4 GB R/W image @@ -77,15 +78,13 @@ rsync -aS com.apple.Terminal.plist "${WK_PATH}/var/root/Library/Preferences"/ # Timezones echo "Installing timezones..." -eval "$(fgrep LINUX_TIME ../../scripts/wk/cfg/main.py)" if [[ "${OS_VERSION:3:2}" == "11" ]]; then rsync -aS /usr/share/zoneinfo/ "${WK_PATH}/usr/share/zoneinfo"/ - ln -sf "/usr/share/zoneinfo/${LINUX_TIME}" "${WK_PATH}/etc/localtime" + ln -sf "/usr/share/zoneinfo/${TIMEZONE}" "${WK_PATH}/etc/localtime" elif [[ "${OS_VERSION:3:2}" -gt "11" ]]; then - if [[ ! -d "${WK_PATH}/var/db/timezone" ]]; then - rsync -aS /var/db/timezone "${WK_PATH}/var/db"/ - fi - ln -sf "/var/db/timezone/zoneinfo/${LINUX_TIME}" "${WK_PATH}/etc/localtime" + sudo mkdir -p "${WK_PATH}/var/db/timezone/zoneinfo" + sudo rsync -aS /var/db/timezone/zoneinfo/ "${WK_PATH}/var/db/timezone/zoneinfo"/ + ln -sf "/var/db/timezone/zoneinfo/${TIMEZONE}" "${WK_PATH}/etc/localtime" fi # zsh