diff --git a/install/existing_db.sql b/install/existing_db.sql
new file mode 100644
index 0000000000000000000000000000000000000000..0ed379be4377cea7949b5b23b9a8d12395a549d0
--- /dev/null
+++ b/install/existing_db.sql
@@ -0,0 +1,306 @@
+-- MySQL dump 10.11
+--
+-- Host: localhost    Database: dbispconfig
+-- ------------------------------------------------------
+-- Server version	5.0.51a-3ubuntu5
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8 */;
+/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
+/*!40103 SET TIME_ZONE='+00:00' */;
+/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
+/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
+/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
+/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
+
+--
+-- Dumping data for table `attempts_login`
+--
+
+LOCK TABLES `attempts_login` WRITE;
+/*!40000 ALTER TABLE `attempts_login` DISABLE KEYS */;
+/*!40000 ALTER TABLE `attempts_login` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `client`
+--
+
+LOCK TABLES `client` WRITE;
+/*!40000 ALTER TABLE `client` DISABLE KEYS */;
+INSERT INTO `client` (`client_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `company_name`, `contact_name`, `street`, `zip`, `city`, `state`, `country`, `telephone`, `mobile`, `fax`, `email`, `internet`, `icq`, `notes`, `default_mailserver`, `limit_maildomain`, `limit_mailbox`, `limit_mailalias`, `limit_mailforward`, `limit_mailcatchall`, `limit_mailrouting`, `limit_mailfilter`, `limit_fetchmail`, `limit_mailquota`, `limit_spamfilter_wblist`, `limit_spamfilter_user`, `limit_spamfilter_policy`, `default_webserver`, `limit_web_ip`, `limit_web_domain`, `limit_web_subdomain`, `limit_web_aliasdomain`, `limit_ftp_user`, `limit_shell_user`, `default_dnsserver`, `limit_dns_zone`, `limit_dns_record`, `limit_client`, `parent_client_id`, `username`, `password`, `language`, `usertheme`) VALUES (1,1,1,'riud','riud','','','Daniel Rossi','','','','','','','','','','http://','','',1,-1,-1,-1,-1,-1,0,-1,-1,-1,0,0,0,1,NULL,-1,-1,-1,-1,0,1,-1,-1,0,0,'danielr','4afc1f4d0d0b0ead0738753c382bc02d','en','default');
+/*!40000 ALTER TABLE `client` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `dns_rr`
+--
+
+LOCK TABLES `dns_rr` WRITE;
+/*!40000 ALTER TABLE `dns_rr` DISABLE KEYS */;
+/*!40000 ALTER TABLE `dns_rr` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `dns_soa`
+--
+
+LOCK TABLES `dns_soa` WRITE;
+/*!40000 ALTER TABLE `dns_soa` DISABLE KEYS */;
+/*!40000 ALTER TABLE `dns_soa` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `ftp_user`
+--
+
+LOCK TABLES `ftp_user` WRITE;
+/*!40000 ALTER TABLE `ftp_user` DISABLE KEYS */;
+/*!40000 ALTER TABLE `ftp_user` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_access`
+--
+
+LOCK TABLES `mail_access` WRITE;
+/*!40000 ALTER TABLE `mail_access` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_access` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_content_filter`
+--
+
+LOCK TABLES `mail_content_filter` WRITE;
+/*!40000 ALTER TABLE `mail_content_filter` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_content_filter` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_domain`
+--
+
+LOCK TABLES `mail_domain` WRITE;
+/*!40000 ALTER TABLE `mail_domain` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_domain` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_forwarding`
+--
+
+LOCK TABLES `mail_forwarding` WRITE;
+/*!40000 ALTER TABLE `mail_forwarding` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_forwarding` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_get`
+--
+
+LOCK TABLES `mail_get` WRITE;
+/*!40000 ALTER TABLE `mail_get` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_get` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_greylist`
+--
+
+LOCK TABLES `mail_greylist` WRITE;
+/*!40000 ALTER TABLE `mail_greylist` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_greylist` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_mailman_domain`
+--
+
+LOCK TABLES `mail_mailman_domain` WRITE;
+/*!40000 ALTER TABLE `mail_mailman_domain` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_mailman_domain` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_traffic`
+--
+
+LOCK TABLES `mail_traffic` WRITE;
+/*!40000 ALTER TABLE `mail_traffic` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_traffic` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_transport`
+--
+
+LOCK TABLES `mail_transport` WRITE;
+/*!40000 ALTER TABLE `mail_transport` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_transport` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `mail_user`
+--
+
+LOCK TABLES `mail_user` WRITE;
+/*!40000 ALTER TABLE `mail_user` DISABLE KEYS */;
+/*!40000 ALTER TABLE `mail_user` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `remote_session`
+--
+
+LOCK TABLES `remote_session` WRITE;
+/*!40000 ALTER TABLE `remote_session` DISABLE KEYS */;
+/*!40000 ALTER TABLE `remote_session` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `remote_user`
+--
+
+LOCK TABLES `remote_user` WRITE;
+/*!40000 ALTER TABLE `remote_user` DISABLE KEYS */;
+/*!40000 ALTER TABLE `remote_user` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `server`
+--
+
+LOCK TABLES `server` WRITE;
+/*!40000 ALTER TABLE `server` DISABLE KEYS */;
+INSERT INTO `server` (`server_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_name`, `mail_server`, `web_server`, `dns_server`, `file_server`, `db_server`, `vserver_server`, `config`, `updated`, `active`) VALUES (1,1,1,'riud','riud','r','Kubuntu',1,1,1,1,1,1,'[global]\nwebserver=apache\nmailserver=postfix\ndnsserver=mydns\n\n[server]\nip_address=192.168.0.105\nnetmask=255.255.255.0\ngateway=192.168.0.1\nhostname=server1.example.com\nnameservers=193.174.32.18,145.253.2.75\n\n[mail]\nmodule=postfix_mysql\nmaildir_path=/home/vmail/[domain]/[localpart]/\nhomedir_path=/home/vmail/\nmailuser_uid=5000\nmailuser_gid=5000\nmailuser_name=vmail\nmailuser_group=vmail\nrelayhost=\nrelayhost_user=\nrelayhost_password=\nmailbox_size_limit=0\nmessage_size_limit=0\n\n[getmail]\ngetmail_config_dir=/etc/getmail\n\n[web]\nwebsite_path=/var/clients/client[client_id]/web[website_id]\nwebsite_symlinks=/var/www/[website_domain]/:/var/clients/client[client_id]/[website_domain]/\nvhost_conf_dir=/etc/apache2/sites-available\nvhost_conf_enabled_dir=/etc/apache2/sites-enabled\n\n[fastcgi]\nfastcgi_starter_path=/var/www/php-fcgi-scripts/[system_user]/\nfastcgi_starter_script=.php-fcgi-starter\nfastcgi_alias=/php/\nfastcgi_phpini_path=/etc/php5/cgi/\nfastcgi_children=8\nfastcgi_max_requests=5000\nfastcgi_bin=/usr/bin/php-cgi\n\n[jailkit]\njailkit_chroot_home=/home/[username]\njailkit_chroot_app_sections=basicshell editors extendedshell netutils ssh sftp scp groups jk_lsh\njailkit_chroot_app_programs=/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico\n',0,1);
+/*!40000 ALTER TABLE `server` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `server_ip`
+--
+
+LOCK TABLES `server_ip` WRITE;
+/*!40000 ALTER TABLE `server_ip` DISABLE KEYS */;
+INSERT INTO `server_ip` (`server_ip_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `ip_address`, `virtualhost`) VALUES (1,1,1,'riud','riud','',1,'192.168.5.101','y');
+/*!40000 ALTER TABLE `server_ip` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `shell_user`
+--
+
+LOCK TABLES `shell_user` WRITE;
+/*!40000 ALTER TABLE `shell_user` DISABLE KEYS */;
+INSERT INTO `shell_user` (`shell_user_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `parent_domain_id`, `username`, `password`, `quota_size`, `active`, `puser`, `pgroup`, `shell`, `dir`, `chroot`) VALUES (15,1,1,'riud','riud','',1,6,'danweb','$1$UTue}CsC$kuZQQXa6ZeuSBEOrk7LNy1',-1,'y','web6','client0','/bin/bash','/var/clients/client0/web6','jailkit');
+/*!40000 ALTER TABLE `shell_user` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `spamfilter_policy`
+--
+
+LOCK TABLES `spamfilter_policy` WRITE;
+/*!40000 ALTER TABLE `spamfilter_policy` DISABLE KEYS */;
+INSERT INTO `spamfilter_policy` (`id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `policy_name`, `virus_lover`, `spam_lover`, `banned_files_lover`, `bad_header_lover`, `bypass_virus_checks`, `bypass_spam_checks`, `bypass_banned_checks`, `bypass_header_checks`, `spam_modifies_subj`, `virus_quarantine_to`, `spam_quarantine_to`, `banned_quarantine_to`, `bad_header_quarantine_to`, `clean_quarantine_to`, `other_quarantine_to`, `spam_tag_level`, `spam_tag2_level`, `spam_kill_level`, `spam_dsn_cutoff_level`, `spam_quarantine_cutoff_level`, `addr_extension_virus`, `addr_extension_spam`, `addr_extension_banned`, `addr_extension_bad_header`, `warnvirusrecip`, `warnbannedrecip`, `warnbadhrecip`, `newvirus_admin`, `virus_admin`, `banned_admin`, `bad_header_admin`, `spam_admin`, `spam_subject_tag`, `spam_subject_tag2`, `message_size_limit`, `banned_rulenames`) VALUES (1,1,0,'riud','riud','r','Non-paying','N','N','N','N','Y','Y','Y','N','Y','','','','','','',3,7,10,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),(2,1,0,'riud','riud','r','Uncensored','Y','Y','Y','Y','N','N','N','N','N',NULL,NULL,NULL,NULL,NULL,NULL,3,999,999,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),(3,1,0,'riud','riud','r','Wants all spam','N','Y','N','N','N','N','N','N','Y',NULL,NULL,NULL,NULL,NULL,NULL,3,999,999,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),(4,1,0,'riud','riud','r','Wants viruses','Y','N','Y','Y','N','N','N','N','Y',NULL,NULL,NULL,NULL,NULL,NULL,3,6.9,6.9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),(5,1,0,'riud','riud','r','Normal','N','N','N','N','N','N','N','N','Y',NULL,NULL,NULL,NULL,NULL,NULL,3,6.9,6.9,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),(6,1,0,'riud','riud','r','Trigger happy','N','N','N','N','N','N','N','N','Y',NULL,NULL,NULL,NULL,NULL,NULL,3,5,5,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL),(7,1,0,'riud','riud','r','Permissive','N','N','N','Y','N','N','N','N','Y',NULL,NULL,NULL,NULL,NULL,NULL,3,10,20,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL);
+/*!40000 ALTER TABLE `spamfilter_policy` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `spamfilter_users`
+--
+
+LOCK TABLES `spamfilter_users` WRITE;
+/*!40000 ALTER TABLE `spamfilter_users` DISABLE KEYS */;
+/*!40000 ALTER TABLE `spamfilter_users` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `spamfilter_wblist`
+--
+
+LOCK TABLES `spamfilter_wblist` WRITE;
+/*!40000 ALTER TABLE `spamfilter_wblist` DISABLE KEYS */;
+/*!40000 ALTER TABLE `spamfilter_wblist` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `support_message`
+--
+
+LOCK TABLES `support_message` WRITE;
+/*!40000 ALTER TABLE `support_message` DISABLE KEYS */;
+/*!40000 ALTER TABLE `support_message` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `sys_datalog`
+--
+
+LOCK TABLES `sys_datalog` WRITE;
+/*!40000 ALTER TABLE `sys_datalog` DISABLE KEYS */;
+INSERT INTO `sys_datalog` (`datalog_id`, `server_id`, `dbtable`, `dbidx`, `action`, `tstamp`, `user`, `data`) VALUES (1,0,'client','client_id:1','i',1212765060,'admin','a:2:{s:3:\"new\";a:49:{s:9:\"client_id\";s:1:\"1\";s:10:\"sys_userid\";s:1:\"1\";s:11:\"sys_groupid\";s:1:\"1\";s:13:\"sys_perm_user\";s:4:\"riud\";s:14:\"sys_perm_group\";s:4:\"riud\";s:14:\"sys_perm_other\";s:0:\"\";s:12:\"company_name\";s:0:\"\";s:12:\"contact_name\";s:12:\"Daniel Rossi\";s:6:\"street\";s:0:\"\";s:3:\"zip\";s:0:\"\";s:4:\"city\";s:0:\"\";s:5:\"state\";s:0:\"\";s:7:\"country\";s:0:\"\";s:9:\"telephone\";s:0:\"\";s:6:\"mobile\";s:0:\"\";s:3:\"fax\";s:0:\"\";s:5:\"email\";s:0:\"\";s:8:\"internet\";s:7:\"http://\";s:3:\"icq\";s:0:\"\";s:5:\"notes\";s:0:\"\";s:18:\"default_mailserver\";s:1:\"1\";s:16:\"limit_maildomain\";s:2:\"-1\";s:13:\"limit_mailbox\";s:2:\"-1\";s:15:\"limit_mailalias\";s:2:\"-1\";s:17:\"limit_mailforward\";s:2:\"-1\";s:18:\"limit_mailcatchall\";s:2:\"-1\";s:17:\"limit_mailrouting\";s:1:\"0\";s:16:\"limit_mailfilter\";s:2:\"-1\";s:15:\"limit_fetchmail\";s:2:\"-1\";s:15:\"limit_mailquota\";s:2:\"-1\";s:23:\"limit_spamfilter_wblist\";s:1:\"0\";s:21:\"limit_spamfilter_user\";s:1:\"0\";s:23:\"limit_spamfilter_policy\";s:1:\"0\";s:17:\"default_webserver\";s:1:\"1\";s:12:\"limit_web_ip\";N;s:16:\"limit_web_domain\";s:2:\"-1\";s:19:\"limit_web_subdomain\";s:2:\"-1\";s:21:\"limit_web_aliasdomain\";s:2:\"-1\";s:14:\"limit_ftp_user\";s:2:\"-1\";s:16:\"limit_shell_user\";s:1:\"0\";s:17:\"default_dnsserver\";s:1:\"1\";s:14:\"limit_dns_zone\";s:2:\"-1\";s:16:\"limit_dns_record\";s:2:\"-1\";s:12:\"limit_client\";s:1:\"0\";s:16:\"parent_client_id\";s:1:\"0\";s:8:\"username\";s:7:\"danielr\";s:8:\"password\";s:32:\"4afc1f4d0d0b0ead0738753c382bc02d\";s:8:\"language\";s:2:\"en\";s:9:\"usertheme\";s:7:\"default\";}s:3:\"old\";a:49:{s:9:\"client_id\";N;s:10:\"sys_userid\";N;s:11:\"sys_groupid\";N;s:13:\"sys_perm_user\";N;s:14:\"sys_perm_group\";N;s:14:\"sys_perm_other\";s:0:\"\";s:12:\"company_name\";s:0:\"\";s:12:\"contact_name\";N;s:6:\"street\";s:0:\"\";s:3:\"zip\";s:0:\"\";s:4:\"city\";s:0:\"\";s:5:\"state\";s:0:\"\";s:7:\"country\";s:0:\"\";s:9:\"telephone\";s:0:\"\";s:6:\"mobile\";s:0:\"\";s:3:\"fax\";s:0:\"\";s:5:\"email\";s:0:\"\";s:8:\"internet\";N;s:3:\"icq\";s:0:\"\";s:5:\"notes\";s:0:\"\";s:18:\"default_mailserver\";N;s:16:\"limit_maildomain\";N;s:13:\"limit_mailbox\";N;s:15:\"limit_mailalias\";N;s:17:\"limit_mailforward\";N;s:18:\"limit_mailcatchall\";N;s:17:\"limit_mailrouting\";N;s:16:\"limit_mailfilter\";N;s:15:\"limit_fetchmail\";N;s:15:\"limit_mailquota\";N;s:23:\"limit_spamfilter_wblist\";N;s:21:\"limit_spamfilter_user\";N;s:23:\"limit_spamfilter_policy\";N;s:17:\"default_webserver\";N;s:12:\"limit_web_ip\";N;s:16:\"limit_web_domain\";N;s:19:\"limit_web_subdomain\";N;s:21:\"limit_web_aliasdomain\";N;s:14:\"limit_ftp_user\";N;s:16:\"limit_shell_user\";N;s:17:\"default_dnsserver\";N;s:14:\"limit_dns_zone\";N;s:16:\"limit_dns_record\";N;s:12:\"limit_client\";N;s:16:\"parent_client_id\";N;s:8:\"username\";N;s:8:\"password\";N;s:8:\"language\";N;s:9:\"usertheme\";N;}}');
+/*!40000 ALTER TABLE `sys_datalog` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `sys_dbsync`
+--
+
+LOCK TABLES `sys_dbsync` WRITE;
+/*!40000 ALTER TABLE `sys_dbsync` DISABLE KEYS */;
+/*!40000 ALTER TABLE `sys_dbsync` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `sys_filesync`
+--
+
+LOCK TABLES `sys_filesync` WRITE;
+/*!40000 ALTER TABLE `sys_filesync` DISABLE KEYS */;
+/*!40000 ALTER TABLE `sys_filesync` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `sys_group`
+--
+
+LOCK TABLES `sys_group` WRITE;
+/*!40000 ALTER TABLE `sys_group` DISABLE KEYS */;
+INSERT INTO `sys_group` (`groupid`, `name`, `description`, `client_id`) VALUES (1,'admin','Administrators group',0),(4,'danielr','',1);
+/*!40000 ALTER TABLE `sys_group` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `sys_user`
+--
+
+LOCK TABLES `sys_user` WRITE;
+/*!40000 ALTER TABLE `sys_user` DISABLE KEYS */;
+INSERT INTO `sys_user` (`userid`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `username`, `passwort`, `modules`, `startmodule`, `app_theme`, `typ`, `active`, `language`, `groups`, `default_group`, `client_id`) VALUES (1,1,0,'riud','riud','','admin','21232f297a57a5a743894a0e4a801fc3','admin,client,mail,monitor,sites,dns','mail','default','admin',1,'en','1,2',1,0),(3,1,1,'riud','riud','','danielr','4afc1f4d0d0b0ead0738753c382bc02d','mail,sites,dns','mail','default','user',1,'en','4',4,1);
+/*!40000 ALTER TABLE `sys_user` ENABLE KEYS */;
+UNLOCK TABLES;
+
+--
+-- Dumping data for table `web_domain`
+--
+
+LOCK TABLES `web_domain` WRITE;
+/*!40000 ALTER TABLE `web_domain` DISABLE KEYS */;
+INSERT INTO `web_domain` (`domain_id`, `sys_userid`, `sys_groupid`, `sys_perm_user`, `sys_perm_group`, `sys_perm_other`, `server_id`, `ip_address`, `domain`, `type`, `parent_domain_id`, `vhost_type`, `document_root`, `system_user`, `system_group`, `hd_quota`, `traffic_quota`, `cgi`, `ssi`, `suexec`, `php`, `redirect_type`, `redirect_path`, `ssl`, `ssl_state`, `ssl_locality`, `ssl_organisation`, `ssl_organisation_unit`, `ssl_country`, `ssl_request`, `ssl_cert`, `ssl_bundle`, `ssl_action`, `apache_directives`, `active`) VALUES (6,1,4,'riud','ru','',1,'192.168.5.101','test.com','vhost',0,'name','/var/clients/client0/web6','web6','client0',-1,-1,'y','y','y','fast-cgi',NULL,NULL,'y',NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'y');
+/*!40000 ALTER TABLE `web_domain` ENABLE KEYS */;
+UNLOCK TABLES;
+/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
+
+/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
+/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
+/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
+/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
+
+-- Dump completed on 2008-06-06 18:06:32
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index cad13a5ba4925accfce41bc51f9ff730f0382037..764c8ef8dc35f94adbb4447ed44b0c58b785b8d9 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -624,7 +624,7 @@ class installer_base {
 			if ($dh = opendir($dir)) {
 				while (($file = readdir($dh)) !== false) {
 					if($file != '.' && $file != '..') {
-						if(!is_link($install_dir.'/server/mods-enabled/'.$file)) symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
+						if(!@is_link($install_dir.'/server/mods-enabled/'.$file)) @symlink($install_dir.'/server/mods-available/'.$file, $install_dir.'/server/mods-enabled/'.$file);
 					}
 				}
 				closedir($dh);
@@ -636,7 +636,7 @@ class installer_base {
 			if ($dh = opendir($dir)) {
 				while (($file = readdir($dh)) !== false) {
 					if($file != '.' && $file != '..') {
-						if(!is_link($install_dir.'/server/plugins-enabled/'.$file)) symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
+						if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
 					}
 				}
 				closedir($dh);
diff --git a/install/tpl/server.ini.master b/install/tpl/server.ini.master
index 5e66de107ce70acb74cb97ba68d68c6c19c278b0..5f19aa8e74d21896493832ffbe372669414980e0 100644
--- a/install/tpl/server.ini.master
+++ b/install/tpl/server.ini.master
@@ -32,10 +32,17 @@ website_path=/var/clients/client[client_id]/web[website_id]
 website_symlinks=/var/www/[website_domain]/:/var/clients/client[client_id]/[website_domain]/
 vhost_conf_dir=/etc/apache2/sites-available
 vhost_conf_enabled_dir=/etc/apache2/sites-enabled
+
+[fastcgi]
 fastcgi_starter_path=/var/www/php-fcgi-scripts/[system_user]/
 fastcgi_starter_script=.php-fcgi-starter
 fastcgi_alias=/php/
 fastcgi_phpini_path=/etc/php5/cgi/
 fastcgi_children=8
 fastcgi_max_requests=5000
-fastcgi_bin=/usr/bin/php-cgi
\ No newline at end of file
+fastcgi_bin=/usr/bin/php-cgi
+
+[jailkit]
+jailkit_chroot_home=/home/[username]
+jailkit_chroot_app_sections=basicshell editors extendedshell netutils ssh sftp scp groups jk_lsh
+jailkit_chroot_app_programs=/usr/bin/groups /usr/bin/id /usr/bin/dircolors /usr/bin/lesspipe /usr/bin/basename /usr/bin/dirname /usr/bin/nano /usr/bin/pico
diff --git a/install/update.php b/install/update.php
index 3c8c9366362dcb8d6165f83839a8e76622b6963d..ebc7e9b79ec0240da09649f060bc47215c4aa6ac 100644
--- a/install/update.php
+++ b/install/update.php
@@ -180,12 +180,15 @@ swriteln('Updating ISPConfig');
 //** TODO: Don't always ask for this somehow ? 
 $fast_cgi = $inst->simple_query('CGI PHP Enabled Server?', array('yes','no'),'no');
 
+
 if($fast_cgi == 'yes') {
 	 $alias = $inst->free_query('Script Alias', '/php/');
 	 $path = $inst->free_query('Script Alias Path', '/path/to/cgi/bin');
 	 $inst->conf['apache']['vhost_cgi_alias'] = sprintf('ScriptAlias %s %s', $alias, $path);
+	 $inst->conf['apache']['vhost_cgi_alias_path'] = $path;
 } else {
 	 $inst->conf['apache']['vhost_cgi_alias'] = "";
+	 $inst->conf['apache']['vhost_cgi_alias_path'] = "";
 }
 
 
diff --git a/interface/web/sites/shell_user_edit.php b/interface/web/sites/shell_user_edit.php
index 629977efd5bc1dd7bb96929d278848f91d28776a..633ef46da55092d2b994a7cedf9f90e2203e7f56 100644
--- a/interface/web/sites/shell_user_edit.php
+++ b/interface/web/sites/shell_user_edit.php
@@ -80,9 +80,8 @@ class page_action extends tform_actions {
 		$dir = $web["document_root"];
 		$puser = $web["system_user"];
 		$pgroup = $web["system_group"];
-		$chroot = $web["chroot"];
 		
-		$sql = "UPDATE shell_user SET server_id = $server_id, dir = '$dir', puser = '$puser', pgroup = '$pgroup' chroot='$chroot' WHERE shell_user_id = ".$this->id;
+		$sql = "UPDATE shell_user SET server_id = $server_id, dir = '$dir', puser = '$puser', pgroup = '$pgroup' WHERE shell_user_id = ".$this->id;
 		$app->db->query($sql);
 		
 	}
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 2b790d27ff91eae652ad55ac7c9b8594c385dca7..d8b0c06401cb9bfa090d3f2706cc0f1e8ad5c979 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -382,30 +382,38 @@ class apache2_plugin {
 		
 		if ($data["new"]["php"] == "fast-cgi")
 		{
-			$fastcgi_starter_path = str_replace("[system_user]",$data["new"]["system_user"],$web_config["fastcgi_starter_path"]);
+			$fastcgi_config = $app->getconf->get_server_config($conf["server_id"], 'fastcgi');
+			
+			$fastcgi_starter_path = str_replace("[system_user]",$data["new"]["system_user"],$fastcgi_config["fastcgi_starter_path"]);
 			if (!is_dir($fastcgi_starter_path))
 			{
-				exec("mkdir $fastcgi_starter_path");
+				exec("mkdir -p $fastcgi_starter_path");
 				exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." $fastcgi_starter_path");
+				
+				
+				$app->log("Creating fastcgi starter script directory: $fastcgi_starter_path",LOGLEVEL_DEBUG);
 			}
 			
 			$fcgi_tpl = new tpl();
 			$fcgi_tpl->newTemplate("php-fcgi-starter.master");
 				
-			$fcgi_tpl->setVar('php_ini_path',$web_config["fastcgi_phpini_path"]);
+			$fcgi_tpl->setVar('php_ini_path',$fastcgi_config["fastcgi_phpini_path"]);
 			$fcgi_tpl->setVar('document_root',$data["new"]["document_root"]);
-			$fcgi_tpl->setVar('php_fcgi_children',$web_config["fastcgi_children"]);
-			$fcgi_tpl->setVar('php_fcgi_max_requests',$web_config["fastcgi_max_requests"]);
-			$fcgi_tpl->setVar('php_fcgi_bin',$web_config["fastcgi_bin"]);
+			$fcgi_tpl->setVar('php_fcgi_children',$fastcgi_config["fastcgi_children"]);
+			$fcgi_tpl->setVar('php_fcgi_max_requests',$fastcgi_config["fastcgi_max_requests"]);
+			$fcgi_tpl->setVar('php_fcgi_bin',$fastcgi_config["fastcgi_bin"]);
 				
-			$fcgi_starter_script = escapeshellcmd($fastcgi_starter_path."/".$web_config["fastcgi_starter_script"]);
+			$fcgi_starter_script = escapeshellcmd($fastcgi_starter_path."/".$fastcgi_config["fastcgi_starter_script"]);
 			file_put_contents($fcgi_starter_script,$fcgi_tpl->grab());
 			unset($fcgi_tpl);
 			
+			$app->log("Creating fastcgi starter script: $fcgi_starter_script",LOGLEVEL_DEBUG);
+			
+			
 			exec("chmod 755 $fcgi_starter_script");
 			exec("chown ".$data["new"]["system_user"].":".$data["new"]["system_group"]." $fcgi_starter_script");
 
-			$tpl->setVar('fastcgi_alias',$web_config["fastcgi_alias"]);
+			$tpl->setVar('fastcgi_alias',$fastcgi_config["fastcgi_alias"]);
 			$tpl->setVar('fastcgi_starter_path',$fastcgi_starter_path);
 			
 		}
@@ -500,6 +508,10 @@ class apache2_plugin {
 		if($data["old"]["domain"] != '' && !stristr($vhost_logfile_dir,'..')) exec("rm -rf $vhost_logfile_dir");
 		$app->log("Removing website logfile directory: $vhost_logfile_dir",LOGLEVEL_DEBUG);
 		
+		//delete the web user
+		$command = 'userdel';
+		$command .= ' '.$data["old"]["system_user"];			
+		exec($command);
 	}
 	
 	//* This function is called when a IP on the server is inserted, updated or deleted
diff --git a/server/plugins-available/shelluser_plugin.inc.php b/server/plugins-available/shelluser_base_plugin.inc.php
old mode 100644
new mode 100755
similarity index 97%
rename from server/plugins-available/shelluser_plugin.inc.php
rename to server/plugins-available/shelluser_base_plugin.inc.php
index 9fa34aae8933cc97b88e38edadcf0fe0fb09fc26..7e6b48554bc83bd555bcb37471e8a1e6a34fbc0b
--- a/server/plugins-available/shelluser_plugin.inc.php
+++ b/server/plugins-available/shelluser_base_plugin.inc.php
@@ -28,10 +28,10 @@ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-class shelluser_plugin {
+class shelluser_base_plugin {
 	
-	var $plugin_name = 'shelluser_plugin';
-	var $class_name = 'shelluser_plugin';
+	var $plugin_name = 'shelluser_base_plugin';
+	var $class_name = 'shelluser_base_plugin';
 	
 		
 	/*
@@ -102,7 +102,6 @@ class shelluser_plugin {
 		} else {
 			$app->log("UID = $uid for shelluser:".$data['new']['username']." not allowed.",LOGLEVEL_ERROR);
 		}
-		
 	}
 	
 	function delete($event_name,$data) {
diff --git a/server/plugins-available/shelluser_jailkit_plugin.inc.php b/server/plugins-available/shelluser_jailkit_plugin.inc.php
new file mode 100755
index 0000000000000000000000000000000000000000..a74f1712ff59fac50a443185ce2ce495fbb80303
--- /dev/null
+++ b/server/plugins-available/shelluser_jailkit_plugin.inc.php
@@ -0,0 +1,193 @@
+<?php
+
+/*
+Copyright (c) 2008, Till Brehm, projektfarm Gmbh
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+    * Redistributions of source code must retain the above copyright notice,
+      this list of conditions and the following disclaimer.
+    * Redistributions in binary form must reproduce the above copyright notice,
+      this list of conditions and the following disclaimer in the documentation
+      and/or other materials provided with the distribution.
+    * Neither the name of ISPConfig nor the names of its contributors
+      may be used to endorse or promote products derived from this software without
+      specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+class shelluser_jailkit_plugin {
+	
+	//* $plugin_name and $class_name have to be the same then the name of this class
+	var $plugin_name = 'shelluser_jailkit_plugin';
+	var $class_name = 'shelluser_jailkit_plugin';
+	
+		
+	/*
+	 	This function is called when the plugin is loaded
+	*/
+	
+	function onLoad() {
+		global $app;
+		
+		/*
+		Register for the events
+		*/
+		
+		$app->plugins->registerEvent('shell_user_insert',$this->plugin_name,'insert');
+		$app->plugins->registerEvent('shell_user_update',$this->plugin_name,'update');
+		$app->plugins->registerEvent('shell_user_delete',$this->plugin_name,'delete');
+
+		
+	}
+	
+	//* This function is called, when a shell user is inserted in the database
+	function insert($event_name,$data) {
+		global $app, $conf;
+		
+		/**
+		 * Setup Jailkit Chroot System If Enabled 
+		 */
+		if ($data['new']['chroot'] == "jailkit")
+		{
+			// load the server configuration options
+			$app->uses("getconf");
+			$this->data = $data;
+			$this->app = $app;
+			$this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
+			
+			$this->_setup_jailkit_chroot();
+			$this->_add_jailkit_user();
+		}
+		
+		$app->log("Jalikit Plugin -> insert username:".$data['new']['username'],LOGLEVEL_DEBUG);
+		
+	}
+	
+	//* This function is called, when a shell user is updated in the database
+	function update($event_name,$data) {
+		global $app, $conf;
+		
+		/**
+		 * Setup Jailkit Chroot System If Enabled 
+		 */
+		if ($data['new']['chroot'] == "jailkit")
+		{
+			// load the server configuration options
+			$app->uses("getconf");
+			$this->data = $data;
+			$this->app = $app;
+			$this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
+			
+			$this->_setup_jailkit_chroot();
+			$this->_add_jailkit_user();
+		}
+		
+		$app->log("Jalikit Plugin -> update username:".$data['new']['username'],LOGLEVEL_DEBUG);
+		
+	}
+	
+	//* This function is called, when a shell user is deleted in the database
+	function delete($event_name,$data) {
+		global $app, $conf;
+		
+		if ($data['old']['chroot'] == "jailkit")
+		{
+			$app->uses("getconf");
+			$this->jailkit_config = $app->getconf->get_server_config($conf["server_id"], 'jailkit');
+			
+			$jailkit_chroot_userhome = $this->_get_home_dir($data['old']['username']);
+			
+			exec('rm -rf '.$data['old']['dir'].$jailkit_chroot_userhome);
+			
+			
+			$app->log("Jalikit Plugin -> delete chroot home:".$data['old']['dir'].$jailkit_chroot_userhome,LOGLEVEL_DEBUG);
+		}
+		
+		$app->log("Jalikit Plugin -> delete username:".$data['old']['username'],LOGLEVEL_DEBUG);
+		
+		
+	}
+	
+	function _setup_jailkit_chroot()
+	{
+			//check if the chroot environment is created yet if not create it with a list of program sections from the config
+			if (!is_dir($this->data['new']['dir'].'/etc/jailkit'))
+			{
+				$command = '/usr/local/ispconfig/server/scripts/create_jailkit_chroot.sh';
+				$command .= ' '.escapeshellcmd($this->data['new']['dir']);
+				$command .= ' \''.$this->jailkit_config['jailkit_chroot_app_sections'].'\'';
+				exec($command);
+				
+				$this->app->log("Added jailkit chroot with command: ".$command,LOGLEVEL_DEBUG);
+				
+				$this->_add_jailkit_programs();
+				
+				
+			}
+	}
+	
+	function _add_jailkit_programs()
+	{
+		//copy over further programs and its libraries
+		$command = '/usr/local/ispconfig/server/scripts/create_jailkit_programs.sh';
+		$command .= ' '.escapeshellcmd($this->data['new']['dir']);
+		$command .= ' \''.$this->jailkit_config['jailkit_chroot_app_programs'].'\'';
+		exec($command);
+		
+		$this->app->log("Added programs to jailkit chroot with command: ".$command,LOGLEVEL_DEBUG);
+	}
+	
+	function _get_home_dir($username)
+	{
+		return str_replace("[username]",escapeshellcmd($username),$this->jailkit_config["jailkit_chroot_home"]);
+	}
+	
+	function _add_jailkit_user()
+	{
+			//add the user to the chroot
+			$jailkit_chroot_userhome = $this->_get_home_dir($this->data['new']['username']);
+			$jailkit_chroot_puserhome = $this->_get_home_dir($this->data['new']['puser']);
+			
+			if (!is_dir($this->data['new']['dir'].$jailkit_chroot_userhome))
+			{
+				$command = '/usr/local/ispconfig/server/scripts/create_jailkit_user.sh';
+				$command .= ' '.escapeshellcmd($this->data['new']['username']);
+				$command .= ' '.escapeshellcmd($this->data['new']['dir']);
+				$command .= ' '.$jailkit_chroot_userhome;
+				$command .= ' '.escapeshellcmd($this->data['new']['shell']);
+				$command .= ' '.$this->data['new']['puser'];
+				$command .= ' '.$jailkit_chroot_puserhome;
+				exec($command);
+				
+				$this->app->log("Added jailkit user to chroot with command: ".$command,LOGLEVEL_DEBUG);
+				
+				exec("mkdir -p ".$this->data['new']['dir'].$jailkit_chroot_userhome);
+				exec("chown ".$this->data['new']['username'].":".$this->data['new']['pgroup']." ".$this->data['new']['dir'].$jailkit_chroot_userhome);
+				
+				$this->app->log("Added created jailkit user home in : ".$this->data['new']['dir'].$jailkit_chroot_userhome,LOGLEVEL_DEBUG);
+				
+				exec("mkdir -p ".$this->data['new']['dir'].$jailkit_chroot_puserhome);
+				exec("chown ".$this->data['new']['puser'].":".$this->data['new']['pgroup']." ".$this->data['new']['dir'].$jailkit_chroot_puserhome);
+				
+				$this->app->log("Added created jailkit parent user home in : ".$this->data['new']['dir'].$jailkit_chroot_puserhome,LOGLEVEL_DEBUG);
+			}	
+	}
+	
+	
+
+} // end class
+
+?>
\ No newline at end of file
diff --git a/server/scripts/create_jailkit_chroot.sh b/server/scripts/create_jailkit_chroot.sh
new file mode 100755
index 0000000000000000000000000000000000000000..07460df951ae652a28747c74dd92074d0b38787b
--- /dev/null
+++ b/server/scripts/create_jailkit_chroot.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# Create the jailkit chroot
+
+#
+# Usage: ./create_jailkit_chroot username 'basicshell editors'
+#
+
+
+# Sanity check
+
+if [ "$1" = "" ]; then
+        echo "    Usage: ./create_jailkit_chroot username 'basicshell editors'"
+        exit
+fi
+
+CHROOT_HOMEDIR=$1
+CHROOT_APP_SECTIONS=$2
+
+## Change ownership of the chroot directory to root
+chown root:root $CHROOT_HOMEDIR
+
+## Initialize the chroot into the specified directory with the specified applications
+jk_init -f -k -j $CHROOT_HOMEDIR $CHROOT_APP_SECTIONS
+
+## Create the temp directory
+mkdir $CHROOT_HOMEDIR/tmp
+chmod a+rwx $CHROOT_HOMEDIR/tmp
+
+
+# mysql needs the socket in the chrooted environment
+mkdir $CHROOT_HOMEDIR/var
+mkdir $CHROOT_HOMEDIR/var/run
+mkdir $CHROOT_HOMEDIR/var/run/mysqld
+ln /var/run/mysqld/mysqld.sock $CHROOT_HOMEDIR/var/run/mysqld/mysqld.sock
diff --git a/server/scripts/create_jailkit_programs.sh b/server/scripts/create_jailkit_programs.sh
new file mode 100755
index 0000000000000000000000000000000000000000..11641f2c1ff506db996cb3063b2cefb41f985ff7
--- /dev/null
+++ b/server/scripts/create_jailkit_programs.sh
@@ -0,0 +1,20 @@
+#!/bin/bash
+
+# Add specified programs and their libraries to the jailkit chroot
+
+#
+# Usage: ./create_jailkit_programs /path/to/chroot '/usr/bin/program'
+#
+
+# Sanity check
+
+if [ "$1" = "" ]; then
+        echo "    Usage: ./create_jailkit_programs /path/to/chroot '/usr/bin/program'"
+        exit
+fi
+
+
+CHROOT_HOMEDIR=$1
+CHROOT_APP_PROGRAMS=$2
+
+jk_cp -k $CHROOT_HOMEDIR $CHROOT_APP_PROGRAMS
diff --git a/server/scripts/create_jailkit_user.sh b/server/scripts/create_jailkit_user.sh
new file mode 100755
index 0000000000000000000000000000000000000000..893046c5220ca8606bfba6f2dfd17d209b728874
--- /dev/null
+++ b/server/scripts/create_jailkit_user.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+# Add user to the jailkit chroot
+
+#
+# Usage: ./create_jailkit_user username /path/to/chroot/ /home/webuser /bin/bash web2 /home/web2
+#
+
+# Sanity check
+
+if [ "$1" = "" ]; then
+        echo "    Usage: ./create_jailkit_user username /path/to/chroot/ /home/webuser /bin/bash"
+        exit
+fi
+
+
+CHROOT_USERNAME=$1
+CHROOT_HOMEDIR=$2
+CHROOT_USERHOMEDIR=$3
+CHROOT_SHELL=$4
+CHROOT_P_USER=$5
+CHROOT_P_USER_HOMEDIR=$6
+
+### Add the chroot user ###
+jk_jailuser  -s $CHROOT_SHELL -j $CHROOT_HOMEDIR $CHROOT_USERNAME
+
+### Reconfigure the chroot home directory for the user ###
+usermod --home=$CHROOT_HOMEDIR/.$CHROOT_USERHOMEDIR $CHROOT_USERNAME
+
+### We have to reconfigure the chroot home directory for the parent user ###
+if [ "$CHROOT_P_USER" != "" ]; then
+  usermod --home=$CHROOT_HOMEDIR/.$CHROOT_P_USER_HOMEDIR $CHROOT_P_USER
+fi
\ No newline at end of file