Back

[SOLVED] Need help installing a script in a Appwrite Function

  • 0
  • Tools
  • Functions
ianmont
12 Apr, 2023, 19:30

Hello appwrite team, I'm trying to create an appwrite function in python, which executes a command for scanning open ports on a url

Theres a tool for network scanning called "nmap" that allows me to do it, when im in linux i can install it in the terminal using the command:

sudo apt install nmap

And once I have nmap installed, I can run python scripts that use the subprocess library of python to run commands, I'll attach an example of the function I want to achieve and that uses the subprocess thing, so you guys can have an idea:

TL;DR
The user was trying to install the 'nmap' library in an Appwrite Function. They received a response with a list of installed packages, including 'nmap', indicating that the library was successfully installed. The user planned to run the function and provide an update. However, it was mentioned that modifying the Docker file or providing a custom one was not currently possible. The user was recommended to like the related issue on GitHub and explore the possibility of spawning a subprocess to install 'nmap' on function start. It was also suggested to look into installing 'nmap' using Alpine's package manager, as the Appwrite functions run in
ianmont
12 Apr, 2023, 19:30
ianmont
12 Apr, 2023, 19:30

I don't really know where the appwrite functions run, but looking at the documentation it says that they are in an isolated docker container, my question is how can i install nmap in the docker container or wherever the function is so i can run the command nmap in my python script?

thanks !

Drake
12 Apr, 2023, 19:35

Technically, it's not possible to install OS-level dependencies at the moment: https://github.com/appwrite/appwrite/issues/1037. That said...I wonder if you can spawn a sub process to install the program on function start 😅

The containers run in an alpine-based container so you can try to look into installing nmap using alpine's package manager

ianmont
12 Apr, 2023, 20:03

thanks for the response Steven <:appwriterocket:823996226894692403>

In the github link I see that they modify the dockerfile to add the library there, I still don't quite understand very well, but I'll take a look at that

but do you happen to have guidance on how to install libraries using alpine package manager 🤔 , or any clues that might get me close to spawning a subprocess to install 'nmap' on function start by any chance?

Drake
12 Apr, 2023, 20:07

No you can't modify the docker file or provide your own right now. You should 👍 the issue.

Did you try searching for how to do it?

ianmont
12 Apr, 2023, 20:13

thanks, already liked the issue 👍

Currently im trying to do it this way:

I'll let you know if I succeed once I run the function

ianmont
12 Apr, 2023, 20:19

Apparently it worked! I made it return all the installed libraries and among them is nmap

the response:

{"installed_packages":["musl","busybox","alpine-baselayout","alpine-keys","ca-certificates-bundle","libcrypto1.1","libssl1.1","libretls","ssl_client","zlib","apk-tools","scanelf","musl-utils","libc-utils","ca-certificates","tzdata","ncurses-terminfo-base","ncurses-libs","libbz2","sqlite-libs","libffi","gdbm","xz-libs","expat","libintl","libtirpc-conf","krb5-conf","libcom_err","keyutils-libs","libverto","krb5-libs","libtirpc","libnsl","libuuid","readline",".python-rundeps","libgcc","lua5.3-libs","libpcap","pcre","libssh2","libstdc++","nmap"]}

I have not tried running nmap yet but for now It seems that the library was installed 👍

joeyouss
24 Apr, 2023, 07:47

Hi @ianmont - is this solved? do you need more help with this?

ianmont
24 Apr, 2023, 16:01

its solved

ianmont
24 Apr, 2023, 16:01

[SOLVED] Need help installing a script in a Appwrite Function

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more