API backend for Web File Manager

This commit is contained in:
Serghey Rodin 2015-07-16 02:21:22 +03:00
commit 75374e264a
11 changed files with 431 additions and 42 deletions

37
bin/v-add-fs-directory Executable file
View file

@ -0,0 +1,37 @@
#!/bin/bash
# info: add directory
# options: USER DIRECTORY
#
# The function creates new directory on the file system
user=$1
dst_dir=$2
# Checking arguments
if [ -z "$dst_dir" ]; then
echo "Usage: USER DIRECTORY"
exit 1
fi
# Checking vesta user
if [ ! -e "$VESTA/data/users/$user" ]; then
exit 1
fi
# Checking user homedir
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
if [ -z $homedir ]; then
exit 1
fi
# Checking destination path
rpath=$(readlink -f "$dst_dir")
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
exit 1
fi
# Adding directory
sudo -u $user mkdir -p $dst_dir >/dev/null 2>&1
# Extiging
exit $?