Variables used for ftp_upload.php, ftp_list.php & ftp_download.php

realcryptonight

Verified User
Joined
Nov 16, 2019
Messages
390
Hello everyone,

I am currently working on a backup and restore script for the admin backups/restore that allows me to work with S3 storage.
I have it all working. (Exept for the download as that one is php based instead of shell/bash based.)

My script are currently working by adding it in the custom script folder and adding code to the existing ftp files.
This has the disadvantage that everytime DirectAdmin updates the ftp scripts it will not update my custom script with there changes.

That is why I would like to have my scripts check if port 443 is set as port and if not trigger the none custom script to handle the rest.
The only problem with this option (for as far as I can see at the moment) is that when I want to call the none custom scripts I need to give it a couple of variables.

So my question is:
Does anyone know what the names are from all the external variables passed to the ftp_upload.php, ftp_list.php and ftp_download.php files?
And also suggestions for this approuche are also welcome. :)
 
Last edited:

realcryptonight

Verified User
Joined
Nov 16, 2019
Messages
390
Hello,

You might check scripts here https://github.com/poralix/directadmin-sftp-backups I did the same in order to add sFTP support.

p.s. and they are BASH scripts in files with extension .php
Thanks,

At the moment my script works the same as poralix but I would like to change it to checking if port 443 is not used and if so then call the original script from DirectAdmin itself.
This way I can just not update the script but still get the DirectAdmin updates to the script. (Since I use both FTP and S3 for backups.)

I also know they are bash but the upload script calls for php and not bash. (And that is why the download script is a nightmare to change as i need bash for S3 but I do not want to lose the functions that DirectAdmin already provides.)
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,739
Location
GMT +7.00
Something like this:

Code:
# export vars
...
...
...

# check port
if [ "${PORT}" == "443" ];
then
  # run a custom script
  bash /usr/local/directadmin/scripts/custom/s3/script.sh
else
  # run a default DA script
  bash /usr/local/directadmin/scripts/native_da_script.sh
fi;

That's a raw idea, and it's up to you to adjust to fit your needs.
 

realcryptonight

Verified User
Joined
Nov 16, 2019
Messages
390
Sorry for my late reply.

I have tried just calling the original script after checking that the port is not 443 but then I get the following error in my log:
Jan 15 00:55:47 **My DA domain name** directadmin[771775]: bash: /usr/local/directadmin/scripts/ftp_list.php: Permission denied
 

realcryptonight

Verified User
Joined
Nov 16, 2019
Messages
390
chmod 755 /usr/local/directadmin/scripts/ftp_list.php ?
I was thinking about that but that would not survive a DA/CB update?

EDIT:
And would the custom script not run under the diradmin:diradmin?
Because if so then it should have sufficient permissions.
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
14,739
Location
GMT +7.00
I believe all scripts `/usr/local/directadmin/scripts/` should be executable by default and with every upgrade of directadmin, so it should be fine.
 

realcryptonight

Verified User
Joined
Nov 16, 2019
Messages
390
I believe all scripts `/usr/local/directadmin/scripts/` should be executable by default and with every upgrade of directadmin, so it should be fine.
I don’t think so, since my servers where installed just days before I make the scripts.
So to my it looks like the scripts cannot be called via custom script by default.
 
Top