mirror of
https://github.com/myvesta/vesta
synced 2025-08-14 18:49:21 -07:00
API backend for Web File Manager
This commit is contained in:
parent
edcd549e4c
commit
75374e264a
11 changed files with 431 additions and 42 deletions
49
bin/v-copy-fs-directory
Executable file
49
bin/v-copy-fs-directory
Executable file
|
@ -0,0 +1,49 @@
|
|||
#!/bin/bash
|
||||
# info: copy directory
|
||||
# options: USER SRC_DIRECTORY DST_DIRECTORY
|
||||
#
|
||||
# The function copies directory on the file system
|
||||
|
||||
user=$1
|
||||
src_dir=$2
|
||||
dst_dir=$3
|
||||
|
||||
# Checking arguments
|
||||
if [ -z "$dst_dir" ]; then
|
||||
echo "Usage: USER SRC_DIRECTORY DST_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 source dir
|
||||
if [ ! -e "$src_dir" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking source path
|
||||
rpath=$(readlink -f "$src_dir")
|
||||
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking destination path
|
||||
rpath=$(readlink -f "$dst_dir")
|
||||
if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Copying directory
|
||||
sudo -u $user cp -r $src_dir $dst_dir >/dev/null 2>&1
|
||||
|
||||
# Exiting
|
||||
exit $?
|
Loading…
Add table
Add a link
Reference in a new issue