Created
November 9, 2016 10:34
Revisions
-
stemid created this gist
Nov 9, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/usr/bin/env bash home_base=/var/sftp test $(id -u $PAM_USER) -gt 500 || exit 1 grep ^{{chroot_openssh_group}} /etc/group | grep -q $PAM_USER || exit 1 _HOME=$(getent passwd $PAM_USER 2>/dev/null | cut -d: -f6 2>/dev/null) if [ -z "$_HOME" ]; then _HOME="/home/$PAM_USER" fi test -d $_HOME || exit 1 if [ ! -d "$home_base/$PAM_USER" ]; then echo "Creating home $home_base/$PAM_USER" mkdir -p "$home_base/$PAM_USER" fi if [ ! -d "$home_base/$PAM_USER/ftp_home" ]; then echo "Creating ftp_home mount point for $PAM_USER" mkdir "$home_base/$PAM_USER/ftp_home" fi if ! mount | grep "$home_base/$PAM_USER/ftp_home type none (rw,bind)" &>/dev/null; then echo "Mounting ftp_home in users ($PAM_USER) sftp-dir " mount -B "$_HOME" "$home_base/$PAM_USER/ftp_home" fi