Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Where should custom hubot scripts go in a snap installation?

Open cit opened this issue 9 years ago • 14 comments

Hey,

I installed rocket.chat 0.50.1 via snap on Ubuntu 16.04.1 TLS and enabled hubot. It is awesome! Now we would like to add custom hubot scripts to rocket.chat. However, in snap the directory /snap/ is mounted as readonly, so I can't just put new scripts in the hubot-scripts folder. I also tried to put scripts into /var/snap/rocketchat-server/common but this gave me of course the following error:

Jan 25 10:29:09 hostname snap[25485]: can't load lunch.coffee
Jan 25 10:29:09 hostname snap[25485]: { [Error: Cannot find module '/snap/rocketchat-server/451/programs/server/npm/node_modules/meteor/rocketchat_internal-hubot/node_modules/hubot-scripts/src/scripts/lunch.coffee'] code: 'MODULE_NOT_FOUND' }

So, my question is where should custom hubot script go in snap installation? Thanks in advance!

cit avatar Jan 25 '17 09:01 cit

Good point, we need to also look at this on Docker. @graywolf336 @rodrigok any ideas?

engelgabriel avatar Jan 25 '17 22:01 engelgabriel

@geekgonecrazy any idea on how to do on snaps?

engelgabriel avatar Jan 25 '17 22:01 engelgabriel

@engelgabriel

For snaps anywhere relative to the code execution is read only. So if we can't change the path in settings or via environment variable then they couldnt write new files.

These changes would be helpful for Docker as well.

geekgonecrazy avatar Jan 26 '17 04:01 geekgonecrazy

Should we put it inside the uploads folder?

engelgabriel avatar Jan 29 '17 20:01 engelgabriel

At least from a user perspective the upload folder was my first thought. However, maybe to avoid that the common directory gets too messy, I would like to recommend something like this: /var/snap/rocketchat-server/common/hotbot-scripts/

cit avatar Jan 29 '17 22:01 cit

Maybe it would be helpful to have a filestructur similar to the mounted snap folders, which could externd/overwrite files from the mounted folder?

maxdwit avatar Jan 30 '17 06:01 maxdwit

For docker one can add custom scripts with docker cp into the location inside the rocketchat container, but these get deleted with every update via docker pull rocketchat/rocketchat:latest It would be very convenient to be able to store them somewhere more persistent.

ghost avatar Feb 07 '17 02:02 ghost

ref: #7095 as soon as this is merged we can add a folder in snaps for this.

geekgonecrazy avatar May 25 '17 17:05 geekgonecrazy

Is there an update on this? I'm unclear how to do this on 0.57.3

I created a folder /var/snap/rocketchat-server/common/scripts and placed an "example.coffee" in there that should respond to "test" I think.

If I put "example.script" in the scripts field, and then try "test" in a channel with the bot, or @thebot, nothing happens. If I @thebot help I get the basic help text.

If I specify "Folder to load the scripts" as "scripts/" or "common/scripts/" or "/var/snap/rocketchat-server/common/scripts" then the logs complain about not being able to locate example.script.

Where would /var/snap/rocketchat-server/common/scripts be mounted relative to the rocketchat-server snap?

apiontek avatar Aug 10 '17 02:08 apiontek

Hello, I'm running into the same issue where I am not able to add Hubot or GifReply

name: rocketchat-server summary: "Group chat server for 100s, installed in seconds." publisher: rocketchat contact: https://demo.rocket.chat/channel/ubuntu-snap description: | Slack-like online chat server for your office, group or family. Up and running in seconds. Supports file sharing, video conference, geolocation, and much more. Web and mobile client. MIT licensed Open Source project. List of features at https://rocket.chat/ , MIT licensed source code at https://github.com/RocketChat/Rocket.Chat , 24 x 7 community support and demo server at https://demo.rocket.chat/ commands:

  • rocketchat-server.backupdb
  • rocketchat-server.initcaddy
  • rocketchat-server.mongo
  • rocketchat-server.restoredb tracking: stable installed: 0.58.2 (943) 163MB - refreshed: 2017-08-23 04:19:37 +0000 UTC channels:
    stable: 0.58.2 (943) 163MB - candidate: 0.59.0-rc.3 (1012) 174MB - beta: ↑
    edge: 0.59.0-develop (1018) 174MB -

DannyHeal avatar Sep 04 '17 04:09 DannyHeal

I am having the same issue, I cannot get internal-hubot to load custom scripts, or scripts I have modified from the github repository.

ttpars avatar Sep 12 '17 13:09 ttpars

I'm running 0.58.2 and I think I already works since 0.58.0 or earlier. The snaps seem to have security first in mind so there are some restrictions. The directories available are listed here: https://snapcraft.io/docs/reference/confinement So what I've done is to set: Folder to load the scripts: /var/snap/rocketchat-server/hubot/ and put the modified scripts in there. That works for me. (no path given for the scripts, ex: "countdown.coffee,gif-me.coffee,zen.coffee" The logs (/admin/view-logs) show if a script cannot be loaded. It seems the internal Hubot comes with some restrictions or drawbacks. The chat pointed me to https://github.com/RocketChat/botswana-snap - which also looks quite interesting.

wemu avatar Sep 15 '17 22:09 wemu

Thanks for replying. I'll try that out.

Go RocketChat

On Fri, Sep 15, 2017 at 3:30 PM, Werner Mueller [email protected] wrote:

I'm running 0.58.2 and I think I already works since 0.58.0 or earlier. The snaps seem to have security first in mind so there are some restrictions. The directories available are listed here: https://snapcraft.io/docs/reference/confinement So what I've done is to set: Folder to load the scripts: /var/snap/rocketchat-server/hubot/ and put the modified scripts in there. That works for me. (no path given for the scripts, ex: "countdown.coffee,gif-me.coffee,zen.coffee" The logs (/admin/view-logs) show if a script cannot be loaded. It seems the internal Hubot comes with some restrictions or drawbacks. The chat pointed me to https://github.com/RocketChat/botswana-snap - which also looks quite interesting.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/RocketChat/Rocket.Chat/issues/5771#issuecomment-329918733, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac0KjtQPOgMATYe0vmIJfs1r3ii-nJyXks5sivqUgaJpZM4LtQ_e .

--

Danny Patel • Sr. Director of DevOps & IT

[image: HEAL_SIG.gif] https://heal.com/?utm_source-email_signature&utm_medium=logo

heal.com https://heal.com/?utm_source-email_signature&utm_medium=link

-- Disclaimer and Confidentiality Notice: Heal is a technology information service provider that connects users with Heal At-Home Medical to provide medical services in your area. Heal does not provide health care services and shall not be liable for any professional advice from a health care professional that is provided to any user of Heal. The information contained in this transmission may contain privileged or confidential information intended only for use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this transmission in error, do not read it. Please immediately reply to the sender that you have received this communication in error, then delete it. Thank you.

DannyHeal avatar Sep 15 '17 22:09 DannyHeal

Will close this because the referenced PR has been merged and any further updates to the internal hubot script loading can be tracked under #6640.

timkinnane avatar Mar 20 '18 03:03 timkinnane