#ftp 服务
eg:
version: "3.7"
services:
ftp:
image: stilliard/pure-ftpd
container_name: pure-ftpd
volumes:
- /opt/www:/home/ftpusers/code
- ./pure-ftpd:/etc/pure-ftpd
ports:
- "21:21"
- "30000-30009:30000-30009"
environment:
PUBLICHOST: localhost
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost"]
interval: 1m30s
timeout: 10s
retries: 3
start_period: 40s
#ftp密码shell
eg:
#!/bin/bash
#-o表示短选项,两个冒号表示该选项有一个可选参数,可选参数必须紧贴选项
#如-carg 而不能是-c arg
#--long表示长选项
#"$@"在上面解释过
# -n:出错时的信息
# -- :举一个例子比较好理解:
#我们要创建一个名字为 "-f"的目录你会怎么办?
# mkdir -f #不成功,因为-f会被mkdir当作选项来解析,这时就可以使用
# mkdir -- -f 这样-f就不会被作为选项。
temp=`getopt -o u:p:P: --long user:,password:,path: \
-n 'example.bash' -- "$@"`
if [ $? != 0 ] ; then echo "terminating..." >&2 ; exit 1 ; fi
# note the quotes around `$temp': they are essential!
#set 会重新排列参数的顺序,也就是改变$1,$2...$n的值,这些值在getopt中重新排列过了
eval set -- "$temp"
#经过getopt的处理,下面处理具体选项。
user="code"
password="123456"
path="/home/ftpusers/code"
while true ; do
case "$1" in
-u|--user) user=$2; shift 2 ;;
-p|--password) password=$2; shift 2 ;;
-P|--path) path=$2; shift 2 ;;
--) shift ; break ;;
*) echo "internal error!" ; exit 1 ;;
esac
done
#建立用户
#echo pure-pw useradd $user -u ftpuser -d $path
(echo $password; echo $password) | pure-pw useradd code -d $path -u ftpuser
#保存
#echo pure-pw mkdb
pure-pw mkdb
参考文献: