mirror of
https://github.com/atmoz/sftp.git
synced 2024-11-24 12:59:24 -05:00
Checking parameters and showing help
This commit is contained in:
parent
d1965cdd84
commit
1e506399b9
3 changed files with 17 additions and 3 deletions
|
@ -1,2 +1 @@
|
|||
.git
|
||||
.README.md
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
FROM debian:wheezy
|
||||
MAINTAINER Adrian Dvergsdal [atmoz.net]
|
||||
|
||||
# Install OpenSSH
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get -y install openssh-server && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
@ -9,9 +8,9 @@ RUN apt-get update && \
|
|||
# sshd needs this directory to run
|
||||
RUN mkdir -p /var/run/sshd
|
||||
|
||||
# Copy configuration and entrypoint script
|
||||
COPY sshd_config /etc/ssh/sshd_config
|
||||
COPY entrypoint /
|
||||
COPY README.md /
|
||||
|
||||
EXPOSE 22
|
||||
|
||||
|
|
16
entrypoint
16
entrypoint
|
@ -1,10 +1,26 @@
|
|||
#!/bin/bash
|
||||
|
||||
if [ $1 == "--readme" ]; then
|
||||
cat /README.md
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [[ -z $1 || $1 =~ ^--help$|^-h$ ]]; then
|
||||
echo "Syntax: user:pass[:e][:[uid][:gid]]..."
|
||||
echo "Use --readme for information and examples."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
for users in "$@"; do
|
||||
IFS=':' read -a data <<< "$users"
|
||||
user="${data[0]}"
|
||||
pass="${data[1]}"
|
||||
|
||||
if [ -z "$user" -o -z "$pass" ]; then
|
||||
echo "You must at least provide a username and a password."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ "${data[2]}" == "e" ]; then
|
||||
chpasswdOptions="-e"
|
||||
uid="${data[3]}"
|
||||
|
|
Loading…
Reference in a new issue