3.3 KiB
Custom Actions
The actions struct inside the "sftpd" configuration section allows to configure the actions for file operations and SSH commands.
Actions will not be executed if an error is detected, and so a partial file is uploaded or an SSH command is not successfully completed. The upload condition includes both uploads to new files and overwrite of existing files. The ssh_cmd condition will be triggered after a command is successfully executed via SSH. scp will trigger the download and upload conditions and not ssh_cmd.
The command, if defined, is invoked with the following arguments:
action, string, possible values are:download,upload,delete,rename,ssh_cmdusernamepathis the full filesystem path, can be empty for some ssh commandstarget_path, non empty forrenameactionssh_cmd, non empty forssh_cmdaction
The command can also read the following environment variables:
SFTPGO_ACTIONSFTPGO_ACTION_USERNAMESFTPGO_ACTION_PATHSFTPGO_ACTION_TARGET, non empty forrenameSFTPGO_ACTIONSFTPGO_ACTION_SSH_CMD, non empty forssh_cmdSFTPGO_ACTIONSFTPGO_ACTION_FILE_SIZE, non empty forupload,downloadanddeleteSFTPGO_ACTIONSFTPGO_ACTION_LOCAL_FILE,trueif the affected file is stored on the local filesystem, otherwisefalse
Previous global environment variables aren't cleared when the script is called.
The command must finish within 30 seconds.
The http_notification_url, if defined, will contain the following, percent encoded, query string parameters:
actionusernamepathlocal_file,trueif the affected file is stored on the local filesystem, otherwisefalsetarget_path, added forrenameactionssh_cmd, added forssh_cmdactionfile_size, added forupload,download,deleteactions
The HTTP request is executed with a 15-second timeout.
The actions struct inside the "data_provider" configuration section allows you to configure actions on user add, update, delete.
Actions will not be fired for internal updates, such as the last login or the user quota fields, or after external authentication.
The command, if defined, is invoked with the following arguments:
action, string, possible values are:add,update,deleteusernameIDstatusexpiration_datehome_diruidgid
The command can also read the following environment variables:
SFTPGO_USER_ACTIONSFTPGO_USER_USERNAMESFTPGO_USER_PASSWORD, hashed password as stored inside the data provider, can be empty if the user does not login using a passwordSFTPGO_USER_IDSFTPGO_USER_STATUSSFTPGO_USER_EXPIRATION_DATESFTPGO_USER_HOME_DIRSFTPGO_USER_UIDSFTPGO_USER_GIDSFTPGO_USER_QUOTA_FILESSFTPGO_USER_QUOTA_SIZESFTPGO_USER_UPLOAD_BANDWIDTHSFTPGO_USER_DOWNLOAD_BANDWIDTHSFTPGO_USER_MAX_SESSIONSSFTPGO_USER_FS_PROVIDER
Previous global environment variables aren't cleared when the script is called.
The command must finish within 15 seconds.
The http_notification_url, if defined, will be called invoked as http POST. The action is added to the query string, for example <http_notification_url>?action=update, and the user is sent serialized as JSON inside the POST body with sensitive fields removed.
The HTTP request is executed with a 15-second timeout.