Last active
September 10, 2018 05:55
-
-
Save ivan/5c6447fe40a112d23be08af0bd351497 to your computer and use it in GitHub Desktop.
Share a Chrome profile on multiple Linuxes without Chrome Sync
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu -o pipefail | |
# We share a Chrome profile on multiple machines using a network filesystem, | |
# but we can't have more than one Chrome using it at the same time. | |
# | |
# Read SingletonLock to determine which machine Chrome is running on | |
# and Chrome's PID, then quit it on the remote machine if necessary. | |
profile=$HOME/.config/google-chrome | |
hostname=$(hostname) | |
host_pid=$(readlink -- "$profile/SingletonLock" || echo "$hostname-0") | |
host=$(echo "$host_pid" | sed -r -- 's/-[0-9]+$//g') | |
pid=$(echo "$host_pid" | egrep -o -- '[0-9]+$') | |
if [[ "$hostname" != "$host" ]]; then | |
echo "Chrome is running on $host, sshing in to quit it..." | |
timeout 5s ssh "$USER@$host" "kill -INT $pid && wait-for-process-exit $pid" | |
fi | |
exec /usr/bin/google-chrome "--user-data-dir=$profile" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://github.com/ludios/ubuntils/blob/master/bin/wait-for-process-exit