mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 18:49:17 -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
|
@ -1,5 +1,8 @@
|
|||
#!/bin/bash
|
||||
# File list wrapper
|
||||
# info: list directory
|
||||
# options: USER DIRECTORY
|
||||
#
|
||||
# The function lists directory on the file system
|
||||
|
||||
user=$1
|
||||
path=$2
|
||||
|
@ -10,12 +13,12 @@ if [ -z "$user" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Checking users
|
||||
# Checking vesta user
|
||||
if [ ! -e "$VESTA/data/users/$user" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Checking homedir
|
||||
# Checking user homedir
|
||||
homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
|
||||
if [ -z $homedir ]; then
|
||||
exit 1
|
||||
|
@ -23,7 +26,6 @@ fi
|
|||
|
||||
# Checking path
|
||||
if [ ! -z "$path" ]; then
|
||||
# Validating absolute path
|
||||
rpath=$(readlink -f "$path")
|
||||
if [ -z "$(echo $rpath |grep $homedir)" ]; then
|
||||
exit 1
|
||||
|
@ -32,8 +34,9 @@ else
|
|||
path=$homedir
|
||||
fi
|
||||
|
||||
# Listing files
|
||||
find "$path" -maxdepth 1 -printf "%y|%m|%TY-%Tm-%Td|%TH:%TM:%TS|%u|%g|%s|%P\n"
|
||||
# Listing directory
|
||||
sudo -u $user find "$path" -maxdepth 1 \
|
||||
-printf "%y|%m|%TY-%Tm-%Td|%TH:%TM:%TS|%u|%g|%s|%P\n" 2>/dev/null
|
||||
|
||||
|
||||
exit
|
||||
# Exiting
|
||||
exit $?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue