Add to Favourites Add to Favourites    Print this Article Print this Article

How to make all files uploaded through the Filemanager chmod to 700

To alter a file uploaded through the filemanager, create the script:

/usr/local/directadmin/scripts/custom/all_post.sh

In it, put:

#!/bin/sh

CHMODVAL=700
ULPATH=/home/${username}${path}

setfile() {
  if [ "$1" = "" ]; then
    return;
  fi

  F=`echo $1 | cut -d/ -f4 | awk '{ print substr($1,1,length($1)-6) }'`

  chmod ${CHMODVAL} ${ULPATH}${F}
}

TMP=/tmp/txt.txt
if [ "$command" = "/CMD_FILE_MANAGER/" ] || [ "$command" = "/CMD_FILE_MANAGER" ]; then
  if [ "$action" = "upload" ]; then

    setfile $file1
    setfile $file2
    setfile $file3
    setfile $file4
    setfile $file5
    setfile $file6
    setfile $file7
    setfile $file8
  fi
fi

exit 0;

Save, exit, and chmod the all_post.sh to 755.

Was this answer helpful?

Also Read