This repository has been archived by the owner on Dec 18, 2017. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
install.sh
executable file
·130 lines (99 loc) · 3.09 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#!/usr/bin/env bash
# Author: Héctor Molinero Fernández <[email protected]>
# Repository: https://github.com/zant95/elementary-dropbox
# License: MIT, https://opensource.org/licenses/MIT
# Exit on errors
set -euo pipefail
# Globals
scriptDir=$(dirname "$(readlink -f "$0")")
# Methods
function downloadDropbox {
infoMsg 'Downloading Dropbox...'
if [ $(uname -m) == 'x86_64' ]; then
arch=x86_64
else
arch=x86
fi
mkdir "$HOME"/.dropbox-dist
wget "https://www.dropbox.com/download?plat=lnx.$arch" -O - | \
tar -xz --strip-components=1 -C "$HOME"/.dropbox-dist
}
function downloadDropboxCLI {
infoMsg 'Downloading Dropbox CLI...'
mkdir "$HOME"/.dropbox-bin
wget 'https://www.dropbox.com/download?dl=packages/dropbox.py' -qO "$HOME"/.dropbox-bin/dropbox
}
function configureDropbox {
infoMsg 'Configuring Dropbox...'
cat > "$HOME"/.dropbox-bin/dropboxd <<-'EOF'
#!/bin/sh
env XDG_CURRENT_DESKTOP=Unity QT_STYLE_OVERRIDE="" "$HOME"/.dropbox-dist/dropboxd "$@"
EOF
# Replace daemon location
sed -i 's|dropbox-dist/dropboxd|dropbox-bin/dropboxd|g' "$HOME"/.dropbox-bin/dropbox
# Prevents autostart modification (buggy)
sed -i '/def reroll_autostart(/a\ \ \ \ return' "$HOME"/.dropbox-bin/dropbox
infoMsg 'Adding to path (maybe a restart is required)...'
if [ -s "$HOME"/.profile ]; then
sed -i '$s|$|\nPATH="$HOME/.dropbox-bin:$PATH"|' "$HOME"/.profile
else
echo 'PATH="$HOME/.dropbox-bin:$PATH"' > "$HOME"/.profile
fi
chmod +x "$HOME"/.dropbox-bin/*
}
function createLaunchers {
infoMsg 'Creating menu launcher...'
mkdir -p "$HOME"/.local/share/applications
cat > "$HOME"/.local/share/applications/dropbox.desktop <<-EOF
[Desktop Entry]
Name=Dropbox
GenericName=File Synchronizer
Comment=Sync your files across computers and to the web
Exec="$HOME"/.dropbox-bin/dropbox start -i
Terminal=false
Type=Application
Icon=dropbox
Categories=Network;FileTransfer;
StartupNotify=false
EOF
infoMsg 'Creating autostart launcher...'
mkdir -p "$HOME"/.config/autostart
ln -fs "$HOME"/.local/share/applications/dropbox.desktop "$HOME"/.config/autostart/dropbox.desktop
}
function installIcons {
infoMsg 'Installing icons...'
mkdir -p "$HOME"/.local/share/icons/hicolor
cp -rT "$scriptDir"/icons "$HOME"/.local/share/icons/hicolor
}
function runDropbox {
"$HOME"/.dropbox-bin/dropbox start -i
}
# Process
source "$scriptDir"/common.sh
infoMsg 'Installing Dropbox...'
if [ -d "$HOME"/.dropbox ] || [ -d "$HOME"/.dropbox-bin ] || [ -d "$HOME"/.dropbox-dist ]; then
warnMsg 'This script has found a previous Dropbox installation.'
if promptMsg 'Do you want to uninstall Dropbox?'; then
bash "$scriptDir"/uninstall.sh
else
errorMsg 'Installation aborted!'
exit 1
fi
fi
downloadDropbox
downloadDropboxCLI
configureDropbox
createLaunchers
if promptMsg 'Do you want to install the custom icons?'; then
installIcons
fi
if isReleaseCodename 'loki'; then
warnMsg 'Elementary OS Loki detected.'
if promptMsg 'Do you want to enable experimental support?'; then
bash "$scriptDir"/loki_support.sh
fi
fi
if promptMsg 'Run Dropbox now?'; then
runDropbox
fi
infoMsg 'Installation complete!'