maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   SailfishOS (https://talk.maemo.org/forumdisplay.php?f=52)
-   -   [WIP] Prey - antitheft system (https://talk.maemo.org/showthread.php?t=92829)

rob_kouw 2015-03-06 19:56

Re: [WIP] Prey - antitheft system
 
1 Attachment(s)
So, after the update to 1.12 Yliaavanlampi, prey stopped working. I uninstalled openssl 1j and installed 1h again, reinstalled prey and preyUI. Started the timer by using the command systemctl enable prey.timer, and tried the UI as well. But somehow the server does not receive any messages, and the UI status shows that prey is waiting since 23 hours. What can I do now?

Victorious 2015-03-06 21:58

Re: [WIP] Prey - antitheft system
 
To me wrote:
Mer 0.2011 Laptop, 0.0 GB RAM Prey: 0.6.4 OUTDATED CLIENT,You must upgrade Prey to the latest version in order to locate the device on this map

nieldk 2015-03-07 05:55

Re: [WIP] Prey - antitheft system
 
That is correct. Prey no longer is functional (map) with this version.
I am working on the new (nodejs) version.

There was an issue that Prey servers didnt recognize our Jolla.

I have been in touch with them. And this should now be solved at their disgression :)

So. Now I can continue were I was stopped.

There still are some things to work on. But, I do have it running using nodejs. (Nodejs is on my merproject pages)

Hooefully during this weekend I can get it working better.

If you want to test you can install nodejs, then install prey using

npm install -g prey

For more information, until I finish this, look here

https://github.com/prey/prey-node-cl...ster/README.md

Nodejs is needed. You will find my build here:

https://build.merproject.org/package...nielsen/nodejs

Victorious 2015-03-07 12:48

Re: [WIP] Prey - antitheft system
 
Has established an nodejs-0.12.0-10.3.1.jolla.armv7hl.rpm, but still writes:
Prey: 0.6.4 OUTDATED CLIENT

pasko 2015-03-07 14:21

Re: [WIP] Prey - antitheft system
 
Hi.
Are there any chances to see this effort ported to Harmattan?. My client is a bit outdated and for instance doesn't work when device 'gprs0' is active...
P.S: Sorry for the off-topic.
Regards.

nieldk 2015-03-07 15:01

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by Victorious (Post 1463328)
Has established an nodejs-0.12.0-10.3.1.jolla.armv7hl.rpm, but still writes:
Prey: 0.6.4 OUTDATED CLIENT

Uninstall old version. And try instructions on post before your post.

nieldk 2015-03-07 15:03

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by pasko (Post 1463332)
Hi.
Are there any chances to see this effort ported to Harmattan?. My client is a bit outdated and for instance doesn't work when device 'gprs0' is active...
P.S: Sorry for the off-topic.
Regards.

Perhaps....
Once i get it more functional on sailfish i can give it a try

Victorious 2015-03-07 15:53

Re: [WIP] Prey - antitheft system
 
Help please
Code:

[nemo@Jolla ~]$ npm update -g prey
[nemo@Jolla ~]$ [sudo] npm install -g prey
-bash: [sudo]: command not found
[nemo@Jolla ~]$ npm install -g prey
|
> prey@1.3.6 preuninstall /usr/lib/node_modules/prey
> ./bin/prey config hooks pre_uninstall

===============================================================================
  Holy cow! Looks like you ran 'npm remove' but without the --unsafe-perm flag.
  This means the init scripts will remain installed, because they need root to be removed.

  To ensure a clean uninstall, please reinstall the package and then re-run this command,
  only this time with the --unsafe-perm flag, so everything gets wiped out:

  $ sudo npm -g remove prey --unsafe-perm
===============================================================================
npm WARN continuing anyway prey@1.3.6 preuninstall: `./bin/prey config hooks pre_uninstall`
npm WARN continuing anyway Exit status 1
npm ERR! Linux 3.4.98.20141219.1.1
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "prey"
npm ERR! node v0.12.0
npm ERR! npm  v2.5.1
npm ERR! path /usr/bin/prey
npm ERR! code EACCES
npm ERR! errno -13

npm ERR! Error: EACCES, unlink '/usr/bin/prey'
npm ERR!    at Error (native)
npm ERR!  { [Error: EACCES, unlink '/usr/bin/prey'] errno: -13, code: 'EACCES', path: '/usr/bin/prey' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

> prey@1.3.6 preuninstall /usr/lib/node_modules/prey
> ./bin/prey config hooks pre_uninstall

===============================================================================
  Holy cow! Looks like you ran 'npm remove' but without the --unsafe-perm flag.
  This means the init scripts will remain installed, because they need root to be removed.

  To ensure a clean uninstall, please reinstall the package and then re-run this command,
  only this time with the --unsafe-perm flag, so everything gets wiped out:

  $ sudo npm -g remove prey --unsafe-perm
===============================================================================
npm WARN continuing anyway prey@1.3.6 preuninstall: `./bin/prey config hooks pre_uninstall`
npm WARN continuing anyway Exit status 1
npm ERR! error rolling back Error: EACCES, unlink '/usr/bin/prey'
npm ERR! error rolling back    at Error (native)
npm ERR! error rolling back  { [Error: EACCES, unlink '/usr/bin/prey'] errno: -13, code: 'EACCES', path: '/usr/bin/prey' }

npm ERR! Please include the following file with any support request:
npm ERR!    /home/nemo/npm-debug.log
[nemo@Jolla ~]$


nieldk 2015-03-07 16:08

Re: [WIP] Prey - antitheft system
 
Like said. This is still work in progress.

But .. try

sudo npm install -g prey

Victorious 2015-03-07 16:13

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1463343)
Like said. This is still work in progress.

But .. try

sudo npm install -g prey

[nemo@Jolla ~]$ sudo npm install -g prey
nemo's password:
nemo is not in the sudoers file. This incident will be reported.
[nemo@Jolla ~]$

nieldk 2015-03-07 16:19

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by Victorious (Post 1463344)
[nemo@Jolla ~]$ sudo npm install -g prey
nemo's password:
nemo is not in the sudoers file. This incident will be reported.
[nemo@Jolla ~]$

You will need to allow user 'nemo' to use sudo

Code:

$ devel-su
# echo "nemo ALL=(ALL) ALL" >> /etc/sudoers
# exit
$ sudo npm install -g prey


Victorious 2015-03-07 16:38

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1463346)
You will need to allow user 'nemo' to use sudo

