Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
A bash script to setup OneDrive integration with GNOME on Ubuntu.
#!/bin/sh
# onedrive-ubu.sh
# A BASH script to set up OneDrive integration with GNOME on Ubuntu
# Copyright (C) 2018 Garrett Mills (garrett@glmdev.tech)
# This software is licensed under the MIT License.
# This sofware is provided without warranty or even any implied intent of purpose.
#
# OnedriveD: https://github.com/xybu/onedrived-dev
clear
echo "Checking for ngrok..."
if ! which ngrok ; then
echo "onedrived requires ngrok. Please download and install it from: https://ngrok.com/download"
exit 1
done
clear
echo "Setting up OneDrive for Ubuntu GNOME..."
sleep 1
echo "Authorize sudo..."
sudo echo "Success!"
echo "Verifying dependencies..."
sleep 1
sudo apt update > /dev/null
sudo apt install -y git build-essential python3-dev libssl-dev inotify-tools python3-pip python3-dbus > /dev/null
echo "Removing any old versions of onedrived..."
sudo pip3 uninstall -y onedrive_d onedrived > /dev/null
sudo rm -rf ~/.onedrive ~/.onedrived ~/.odd
echo "Downloading onedrived..."
git clone --quiet https://github.com/xybu/onedrived-dev.git ~/.odd > /dev/null
cd ~/.odd
echo "Installing onedrived..."
sudo python3 ./setup.py install > /dev/null
echo "Configuring onedrived..."
echo "Configuring account..."
onedrived-pref account add
echo "Configuring drive..."
onedrived-pref drive set
echo "Starting OneDrive daemon..."
onedrived start
echo "Modifying default user directories..."
rm -rf ~/.config/user-dirs.dirs
echo '
# This file was written by an automatic generator while
# setting up the OneDrive integration with onedrived.
XDG_DESKTOP_DIR="$HOME/OneDrive/Desktop"
XDG_DOWNLOAD_DIR="$HOME/Downloads"
XDG_TEMPLATES_DIR="$HOME/Templates"
XDG_PUBLICSHARE_DIR="$HOME/OneDrive/Public"
XDG_DOCUMENTS_DIR="$HOME/OneDrive/Documents"
XDG_MUSIC_DIR="$HOME/OneDrive/Music"
XDG_PICTURES_DIR="$HOME/OneDrive/Pictures"
XDG_VIDEOS_DIR="$HOME/OneDrive/Videos"
' > ~/.config/user-dirs.dirs
rm -rf ~/.config/user-dirs.conf
echo "enabled=false" > ~/.config/user-dirs.conf
echo "Creating auto-start entry..."
echo "
[Desktop Entry]
Name=OneDrive Daemon Autostart
Exec=onedrived start
Type=Application
X-GNOME-Autostart-enabled=true
" > ~/.config/onedrive_daemon.desktop
echo "Success!"
@tmorshed

This comment has been minimized.

Copy link

commented Sep 15, 2018

Line #49, missing echo, giving a simple bug!

@tanjiarui15

This comment has been minimized.

Copy link

commented Nov 16, 2018

in this scrpit ,the ngrok download link is overdue.Before run this script ,you need to download ngrok from office website ,unzip it,then:
sudo mv ngrok /usr/bin/ngrok sudo chmod +x /usr/bin/ngrok

After this .you could run this script.

@glmdev

This comment has been minimized.

Copy link
Owner Author

commented Nov 18, 2018

Line #49, missing echo, giving a simple bug!

Thanks @tmorshed -- that's actually the terminator for the bash 'if' loop.

@glmdev

This comment has been minimized.

Copy link
Owner Author

commented Nov 18, 2018

in this scrpit ,the ngrok download link is overdue.Before run this script ,you need to download ngrok from office website ,unzip it,then:
sudo mv ngrok /usr/bin/ngrok sudo chmod +x /usr/bin/ngrok

After this .you could run this script.

Thanks for the heads up @tanjiarui15 -- this wasn't an ideal solution. I just made it a dependency at the beginning with a link to the install page.

@eduarddrenth

This comment has been minimized.

Copy link

commented Nov 22, 2018

line 16 => fi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.