]> pere.pagekite.me Git - homepage.git/blob - blog/archive/2018/10/10.rss
Improve language.
[homepage.git] / blog / archive / 2018 / 10 / 10.rss
1 <?xml version="1.0" encoding="ISO-8859-1"?>
2 <rss version='2.0' xmlns:lj='http://www.livejournal.org/rss/lj/1.0/'>
3 <channel>
4 <title>Petter Reinholdtsen - Entries from October 2018</title>
5 <description>Entries from October 2018</description>
6 <link>http://people.skolelinux.org/pere/blog/</link>
7
8
9 <item>
10 <title>Automatic Google Drive sync using grive in Debian</title>
11 <link>http://people.skolelinux.org/pere/blog/Automatic_Google_Drive_sync_using_grive_in_Debian.html</link>
12 <guid isPermaLink="true">http://people.skolelinux.org/pere/blog/Automatic_Google_Drive_sync_using_grive_in_Debian.html</guid>
13 <pubDate>Thu, 4 Oct 2018 15:20:00 +0200</pubDate>
14 <description>&lt;p&gt;A few days, I rescued a Windows victim over to Debian. To try to
15 rescue the remains, I helped set up automatic sync with Google Drive.
16 I did not find any sensible Debian package handling this
17 automatically, so I rebuild the grive2 source from
18 &lt;a href=&quot;http://www.webupd8.org/&quot;&gt;the Ubuntu UPD8 PPA&lt;/a&gt; to do the
19 task and added a autostart desktop entry and a small shell script to
20 run in the background while the user is logged in to do the sync.
21 Here is a sketch of the setup for future reference.&lt;/p&gt;
22
23 &lt;p&gt;I first created &lt;tt&gt;~/googledrive&lt;/tt&gt;, entered the directory and
24 ran &#39;&lt;tt&gt;grive -a&lt;/tt&gt;&#39; to authenticate the machine/user. Next, I
25 created a autostart hook in &lt;tt&gt;~/.config/autostart/grive.desktop&lt;/tt&gt;
26 to start the sync when the user log in:&lt;/p&gt;
27
28 &lt;p&gt;&lt;blockquote&gt;&lt;pre&gt;
29 [Desktop Entry]
30 Name=Google drive autosync
31 Type=Application
32 Exec=/home/user/bin/grive-sync
33 &lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;
34
35 &lt;p&gt;Finally, I wrote the &lt;tt&gt;~/bin/grive-sync&lt;/tt&gt; script to sync
36 ~/googledrive/ with the files in Google Drive.&lt;/p&gt;
37
38 &lt;p&gt;&lt;blockquote&gt;&lt;pre&gt;
39 #!/bin/sh
40 set -e
41 cd ~/
42 cleanup() {
43 if [ &quot;$syncpid&quot; ] ; then
44 kill $syncpid
45 fi
46 }
47 trap cleanup EXIT INT QUIT
48 /usr/lib/grive/grive-sync.sh listen googledrive 2&gt;&amp;1 | sed &quot;s%^%$0:%&quot; &amp;
49 syncpdi=$!
50 while true; do
51 if ! xhost &gt;/dev/null 2&gt;&amp;1 ; then
52 echo &quot;no DISPLAY, exiting as the user probably logged out&quot;
53 exit 1
54 fi
55 if [ ! -e /run/user/1000/grive-sync.sh_googledrive ] ; then
56 /usr/lib/grive/grive-sync.sh sync googledrive
57 fi
58 sleep 300
59 done 2&gt;&amp;1 | sed &quot;s%^%$0:%&quot;
60 &lt;/pre&gt;&lt;/blockquote&gt;&lt;/p&gt;
61
62 &lt;p&gt;Feel free to use the setup if you want. It can be assumed to be
63 GNU GPL v2 licensed (or any later version, at your leisure), but I
64 doubt this code is possible to claim copyright on.&lt;/p&gt;
65
66 &lt;p&gt;As usual, if you use Bitcoin and want to show your support of my
67 activities, please send Bitcoin donations to my address
68 &lt;b&gt;&lt;a href=&quot;bitcoin:15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&quot;&gt;15oWEoG9dUPovwmUL9KWAnYRtNJEkP1u1b&lt;/a&gt;&lt;/b&gt;.&lt;/p&gt;
69 </description>
70 </item>
71
72 </channel>
73 </rss>