Code:

$ devel-su
# echo "nemo ALL=(ALL) ALL" >> /etc/sudoers
# exit
$ sudo npm install -g prey


Thank U! I hope all is well!
Code:

[nemo@Jolla ~]$ devel-su
Password:
[root@Jolla nemo]# echo "nemo ALL=(ALL) ALL" >> /etc/sudoers
[root@Jolla nemo]# exit
exit
[nemo@Jolla ~]$ sudo npm install -g prey
nemo's password:
/
> prey@1.3.6 preuninstall /usr/lib/node_modules/prey
> ./bin/prey config hooks pre_uninstall

===============================================================================
  Holy cow! Looks like you ran 'npm remove' but without the --unsafe-perm flag.
  This means the init scripts will remain installed, because they need root to be removed.

  To ensure a clean uninstall, please reinstall the package and then re-run this command,
  only this time with the --unsafe-perm flag, so everything gets wiped out:

  $ sudo npm -g remove prey --unsafe-perm
===============================================================================
npm WARN continuing anyway prey@1.3.6 preuninstall: `./bin/prey config hooks pre_uninstall`
npm WARN continuing anyway Exit status 1
npm WARN engine xmlbuilder@2.4.4: wanted: {"node":"0.8.x || 0.10.x || 0.11.x"} (current: {"node":"0.12.0","npm":"2.5.1"})
/usr/bin/prey -> /usr/lib/node_modules/prey/bin/prey

