Skip to content

Instantly share code, notes, and snippets.

@ctrlcctrlv
Created October 19, 2020 02:00
Show Gist options
  • Select an option

  • Save ctrlcctrlv/fa19e7bbb1e594cd2fb96e7690f90d94 to your computer and use it in GitHub Desktop.

Select an option

Save ctrlcctrlv/fa19e7bbb1e594cd2fb96e7690f90d94 to your computer and use it in GitHub Desktop.
Launch an FTP server for each drive letter (MSYS2 / pyftpdlib)
#!/bin/bash
# A problem I commonly experience on Windows is wanting to access all files via
# another computer on the network running Linux or a phone running Android.
#
# While it is technically possible to use Samba shares, this is annoying to set
# up. Usually I just spawn FTP servers. But an annoying thing about Windows is
# its concept of multiple roots. While it's also possible to "mount" a drive
# letter under C:\ in Windows I think, this is also annoying to set up.
#
# So, I use this script. Running as:
#
# $ ./ftp_servers_launch.sh risingsun
#
# Will start FTP servers for each drive letter with the password "risingsun".
# Requires MSYS2 and pyftpdlib be installed. (/usr/bin/pip3.8 install
# pyftpdlib)
#
# (3.8 is Python3 version.)
DRIVES=(a b c d e f g h i j k l m n o p q r s t u v w x y z)
if [ -z "$1" ]; then
>&2 echo "No password supplied!"
exit 1
fi
NUMDRIVES=0
for DRIVE in ${DRIVES[@]}; do
if [ -d /$DRIVE ]; then
echo /usr/bin/python3.8 -m pyftpdlib -p $((3000+$NUMDRIVES)) -d /$DRIVE/ -i 0.0.0.0 -u $DRIVE -P "$1" '&'
/usr/bin/python3.8 -m pyftpdlib -p $((3000+$NUMDRIVES)) -d /$DRIVE/ -i 0.0.0.0 -u $DRIVE -P "$1" &
NUMDRIVES=$((NUMDRIVES+1))
echo Spawned : $!
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment