Scripts/SimpleFTP/SimpleFTP.ps1

26 lines
569 B
PowerShell
Raw Normal View History

param (
[int] [alias('p')] $port = 21,
[string] [alias('d')] $directory = '.',
[bool] [alias('w')] $write = $false
)
$venv = "\.pyftplib"
$venv = $HOME + $venv
2023-11-13 23:26:00 -04:00
# Create virtual environment
if (-not (Test-Path $venv)) {
write-host "Creating virtual environment at $venv"
virtualenv "$venv"
2023-11-13 23:26:00 -04:00
}
# Activate virtual environment
. ($venv + "\Scripts\Activate.ps1")
2023-11-13 23:26:00 -04:00
# Install dependencies
pip install pyftpdlib
# Run FTP server
if ($write) {
python -m pyftpdlib -p $port -d $directory -w
} else {
python -m pyftpdlib -p $port -d $directory
}