Initial import
This commit is contained in:
parent
f80c14bf4f
commit
05fb603324
3 changed files with 69 additions and 12 deletions
|
@ -1,8 +1,6 @@
|
|||
FROM stilliard/pure-ftpd
|
||||
FROM vimagick/vsftpd
|
||||
|
||||
RUN mv run.sh /run-pure-ftpd.sh
|
||||
# RUN adduser --help --help
|
||||
ADD run.sh /run.sh
|
||||
|
||||
|
||||
|
||||
|
||||
CMD /run.sh
|
||||
|
|
21
Makefile
Normal file
21
Makefile
Normal file
|
@ -0,0 +1,21 @@
|
|||
|
||||
all: build run
|
||||
|
||||
# --build-arg "BUNDLE_BITBUCKET__ORG=$(BUNDLE_BITBUCKET__ORG)" \
|
||||
|
||||
build:
|
||||
docker build -t dt-service-ftp .
|
||||
|
||||
run:
|
||||
docker stop dt-service-ftp || true
|
||||
docker run --rm \
|
||||
--name dt-service-ftp \
|
||||
-p 21:21 \
|
||||
-p 30000-30009:30000-30009 \
|
||||
-e "PUBLICHOST=localhost" \
|
||||
-e "VSFTP_USER_1_USERNAME=dt-site" \
|
||||
-e "VSFTP_USER_1_PASSWORD=random" \
|
||||
-t dt-service-ftp
|
||||
|
||||
|
||||
|
52
run.sh
52
run.sh
|
@ -1,11 +1,49 @@
|
|||
#!/bin/sh
|
||||
|
||||
pure-pw useradd dt-site \
|
||||
-u 1001 \
|
||||
-g 1001 \
|
||||
-f /etc/pure-ftpd/passwd/pureftpd.passwd \
|
||||
-m \
|
||||
-d /sites/dt-site
|
||||
## Mount directories into /ftp
|
||||
|
||||
exec /run-pure-ftpd.sh -c 30 -C 10 -l puredb:/etc/pure-ftpd/pureftpd.pdb -E -j -R -P $PUBLICHOST -p 30000:30059
|
||||
vsftp_add_user() {
|
||||
local username="$1"
|
||||
local password="$2"
|
||||
echo "Adding user:$username with password:******"
|
||||
mkdir -p "/home/$username"
|
||||
|
||||
# UID 33 is for www-data in WP
|
||||
adduser \
|
||||
-h "/home/$username" \
|
||||
-s /bin/sh \
|
||||
-D \
|
||||
"$username"
|
||||
echo "$username:$password" | chpasswd
|
||||
# GID 33 is for www-data in WP
|
||||
sed -i "s/^$username:x:[0-9]*:[0-9]*:/$username:x:33:33:/" /etc/passwd
|
||||
sed -i "s/^$username:x:[0-9]*:/$username:x:33:/" /etc/group
|
||||
chown "$username:$username" "/home/$username"
|
||||
}
|
||||
|
||||
vsftp_main() {
|
||||
|
||||
# Create users
|
||||
idx=0
|
||||
while true ; do
|
||||
idx=$((idx + 1 ))
|
||||
eval "username=\${VSFTP_USER_${idx}_USERNAME:-}"
|
||||
eval "password=\${VSFTP_USER_${idx}_PASSWORD:-}"
|
||||
if [ -z "$username" ]; then break ; fi
|
||||
vsftp_add_user "$username" "$password"
|
||||
done
|
||||
|
||||
echo "Starting VSFTP"
|
||||
exec vsftpd /etc/vsftpd/vsftpd.conf
|
||||
}
|
||||
|
||||
sed -i \
|
||||
"s/^pasv_address=.*$/pasv_address=${VSFTP_HOSTNAME:-}/" \
|
||||
"s/^anonymous_enable=.*$/anonymous_enable=NO/" \
|
||||
/etc/vsftpd/vsftpd.conf
|
||||
|
||||
{
|
||||
echo "log_ftp_protocol=YES" ;
|
||||
} >> /etc/vsftpd/vsftpd.conf
|
||||
|
||||
vsftp_main
|
||||
|
|
Loading…
Reference in a new issue