#!/bin/bash # mkjail # A quick and dirty hack of a script for creating jails. # Copyright 2007, 2008 Daniel Bartholomew ############################################################################### # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . ############################################################################### # Jailkit _must_ be installed for this script to work! Even then it may not. # You can download jailkit from: http://olivier.sessink.nl/jailkit/ # A variable for testing #company=mycompany # Some default variables jailp="/home/jail" # Path to the jails jklsh="etc/jailkit/jk_lsh.ini" # Path to the jk_lsh.ini file in the jails # The script should be run with a single argument following, which should be # the name of the company whose jail you are creating. company=${1} function USAGE { echo echo "Usage: ${0} company_name" echo echo "Example: ${0} widgetworld" echo echo return } if [ ${company} -z ]; then # If the required argument was not supplied, then we quit after # printing out the USAGE message. echo echo echo "You did not enter in a company name." echo USAGE echo exit 1 else # If there is a companyname, we're golden. Go ahead and set things up. groupadd ${company} jk_init ${jailp}/${company} jk_lsh scp sftp echo "[group ${company}]" > ${jailp}/${company}/${jklsh} echo "paths= /usr/bin" >> ${jailp}/${company}/${jklsh} echo -n "executables= /usr/bin/scp, " >> ${jailp}/${company}/${jklsh} echo -n "/usr/lib/sftp-server, " >> ${jailp}/${company}/${jklsh} echo -n "/usr/lib/openssh/sftp-server, " >> ${jailp}/${company}/${jklsh} echo "/usr/libexec/openssh/sftp-server" >> ${jailp}/${company}/${jklsh} fi # I should probably mention that this script ignores all but the first # argument that it sees. Maybe we should complain to the user if that happens, # but for now . . . this is good enough. # Oh, and by the way, we're... echo echo echo "Done." echo