Skip to content

Instantly share code, notes, and snippets.

@davidfraser
Last active July 9, 2023 01:00
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 5 You must be signed in to fork a gist
  • Save davidfraser/96867a8dbfa607ceba9ed363e6c1688b to your computer and use it in GitHub Desktop.
Save davidfraser/96867a8dbfa607ceba9ed363e6c1688b to your computer and use it in GitHub Desktop.
Google Drive Sync Wine Scripting
#!/bin/bash
[ "$1" != "" ] && google_account="$1"
if [ "$google_account" == "--all" ]
then
google_accounts="`<$HOME/.config/gdrive-accounts`"
else
google_accounts="$google_account"
fi
[ "$google_accounts" == "" ] && { echo "syntax $0 [--all|google_account] [--tail]" >&2 ; exit 1 ; }
LOGFILES=()
for google_account in $google_accounts
do
echo -n checking "$google_account"...
WINEPREFIX="$HOME/.local/share/wineprefixes/gdrive-$google_account"
LOGFILE="$WINEPREFIX/drive_c/users/davidf/Local Settings/Application Data/Google/Drive/user_default/sync_log.log"
echo $LOGFILE
LOGFILES+=("$LOGFILE")
done
[ "$2" == "--tail" ] && tail -f "${LOGFILES[@]}"
#!/bin/bash
[ "$1" != "" ] && google_account="$1"
if [ "$google_account" == "--all" ]
then
google_accounts="`<$HOME/.config/gdrive-accounts`"
else
google_accounts="$google_account"
fi
[ "$google_accounts" == "" ] && { echo "syntax $0 [--all|google_account]" >&2 ; exit 1 ; }
for google_account in $google_accounts
do
echo -n checking "$google_account"...
WINEPREFIX=$HOME/.local/share/wineprefixes/gdrive-$google_account
gds_processes="`pgrep -f 'Drive.googledrivesync'`"
found=
for p in $gds_processes
do
P_DIR="`readlink -f /proc/$p/cwd`"
[ "${P_DIR/${WINEPREFIX}/}" = "${P_DIR}" ] && continue
ps --no-headers -f -p "$p"
found=1
done
[ "$found" != 1 ] && echo "not found"
done
#!/bin/bash
[ "$1" != "" ] && google_account="$1"
if [ "$google_account" == "--all" ]
then
google_accounts="`<$HOME/.config/gdrive-accounts`"
else
google_accounts="$google_account"
fi
[ "$google_accounts" == "" ] && { echo "syntax $0 [--all|google_account]" >&2 ; exit 1 ; }
for google_account in $google_accounts
do
echo configuring "$google_account"
(
. $HOME/bin/gdrive-wine-activate
cd "$WINEPREFIX/drive_c/Program Files/Google/Drive/"
{ wine googledrivesync.exe & sleep 5 ; }
)
done
#!/bin/bash
# if we're being run, then refuse - this file is meant to be sourced
[ "$BASH_SOURCE" == "$0" ] && {
echo This file must be used with "source $0" *from bash*. You cannot run it directly >&2
exit 1
}
[ "$google_account" == "" ] && {
echo This file depends on the google_account variable being set to determine which prefix to use. Please try again >&2
return
}
export WINEARCH=win32
export WINEPREFIX=$HOME/.local/share/wineprefixes/gdrive-$google_account
export WINEROOT=/opt/wine-staging
export PATH=$WINEROOT/bin:$PATH
export LD_LIBRARY_PATH=$WINEROOT/lib:$LD_LIBRARY_PATH
export WINEDLLOVERRIDES="ieframe:native,builtin;winhttp,wininet:builtin,native"
readlink -f $WINEPREFIX/drive_c

Google Drive Sync Wine Scripting

This is a set of scripts that help running Google Drive Backup and Sync under Wine, with multiple Google accounts.

Each account is given its own Wine prefix (a separate wine configuration).

To install, run install-gdrive-sync google_account

List the accounts set up in ~/.config/gdrive-accounts

To run the sync program, run gdrive-sync --all

To check if the sync program is running, run gdrive-sync --all

#!/bin/bash
[ "$1" != "" ] && google_account="$1"
if [ "$google_account" == "" ]
then
echo "syntax $0 google_account [download_dir]" >&2
exit 1
fi
[ "$2" != "" ] && download_dir="$2"
[ "$download_dir" == "" ] && download_dir="$HOME/Download/"
script_name="`readlink -f "$0"`"
script_dir="`dirname "$script_name"`"
. "$script_dir/gdrive-wine-activate"
winetricks ie8 vcrun2008
(
cd "$download_dir"
[ -f "$download_dir"/gsync_enterprise.msi ] || wget https://dl.google.com/drive/gsync_enterprise.msi
wine start gsync_enterprise.msi
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment