Re: [qubes-users] Move Firefox Bookmarks between AppVMs - Help with Script

2018-05-07 Thread Drew White
[799],

If it's only for FF you want it, why not have an FF sync server on your local?
I have built myself a local DNS guest with a lot of bells and whistles.

It allows me to perform sharing and more between guests. All only accessible 
from inside my PC.

ALL DNS requests are stored and filtered properly.
ALL blocked things get a local page that provides blocked details.

I can pretty much do what I want to.
So setting a similar thing up as  an FF account Sync server should not be too 
difficult, if that is what you are interested in?


On Monday, 7 May 2018 16:26:51 UTC+10, [ 799 ]  wrote:
> Hello Ivan,
> 
> sorry for top-posting, but as everything you mentioned is super interesting 
> and very helpful ... Thank you!
> 
> 
> The auto export bookmarks feature is nice, didn't know that and if 
> places.sqlite also includes the browser history I will not use the "copy 
> places.sqlite file"-approach, because one reason why I am using a disposable 
> AppVM is exactly because I don't want to have my history seen.
> 
> 
> So the only task is to qvm-copy the latest auto-bookmarks export file into 
> the right location on the dispvm.
> There is one problem (maybe):
> I need to check if a firefox profile folder exists in the disposable VM.
> Not sure if this is the case as each disposable VM is a "fresh" one.
> 
> 
> Thanks again for your scripting tips - this is why I love the Qubes Community 
> :-)
> 
> 
> [799]
> 

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/d9bd0185-8384-4592-a454-c1e080a829da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] Move Firefox Bookmarks between AppVMs - Help with Script

2018-05-07 Thread 799
Hello Ivan,

sorry for top-posting, but as everything you mentioned is super interesting
and very helpful ... Thank you!

The auto export bookmarks feature is nice, didn't know that and if
places.sqlite also includes the browser history I will not use the "copy
places.sqlite file"-approach, because one reason why I am using a
disposable AppVM is exactly because I don't want to have my history seen.

So the only task is to qvm-copy the latest auto-bookmarks export file into
the right location on the dispvm.
There is one problem (maybe):
I need to check if a firefox profile folder exists in the disposable VM.
Not sure if this is the case as each disposable VM is a "fresh" one.

Thanks again for your scripting tips - this is why I love the Qubes
Community :-)

[799]


Ivan Mitev  schrieb am Mo., 7. Mai 2018, 07:28:

> Hi,
>
> On 05/05/2018 11:44 PM, [799] wrote:
> > Hello,
> >
> > following a recent discussion in the qubes-community github repository,
> Ivan has written an interesting script for handling links and disposable
> VMs.
> > This has inspired me to look how to move firefox bookmarks to other
> AppVMs.
> > While disposable VMs are great, sometimes it is handy to have bookmarks
> available in an AppVM.
> >
> > I was able to import bookmarks into other Appvms by transfering the
> places.sqlite file which holds the bookmarks.
>
> Interestingly I investigated this a few weeks ago; an alternative to
> copying the sqlite file (or using sql commands as suggested by rudd-o)
> is to automatically import/export bookmarks as an html file. See:
>
> https://support.mozilla.org/en-US/questions/928809#answer-338913
>
> you shouldn't need to delete the sqlite file in the target VM if you set
> this:
>
> http://kb.mozillazine.org/Browser.places.importBookmarksHTML
>
> The bookmark format looks straightforward so it should be possible to
> merge two html files with basic commands (sed/grep/awk/...) before
> importing. But you might be better off using buku
> (https://github.com/jarun/Buku) to import bookmarks, and then export
> them ; it's quite powerful...
>
>
>
> > In the target AppVM which has the bookmarks:
> > qvm-copy-to-vm 
> /home/user/.mozilla/firefox/*.default/places.sqlite
> >
> > then in the destination VM you only need to move the file from
> QubesIncoming to the profile path.
> > While this works, I like to add some error checking and I would also
> like to kill a running firefox in the destination AppVM.
> >
> > I was able to kill firefox running:
> >
> >kill `ps -A | grep firefox | gawk '{ print $1 }'`
>
> you could also use `pkill firefox`
>
> >
> > no I tried to run further command based on the fact if firefox is
> running or not.
> > I thereof tried to do something like this:
> >
> > if [`ps -A | grep firefox | gawk '{ print $1 }'` \> 0]; then
> >echo "Run this when PID is > 0 and thereof Firefox is running"
> > else
> >echo "Run this when firefox is not running"
> > fi
>
> The problem when using 'grep' is that 'ps' may output the 'grep' line
> itself so even if the process doesn't exist you'll get a match; eg.
>
> $ ps aux | grep nosuchprocess
>
> user  6837  [..] grep --color=auto nosuchprocess
>
> (although 'ps -A' doesn't seem to have this behavior)
>
> to avoid that, a trick is to use a regex like that:
>
> if ps -A | grep -q [f]irefox; then ...
>
> alternatives:
>
> if pgrep firefox > /dev/null; then ...
> if [ -n "$(pgrep firefox)" ]; then ...
> if [ -n "$(pidof firefox)" ]; then ...
>
> and as a side note you can use a short 'if' construct like that if you
> have only short commands:
>
> [ -n "$(pgrep firefox)" ] && echo running || echo not running
>

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/CAJ3yz2tUzwfmdKgeOsqogXvDU2%2Bhz2beykhNEGgQEnCGRsJ%3Drg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] Move Firefox Bookmarks between AppVMs - Help with Script

2018-05-06 Thread Ivan Mitev
Hi,

On 05/05/2018 11:44 PM, [799] wrote:
> Hello,
> 
> following a recent discussion in the qubes-community github repository, Ivan 
> has written an interesting script for handling links and disposable VMs.
> This has inspired me to look how to move firefox bookmarks to other AppVMs.
> While disposable VMs are great, sometimes it is handy to have bookmarks 
> available in an AppVM.
> 
> I was able to import bookmarks into other Appvms by transfering the 
> places.sqlite file which holds the bookmarks.

Interestingly I investigated this a few weeks ago; an alternative to
copying the sqlite file (or using sql commands as suggested by rudd-o)
is to automatically import/export bookmarks as an html file. See:

https://support.mozilla.org/en-US/questions/928809#answer-338913

you shouldn't need to delete the sqlite file in the target VM if you set
this:

http://kb.mozillazine.org/Browser.places.importBookmarksHTML

The bookmark format looks straightforward so it should be possible to
merge two html files with basic commands (sed/grep/awk/...) before
importing. But you might be better off using buku
(https://github.com/jarun/Buku) to import bookmarks, and then export
them ; it's quite powerful...



> In the target AppVM which has the bookmarks:
> qvm-copy-to-vm  
> /home/user/.mozilla/firefox/*.default/places.sqlite
> 
> then in the destination VM you only need to move the file from QubesIncoming 
> to the profile path.
> While this works, I like to add some error checking and I would also like to 
> kill a running firefox in the destination AppVM.
> 
> I was able to kill firefox running:
> 
>kill `ps -A | grep firefox | gawk '{ print $1 }'`

you could also use `pkill firefox`

> 
> no I tried to run further command based on the fact if firefox is running or 
> not.
> I thereof tried to do something like this:
> 
> if [`ps -A | grep firefox | gawk '{ print $1 }'` \> 0]; then
>echo "Run this when PID is > 0 and thereof Firefox is running"
> else
>echo "Run this when firefox is not running"
> fi

The problem when using 'grep' is that 'ps' may output the 'grep' line
itself so even if the process doesn't exist you'll get a match; eg.

$ ps aux | grep nosuchprocess

user  6837  [..] grep --color=auto nosuchprocess

(although 'ps -A' doesn't seem to have this behavior)

to avoid that, a trick is to use a regex like that:

if ps -A | grep -q [f]irefox; then ...

alternatives:

if pgrep firefox > /dev/null; then ...
if [ -n "$(pgrep firefox)" ]; then ...
if [ -n "$(pidof firefox)" ]; then ...

and as a side note you can use a short 'if' construct like that if you
have only short commands:

[ -n "$(pgrep firefox)" ] && echo running || echo not running



> Unfortunately this doesn't work. Can somone point me into the right direction?
> What is the right approach to run certain commands based on the fact that a 
> program is running or not?
> 
> Sorry for this off-topic question but playing with Qubes gives so much 
> options for building own scripts and I am still a beginner here.
> 
> [799]


-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/8b6cdcd8-2c5f-e60c-1374-e6b43aaeeb01%40maa.bz.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] Move Firefox Bookmarks between AppVMs - Help with Script

2018-05-06 Thread 'MirrorWay' via qubes-users
On May 5, 2018 8:44 PM, [799]  wrote:

> Hello,
> 
> following a recent discussion in the qubes-community github repository, Ivan 
> has written an interesting script for handling links and disposable VMs.
> 
> This has inspired me to look how to move firefox bookmarks to other AppVMs.
> 
> While disposable VMs are great, sometimes it is handy to have bookmarks 
> available in an AppVM.
> 
> I was able to import bookmarks into other Appvms by transfering the 
> places.sqlite file which holds the bookmarks.
> 
> In the target AppVM which has the bookmarks:
> 
> qvm-copy-to-vm  
> /home/user/.mozilla/firefox/*.default/places.sqlite
> 
> then in the destination VM you only need to move the file from QubesIncoming 
> to the profile path.
> 
> While this works, I like to add some error checking and I would also like to 
> kill a running firefox in the destination AppVM.

Isn't this a one-time import? I'm not sure why you need to automate this 
process, Seems like the VM that stores bookmarks could get compromised 
eventually if it parses SQL files constantly.

> I thereof tried to do something like this:
> 
> if [`ps -A | grep firefox | gawk '{ print $1 }'` > 0]; then
> 
> echo "Run this when PID is > 0 and thereof Firefox is running"
> 
> else
> 
> echo "Run this when firefox is not running"
> 
> fi

I'm not sure why firefox PID would ever be 0?
If firefox isn't running, it won't show in ps. So: 
  if ps -A | grep -q firefox; then  else ... fi

assuming any process whose name contains "firefox" is actually firefox.


-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/4ps-IzfLcjNq04B7enXkHTs5f5K5CR9xA-pJUTb0sH8CS7VLpgHOtk-vHJ6OjPyVKhVTF52bUtmypaMiWBrxeUGrJA0RD2SNQhL9La9Wdb4%3D%40protonmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] Move Firefox Bookmarks between AppVMs - Help with Script

2018-05-06 Thread Stuart Perkins
I would accomplish bookmarks within disposable vm by...

Create an exported tar file of a profile, including the control file for 
firefox which defines the default profile.
Start the disposable vm for terminal.
qvm-copy-to-vm the tar file
extract tar
run script
start firefox

It would be a little bit "manual" but would accomplish the goal.  The tar file 
would be recreated when bookmarked site login info changed etc...

Just my take on it.

On Sat, 5 May 2018 22:44:44 +0200
"[799]"  wrote:

>Hello,
>
>following a recent discussion in the qubes-community github repository, Ivan 
>has written an interesting script for handling links and disposable VMs.
>This has inspired me to look how to move firefox bookmarks to other AppVMs.
>While disposable VMs are great, sometimes it is handy to have bookmarks 
>available in an AppVM.
>
>I was able to import bookmarks into other Appvms by transfering the 
>places.sqlite file which holds the bookmarks.
>
>In the target AppVM which has the bookmarks:
>qvm-copy-to-vm  
>/home/user/.mozilla/firefox/*.default/places.sqlite
>
>then in the destination VM you only need to move the file from QubesIncoming 
>to the profile path.
>While this works, I like to add some error checking and I would also like to 
>kill a running firefox in the destination AppVM.
>
>I was able to kill firefox running:
>
>   kill `ps -A | grep firefox | gawk '{ print $1 }'`
>
>no I tried to run further command based on the fact if firefox is running or 
>not.
>I thereof tried to do something like this:
>
>if [`ps -A | grep firefox | gawk '{ print $1 }'` \> 0]; then
>   echo "Run this when PID is > 0 and thereof Firefox is running"
>else
>   echo "Run this when firefox is not running"
>fi
>
>Unfortunately this doesn't work. Can somone point me into the right direction?
>What is the right approach to run certain commands based on the fact that a 
>program is running or not?
>
>Sorry for this off-topic question but playing with Qubes gives so much options 
>for building own scripts and I am still a beginner here.
>
>[799]
>

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/20180506114259.631ccc40%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] Move Firefox Bookmarks between AppVMs - Help with Script

2018-05-06 Thread 799
Hello rudd-o,

Manuel Amador (Rudd-O)  schrieb am So., 6. Mai 2018,
03:44:

> On 2018-05-05 20:44, [799] wrote:

> () I thereof tried to do something

> like this:
> >
> > if [`ps -A | grep firefox | gawk '{ print $1 }'` \> 0]; then
> >echo "Run this when PID is > 0 and thereof Firefox is running"
> > else
> >echo "Run this when firefox is not running"
> > fi
> >
> > Unfortunately this doesn't work. Can somone point me into the right
> direction?
>

This is still not solved, I like to know how to make this work, also
because I might need this for other purposes.

You are probably better off writing something that will sync two
> different .sqlite files by using SQL operations on both.  SQLite files
> are safe to be accessed by two different programs at the same time, and
> therefore you may not need to kill Firefox.
>

You are right, but this is something that is currently beyond my skillet as
I need to learn python and sqlite.
There is an interesting tutorial which might be helpful, but it will take
some time for me ...
http://www.sqlitetutorial.net/

As an additional task I need to understand how the sqlite database is
setup/working in order to merge bookmarks from two different places.sqlite
files.
I think the easiest way would look like:

1) dump data from sqlite (even while Firefox is running
2) copy dumpfile to destination VM
3) import dump and overwrite the existing entries in the places.sqlite

If I has the dump export/import part I can take care of the rest.
The idea is that I can start a disposable VM and then "push" the firefox
bookmarks of another VM into this disposable VM.

[799]

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/CAJ3yz2vTp5GkFPu9fS05QLwpfTzsMnit24UpneoTbR_2aYzgZg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [qubes-users] Move Firefox Bookmarks between AppVMs - Help with Script

2018-05-05 Thread Manuel Amador (Rudd-O)
On 2018-05-05 20:44, [799] wrote:
> Hello,
>
> following a recent discussion in the qubes-community github repository, Ivan 
> has written an interesting script for handling links and disposable VMs.
> This has inspired me to look how to move firefox bookmarks to other AppVMs.
> While disposable VMs are great, sometimes it is handy to have bookmarks 
> available in an AppVM.
>
> I was able to import bookmarks into other Appvms by transfering the 
> places.sqlite file which holds the bookmarks.
>
> In the target AppVM which has the bookmarks:
> qvm-copy-to-vm  
> /home/user/.mozilla/firefox/*.default/places.sqlite
>
> then in the destination VM you only need to move the file from QubesIncoming 
> to the profile path.
> While this works, I like to add some error checking and I would also like to 
> kill a running firefox in the destination AppVM.
>
> I was able to kill firefox running:
>
>kill `ps -A | grep firefox | gawk '{ print $1 }'`
>
> no I tried to run further command based on the fact if firefox is running or 
> not.
> I thereof tried to do something like this:
>
> if [`ps -A | grep firefox | gawk '{ print $1 }'` \> 0]; then
>echo "Run this when PID is > 0 and thereof Firefox is running"
> else
>echo "Run this when firefox is not running"
> fi
>
> Unfortunately this doesn't work. Can somone point me into the right direction?
> What is the right approach to run certain commands based on the fact that a 
> program is running or not?
>
> Sorry for this off-topic question but playing with Qubes gives so much 
> options for building own scripts and I am still a beginner here.
>
> [799]
>
You are probably better off writing something that will sync two
different .sqlite files by using SQL operations on both.  SQLite files
are safe to be accessed by two different programs at the same time, and
therefore you may not need to kill Firefox.

-- 
Rudd-O
http://rudd-o.com/

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/31c51383-57c4-86f9-c0db-91b0dc8ccbf0%40rudd-o.com.
For more options, visit https://groups.google.com/d/optout.


[qubes-users] Move Firefox Bookmarks between AppVMs - Help with Script

2018-05-05 Thread [799]
Hello,

following a recent discussion in the qubes-community github repository, Ivan 
has written an interesting script for handling links and disposable VMs.
This has inspired me to look how to move firefox bookmarks to other AppVMs.
While disposable VMs are great, sometimes it is handy to have bookmarks 
available in an AppVM.

I was able to import bookmarks into other Appvms by transfering the 
places.sqlite file which holds the bookmarks.

In the target AppVM which has the bookmarks:
qvm-copy-to-vm  
/home/user/.mozilla/firefox/*.default/places.sqlite

then in the destination VM you only need to move the file from QubesIncoming to 
the profile path.
While this works, I like to add some error checking and I would also like to 
kill a running firefox in the destination AppVM.

I was able to kill firefox running:

   kill `ps -A | grep firefox | gawk '{ print $1 }'`

no I tried to run further command based on the fact if firefox is running or 
not.
I thereof tried to do something like this:

if [`ps -A | grep firefox | gawk '{ print $1 }'` \> 0]; then
   echo "Run this when PID is > 0 and thereof Firefox is running"
else
   echo "Run this when firefox is not running"
fi

Unfortunately this doesn't work. Can somone point me into the right direction?
What is the right approach to run certain commands based on the fact that a 
program is running or not?

Sorry for this off-topic question but playing with Qubes gives so much options 
for building own scripts and I am still a beginner here.

[799]

-- 
You received this message because you are subscribed to the Google Groups 
"qubes-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to qubes-users+unsubscr...@googlegroups.com.
To post to this group, send email to qubes-users@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/qubes-users/2018050520.o22gzlllsub4kdgj%40my-privmail.
For more options, visit https://groups.google.com/d/optout.