> prey@1.3.6 postinstall /usr/lib/node_modules/prey
> ./bin/prey config hooks post_install

===============================================================================
  You are running this script as an unprivileged user
  so we cannot finalize setting up the client.
  To continue with the install process please run:

  $ sudo prey config hooks post_install
===============================================================================
prey@1.3.6 /usr/lib/node_modules/prey
├── clean-exit@0.0.3
├── wink@0.0.1
├── memorize@0.0.1
├── scrambler@0.0.1
├── petit@0.0.5
├── uid-number@0.0.5
├── remover@0.0.2
├── winssh@0.0.1
├── dialog@0.1.8
├── tuna@0.0.2
├── which@1.0.5
├── sudoer@0.1.1
├── ocelot@0.0.5
├── whenever@0.0.3
├── commander@2.3.0
├── reply@0.3.1
├── graceful-fs@2.0.3
├── rimraf@2.2.8
├── colors@0.6.2
├── network@0.1.3
├── random-ua@0.0.6
├── campfire@0.2.0
├── getset@0.6.3
├── underscore@1.7.0
├── mime@1.2.5
├── qs@2.2.4
├── firewall@0.0.5 (spawnx@0.0.1)
├── async@0.9.0
├── linus@0.0.3 (getos@1.0.1, memorize@0.0.3, whenever@0.0.2)
├── triggers@0.2.0
├── wmic@0.0.7
├── nat-pmp@0.0.3 (debug@0.7.4)
├── chela@0.0.5 (graceful-fs@3.0.5)
├── connect@3.2.0 (utils-merge@1.0.0, parseurl@1.3.0, finalhandler@0.2.0, debug@2.0.0)
├── serve-static@1.7.0 (utils-merge@1.0.0, escape-html@1.0.1, parseurl@1.3.0, send@0.10.0)
├── satan@0.4.2 (launchd@0.0.5, whenever@0.0.4, minstache@1.2.0)
├── folder@0.0.4 (batch@0.5.1, negotiator@0.4.9)
├── needle@0.7.10 (iconv-lite@0.4.4)
├── nodemailer@1.3.0 (hyperquest@0.3.0, nodemailer-smtp-transport@0.1.13, nodemailer-direct-transport@1.0.0, buildmail@1.2.0, libmime@0.1.5)
├── buckle@0.0.3 (decompress-zip@0.0.6)
└── entry@0.3.6 (xml2js@0.4.4)
[nemo@Jolla ~]$


nieldk 2015-03-07 16:54

Re: [WIP] Prey - antitheft system
 
A bit more to do.
Here is a more complete guide.

Please not last sentence in this. There is no systemd service at the moment. So, prey will need to be running in terminal until I have worked a bit more.

Code:

$ sudo npm -g install prey
$ sudo prey config hooks post_install
$ sudo prey config account setup -f

yes
your@email.com
prey account password

Code:

$ devel-su
$ su prey
$ prey config activate
$ exit
$ exit


You will need to start prey (I didnt create a systemd service yet)
Code:

$ sudo prey
This should show on panel.preyproject.com now
Until I create a full package, with a systemd service, prey will need to be running in terminal

nieldk 2015-03-07 17:24

Re: [WIP] Prey - antitheft system
 
You are missing some of the steps i posted before. From

$ sudo prey config account setup -f

And down

Api and every other config is then made.
No manual config to edit

Victorious 2015-03-07 17:39

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1463354)
You are missing some of the steps i posted before. From

$ sudo prey config account setup -f

And down

Api and every other config is then made.
No manual config to edit

Thank U! Prey writes:
"Mer 0.2011 Laptop, 1.404 GHz Prey: 1.3.6but Unknown location"
I'm on the internet(A-GPS on) .. maps immediately find location the phone ...

nieldk 2015-03-07 17:43

Re: [WIP] Prey - antitheft system
 
Is prey running in terminal?
Like i said. At the moment it needs to be running in terminal, as no service is created.

