From 714737576ca8a99dfe59c6493e1d1a67031db4c4 Mon Sep 17 00:00:00 2001 From: calclover2514 <43104632+calclover2514@users.noreply.github.com> Date: Tue, 29 Oct 2019 19:57:40 -0400 Subject: [PATCH] Add files via upload --- installGoogleDrive.sh | 84 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 installGoogleDrive.sh diff --git a/installGoogleDrive.sh b/installGoogleDrive.sh new file mode 100644 index 0000000..19dfca9 --- /dev/null +++ b/installGoogleDrive.sh @@ -0,0 +1,84 @@ +#!/bin/bash +number="0" +clear +echo Google Drive for Raspbian +echo ------------------------- +echo Options: +echo 1. Install/Re-install Google Drive +echo 2. Uninstall Google Drive +echo 3. Add auto-mount +echo 4. Remove auto-mount +echo 5. Exit Installer +echo +read -p "Input Number: " number +if (( $number == "1" )); then + echo Initializing... + cd /home/pi + echo Cleaning up old assets... + sudo umount /mnt/gdrivefs + sudo rmdir /mnt/gdrivefs + sudo rm "/home/pi/Google Drive" + sudo rm /home/pi/.gdfs.creds + sudo sed -i '\|sudo gdfs -\o allow_other /home/pi/.gdfs.creds /mnt/gdrivefs|d' /etc/rc.local + echo Installing updates... + sudo apt-get install python-pip + sudo pip install gdrivefs + sudo pip install oauth2client + echo Creating directories... + sudo mkdir /mnt/gdrivefs + echo Authorizing Google Drive... + authKey="" + echo Please follow the instructions to sign in to your Google Drive account: + sleep 1s + gdfstool auth_get_url + read -p "Authorization Key: " authKey + echo Authorizing... + gdfstool auth -a /home/pi/.gdfs.creds "$authKey" + echo Mounting drive files... + sudo gdfs -o allow_other /home/pi/.gdfs.creds /mnt/gdrivefs + ln -s "/mnt/gdrivefs" "/home/pi/Google Drive" + echo Listing files... + echo _______________________________ + confirm="y" + ls "/home/pi/Google Drive" + read -p "Is this correct (Y/n)? " confirm + if (( $confirm == "y" || $confirm == "Y" )); then + read -p "Mount at system startup (Y/n)? " confirm + if (( $confirm == "y" || $confirm == "Y" )); then + sudo sed -i -e '$i \sudo gdfs -o allow_other /home/pi/.gdfs.creds /mnt/gdrivefs' /etc/rc.local + echo Installation successful... + read -p "Press enter to exit..." + fi + else + echo Installation failed! + read -p "Press enter to exit..." + fi +fi +if (( $number == "2" )); then + echo Uninstalling... + sudo umount /mnt/gdrivefs + sudo rmdir /mnt/gdrivefs + sudo rm "/home/pi/Google Drive" + sudo rm /home/pi/.gdfs.creds + sudo sed -i '\|sudo gdfs -\o allow_other /home/pi/.gdfs.creds /mnt/gdrivefs|d' /etc/rc.local + sudo pip uninstall gdrivefs + sudo pip uninstall oauth2client + echo Uninstallation successful! + read -p "Press enter to exit..." +fi + +if (( $number == "3" )); then + sudo sed -i -e '$i \sudo gdfs -o allow_other /home/pi/.gdfs.creds /mnt/gdrivefs' /etc/rc.local + echo Auto-mount added! + read -p "Press enter to exit..." +fi + +if (( $number == "4" )); then + sudo sed -i '\|sudo gdfs -\o allow_other /home/pi/.gdfs.creds /mnt/gdrivefs|d' /etc/rc.local + echo Auto-mount removed! + read -p "Press enter to exit..." +fi + +echo Goodbye! +sleep 1s +clear