forked from MunifTanjim/scripts.sh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-drivesync
executable file
·39 lines (29 loc) · 977 Bytes
/
setup-drivesync
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
#!/usr/bin/env bash
# install/update drivesync
# https://github.com/MStadlmeier/drivesync
_drivesync_dir="${HOME}/.drivesync"
if [[ -d "${_drivesync_dir}" ]]; then
echo "DriveSync is already installed!"
echo "Updating to the latest version..."
cd ${_drivesync_dir} && git pull
else
echo "Installing DriveSync..."
git clone https://github.com/MStadlmeier/drivesync ${_drivesync_dir}
cd ${_drivesync_dir}
fi
echo "Running build..."
bundle install
_drivesync_entrypoint="${_drivesync_dir}/drivesync.rb"
echo "Setting up DriveSync binary: drivesync"
_drivesync_bin="${HOME}/.local/bin/drivesync"
tee ${_drivesync_bin} > /dev/null << EOL
#!/usr/bin/env sh
ruby ${_drivesync_entrypoint} \${@}
EOL
chmod u+x ${_drivesync_bin}
echo "Setting up periodic synchronization: 20m"
sudo tee /etc/cron.d/drivesync > /dev/null << EOL
SHELL=${SHELL}
*/20 * * * * munif . \${HOME}/.bashrc && drivesync > /tmp/drivesync.\$(date +\%Y\%m\%d\%H\%M\%S).log 2>&1
EOL
echo "Done!"