nieldk 2015-03-07 17:45

Re: [WIP] Prey - antitheft system
 
@Victorious i appreciate you trying at this stage. Testers are indeed needed to complete this as fast as possible.

Victorious 2015-03-07 18:24

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1463358)
Is prey running in terminal?

Yes - "Unknown location"
Code:

[nemo@Jolla ~]$ sudo prey
nemo's password:

 The Prey agent is running. Good job!
 It has been live for 58.99 minutes, under process ID 5273.
 To trigger actions or retrieve information, log in to your Prey account at https://preyproject.com
 For additional configuration options, please run `prey config`.


nieldk 2015-03-07 18:28

Re: [WIP] Prey - antitheft system
 
Is location enabled for apps ?
SETTINGS->SYSTEM->location

(There is also the setting for A-GPS)

Victorious 2015-03-07 18:31

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1463369)
Is location enabled for apps ?

Yes.
Nokia maps is looking for 2 sec
Strange thing ... I decided to restart the phone ... and the site showed my location ..

nieldk 2015-03-07 18:53

Re: [WIP] Prey - antitheft system
 
Yes. It seems slow on updating.
you can see in terminal if it got posted.


info Sat, 07 Mar 2015 18:49:13 GMT [reports] Report gathered: status
info Sat, 07 Mar 2015 18:49:13 GMT [control-panel] Posting data
info Sat, 07 Mar 2015 18:49:14 GMT [control-panel] Got 200 response: OK

nieldk 2015-03-07 19:10

Re: [WIP] Prey - antitheft system
 
Now. Create a system service
$ devel-su
# nano -w /etc/systemd/system/prey-agent.service

[Unit]
Description=The Prey daemon.
After=network.target
[Service]
ExecStart=/usr/lib/node_modules/prey/bin/prey
WorkingDirectory=/usr/lib/node_modules/prey
Restart=always
RestartSec=15
User=prey
Environment="TERM=dumb" "USER=prey"
KillMode=process
TimeoutStopSec=20
KillSignal=QUIT
[Install]
WantedBy=multi-user.target

And start it
# systemctl start prey-agent

Enable it on boot
# systemctl enable prey-agent

Victorious 2015-03-07 19:11

Re: [WIP] Prey - antitheft system
 
It works now :).

Victorious 2015-03-07 19:22

Re: [WIP] Prey - antitheft system
 
[nemo@Jolla ~]$ devel-su
Password:
[root@Jolla nemo]# systemctl start prey-agent
Warning: Unit file of prey-agent.service changed on disk, 'systemctl daemon-reload' recommended.
[root@Jolla nemo]# systemctl enable prey-agent
[root@Jolla nemo]#

nieldk 2015-03-07 19:53

Re: [WIP] Prey - antitheft system
 
Wonderful!

A lot is missing still.
But, most important is location tracking.
So. I can move on and create a first Alpha package for openrepos :)

Thanks again buddy for helping.

Also. Thank prey guys for making the changes to recignize Jolla on their side.

Victorious 2015-03-07 20:07

Re: [WIP] Prey - antitheft system
 
After rebooting the phone - 10 seconds Prey found my phone and accurately (+ - 5 meters) showed my location! Nothing in the terminal I typed ...

nieldk 2015-03-07 20:16

Re: [WIP] Prey - antitheft system
 
That was the purpose of creating the prey-agent.service ;)

Now. When you set it to missing, you should get a report by email.
Containing
Location
Hardware info
Ip adress
Wifi networks around
And timestamps

Victorious 2015-03-07 20:35

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1463385)
That was the purpose of creating the prey-agent.service ;)

Now. When you set it to missing, you should get a report by email.
Containing
Location
Hardware info
Ip adress
Wifi networks around
And timestamps

Yes, I got all this information! But I disabled "Set device to messing" and after a reboot it immediately shows the location. Five times restarts. I just cant find setting "Report frequency".

nieldk 2015-03-07 20:40

Re: [WIP] Prey - antitheft system
 
