Skip to content

Commit

Permalink
Refactor code (fix #6) and resolve dependencies (fix #3)
Browse files Browse the repository at this point in the history
  • Loading branch information
programmer2514 authored May 26, 2022
1 parent 7b29cff commit 744e269
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 26 deletions.
26 changes: 13 additions & 13 deletions installGoogleDrive.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (( $number == "1" )); then
echo Initializing...

# Set active directory
cd /home/pi
cd ~

echo Cleaning up old assets...

Expand All @@ -36,18 +36,18 @@ if (( $number == "1" )); then
sudo rm /mnt/gdrivefs

# Delete Google Drive auth token if it exists
sudo rm /home/pi/.gdfs/creds
sudo rm ~/.gdfs/creds

# Delete Google Drive symbolic link in home directory if it exists
sudo rm "/home/pi/Google Drive"
sudo rm "$HOME/Google Drive"

# Remove autostart entry if it exists
sudo rm /etc/profile.d/mount-gdfs.sh

echo Installing updates...

# Make sure pip3 is installed
sudo apt-get install python3-pip
# Make sure pip3 and fuse are installed
sudo apt-get install python3-pip fuse

# Install necessary python packages
sudo pip3 install google-api-python-client -U
Expand Down Expand Up @@ -76,10 +76,10 @@ if (( $number == "1" )); then
echo Mounting drive files...

# Mount GDFS
gdfs /home/pi/.gdfs/creds /mnt/gdrivefs
gdfs ~/.gdfs/creds /mnt/gdrivefs

# Create symbolic link
ln -s "/mnt/gdrivefs" "/home/pi/Google Drive"
ln -s "/mnt/gdrivefs" "$HOME/Google Drive"

echo Listing files...
echo _______________________________
Expand All @@ -88,7 +88,7 @@ if (( $number == "1" )); then
confirm="y"

# List files in drive
ls "/home/pi/Google Drive"
ls "$HOME/Google Drive"

# Ask user for success confirmation
read -p "Is this correct (Y/n)? " confirm
Expand All @@ -102,7 +102,7 @@ if (( $number == "1" )); then

# Add autostart entry
sudo sh -c 'echo "#!/bin/sh
gdfs /home/pi/.gdfs/creds /mnt/gdrivefs" >> /etc/profile.d/mount-gdfs.sh'
gdfs ~/.gdfs/creds /mnt/gdrivefs" >> /etc/profile.d/mount-gdfs.sh'

# Make autostart entry executable
sudo chmod +x /etc/profile.d/mount-gdfs.sh
Expand Down Expand Up @@ -137,10 +137,10 @@ if (( $number == "2" )); then
sudo rm /mnt/gdrivefs

# Delete Google Drive auth token
sudo rm /home/pi/.gdfs/creds
sudo rm ~/.gdfs/creds

# Delete Google Drive symbolic link in home directory
sudo rm "/home/pi/Google Drive"
sudo rm "$HOME/Google Drive"

# Remove autostart entry
sudo rm /etc/profile.d/mount-gdfs.sh
Expand All @@ -159,7 +159,7 @@ if (( $number == "3" )); then

# Mount GDFS
echo Mounting GDFS...
gdfs /home/pi/.gdfs/creds /mnt/gdrivefs
gdfs ~/.gdfs/creds /mnt/gdrivefs

# Exit script
echo GDFS mounted!
Expand Down Expand Up @@ -188,7 +188,7 @@ if (( $number == "5" )); then

# Add new autostart entry
sudo sh -c 'echo "#!/bin/sh
gdfs /home/pi/.gdfs/creds /mnt/gdrivefs" >> /etc/profile.d/mount-gdfs.sh'
gdfs ~/.gdfs/creds /mnt/gdrivefs" >> /etc/profile.d/mount-gdfs.sh'

# Make autostart entry executable
sudo chmod +x /etc/profile.d/mount-gdfs.sh
Expand Down
26 changes: 13 additions & 13 deletions installGoogleDrive_headless.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ if (( $number == "1" )); then
echo Initializing...

# Set active directory
cd /home/pi
cd ~

echo Cleaning up old assets...

Expand All @@ -36,18 +36,18 @@ if (( $number == "1" )); then
sudo rm /mnt/gdrivefs

# Delete Google Drive auth token if it exists
sudo rm /home/pi/.gdfs/creds
sudo rm ~/.gdfs/creds

# Delete Google Drive symbolic link in home directory if it exists
sudo rm "/home/pi/Google Drive"
sudo rm "$HOME/Google Drive"

# Remove autostart entry if it exists
sudo rm /etc/profile.d/mount-gdfs.sh

echo Installing updates...

# Make sure pip3 is installed
sudo apt-get install python3-pip
# Make sure pip3 and fuse are installed
sudo apt-get install python3-pip fuse

# Install necessary python packages
sudo pip3 install google-api-python-client -U
Expand Down Expand Up @@ -85,10 +85,10 @@ if (( $number == "1" )); then
echo Mounting drive files...

# Mount GDFS
gdfs /home/pi/.gdfs/creds /mnt/gdrivefs
gdfs ~/.gdfs/creds /mnt/gdrivefs

# Create symbolic link
ln -s "/mnt/gdrivefs" "/home/pi/Google Drive"
ln -s "/mnt/gdrivefs" "$HOME/Google Drive"

echo Listing files...
echo _______________________________
Expand All @@ -97,7 +97,7 @@ if (( $number == "1" )); then
confirm="y"

# List files in drive
ls "/home/pi/Google Drive"
ls "$HOME/Google Drive"

# Ask user for success confirmation
read -p "Is this correct (Y/n)? " confirm
Expand All @@ -111,7 +111,7 @@ if (( $number == "1" )); then

# Add autostart entry
sudo sh -c 'echo "#!/bin/sh
gdfs /home/pi/.gdfs/creds /mnt/gdrivefs" >> /etc/profile.d/mount-gdfs.sh'
gdfs ~/.gdfs/creds /mnt/gdrivefs" >> /etc/profile.d/mount-gdfs.sh'

# Make autostart entry executable
sudo chmod +x /etc/profile.d/mount-gdfs.sh
Expand Down Expand Up @@ -146,10 +146,10 @@ if (( $number == "2" )); then
sudo rm /mnt/gdrivefs

# Delete Google Drive auth token
sudo rm /home/pi/.gdfs/creds
sudo rm ~/.gdfs/creds

# Delete Google Drive symbolic link in home directory
sudo rm "/home/pi/Google Drive"
sudo rm "$HOME/Google Drive"

# Remove autostart entry
sudo rm /etc/profile.d/mount-gdfs.sh
Expand All @@ -168,7 +168,7 @@ if (( $number == "3" )); then

# Mount GDFS
echo Mounting GDFS...
gdfs /home/pi/.gdfs/creds /mnt/gdrivefs
gdfs ~/.gdfs/creds /mnt/gdrivefs

# Exit script
echo GDFS mounted!
Expand Down Expand Up @@ -197,7 +197,7 @@ if (( $number == "5" )); then

# Add new autostart entry
sudo sh -c 'echo "#!/bin/sh
gdfs /home/pi/.gdfs/creds /mnt/gdrivefs" >> /etc/profile.d/mount-gdfs.sh'
gdfs ~/.gdfs/creds /mnt/gdrivefs" >> /etc/profile.d/mount-gdfs.sh'

# Make autostart entry executable
sudo chmod +x /etc/profile.d/mount-gdfs.sh
Expand Down

0 comments on commit 744e269

Please sign in to comment.