Not sure what you are asking ?
It definately is supposed to show you location.

Set device to missing is for mailing the report, once the device is located.

Victorious 2015-03-07 20:42

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1463350)
This should show on panel.preyproject.com now
Until I create a full package, with a systemd service, prey will need to be running in terminal

It is not mandatory - and all so perfectly works!

localhost 2015-04-30 18:37

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by nieldk (Post 1463350)
A bit more to do.
Here is a more complete guide.

Please not last sentence in this. There is no systemd service at the moment. So, prey will need to be running in terminal until I have worked a bit more.

[CODE]$ sudo npm -g install prey
$ sudo prey config hooks post_install

I'm trying to set up prey on my Jolla, but something is failing at the last step above.
Code:

...
Setting permissions on /var/log/prey.log
chowning /var/log/prey.log to uid 996 and gid 991
Running "config activate" as prey
Error! Command failed: /bin/sh -c /usr/bin/node /usr/lib/node_modules/prey/node_modules/ocelot/runner.js prey /usr/lib/node_modules/prey/bin/prey config activate
child_process.js:1162
    throw errnoException(err, 'spawn');
          ^
Error: spawn EACCES
    at exports._errnoException (util.js:746:11)
    at ChildProcess.spawn (child_process.js:1162:11)
    at exports.spawn (child_process.js:995:9)
    at run_command (/usr/lib/node_modules/prey/node_modules/ocelot/runner.js:60:15)
    at Object.<anonymous> (/usr/lib/node_modules/prey/node_modules/ocelot/runner.js:95:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)

Anyone an idea what I'm doing wrong?

localhost 2015-04-30 19:13

Re: [WIP] Prey - antitheft system
 
Got past the issue. Went for:
$ devel-su
$ prey config hooks post_install

Now it's working. Not sure why, but it works ;-)

freehub 2015-07-08 12:54

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by localhost (Post 1469018)
Got past the issue. Went for:
$ devel-su
$ prey config hooks post_install

Now it's working. Not sure why, but it works ;-)

Thank you! Also thanks to nieldk! It works.

The systemd service was running right away. No further action required. Not sure if this was from finishing the post_install command error-free by the method quoted above instead of means by sudo. Or if for instance my previous attempts to get Prey to work with nodejs from the Warehouse repository were responsible.

This time one of nieldk's builds of nodejs from the Mer repository was used: https://build.merproject.org/package...latest_armv7hl

There seems to be an issue with Prey 1.3.9 reporting locations: https://github.com/prey/prey-node-client/issues/95

Installing Prey 1.3.6 worked however:

Code:

$ sudo npm -g install prey@1.3.6
Additional feedback on Prey versions 1.3.7 and 1.3.8 would be most welcome. If someone could test a fresh install from Prey version 1.3.6 upwards and report on its behaviour related to the systemd service it would also be great.

nieldk 2015-07-08 17:04

Re: [WIP] Prey - antitheft system
 
Part of why it works better now, is that the Prey guys made changes so that the Linux version reported by our device is no longer responded to as 'unknown'.
FYI: I know that Jolla guys have also been in touch with the prey guys, so perhaps something is coming along the side that will be more complete.
Will look into the new version of Prey and what the problem is.

Eminem 2015-09-07 18:09

Re: [WIP] Prey - antitheft system
 
Can we / I get a updated and new guide and maybe posted on the first page? :)

nieldk 2015-09-07 19:54

Re: [WIP] Prey - antitheft system
 
Quote:

Originally Posted by Eminem (Post 1481452)
Can we / I get a updated and new guide and maybe posted on the first page? :)

Unfortunately not for this thread, as I no longer 'own' it. But, I suppose a new thread is in place actually...

nieldk 2015-09-09 06:47

Re: [WIP] Prey - antitheft system
 
Created new thread for nodejs based version http://talk.maemo.org/showthread.php?p=1481712


All times are GMT. The time now is 17:39.

vBulletin® Version 3.8.8