View Single Post
Old 14th March 2010, 03:43
fducloux fducloux is offline
Junior Member
Join Date: Mar 2010
Posts: 8
Thanks: 4
Thanked 7 Times in 3 Posts

I've automated the whole process and tested it!
i hope anyone finds this useful

note: it backup files prior performing any modification, and then shows a diff on a less, so you'll have to press q. and you'll have to delete the backup files manually.

here's the shell script, you can find it attached and gzipped.

# cat 
set -x

# Download, unzip, and more
cd /tmp
cd net2ftp_v0.98
mv files_to_upload /var/www/webftp
cd ..
/bin/rm -R net2ftp_v0.98

# add to webftp.conf
echo ............. Creating /etc/apache2/conf.d/webftp.conf
cat <<EOF>/etc/apache2/conf.d/webftp.conf
<Directory /var/www/webftp>
Order deny,allow
Allow from all
Alias /net2ftp /var/www/webftp
Alias /webftp /var/www/webftp

# Restart apache
echo ............. Restarting apache
/etc/init.d/apache2 restart

echo ............. Creating /var/www/ispconfig/sites/site_webftp.php
cat <<EOF>/var/www/ispconfig/sites/site_webftp.php
if (!isset(\$_GET['id'])){
die ("No site selected!");
\$domainId = intval(\$_GET['id']);
\$dbData = \$app->db->queryOneRecord("SELECT server_id FROM web_domain WHERE
domain_id = " . \$domainId);
\$serverId = intval(\$dbData['server_id']);
if (\$serverId == 0){
die ("No Server found!");
\$serverData = \$app->db->queryOneRecord(
"SELECT server_name FROM server WHERE server_id = " .

echo ............. Setting permissions for /var/www/ispconfig/sites/site_webftp.php
chown ispconfig:ispconfig /var/www/ispconfig/sites/site_webftp.php

echo ............. Modifing line 44 /var/www/ispconfig/sites/templates/web_domain_list.htm  Backup on /var/www/ispconfig/sites/templates/web_domain_list.htm.bak.$$
cp /var/www/ispconfig/sites/templates/web_domain_list.htm /var/www/ispconfig/sites/templates/web_domain_list.htm.bak.$$
sed -i "44i<a class=\"icons16 icoWebFTP\" href=\"sites/site_webftp.php?id={tmpl_var name=\'id\'}\" target=\"webftp\"><span>{tmpl_var name=\'admin_txt\'}</span></a>" /var/www/ispconfig/sites/templates/web_domain_list.htm
diff /var/www/ispconfig/sites/templates/web_domain_list.htm /var/www/ispconfig/sites/templates/web_domain_list.htm.bak.$$ |less

echo ............. Adding text on line 291 /var/www/ispconfig/themes/default/css/screen/content_ispc.css  Backup on  /var/www/ispconfig/themes/default/css/screen/content_ispc.css.bak.$$
cp /var/www/ispconfig/themes/default/css/screen/content_ispc.css /var/www/ispconfig/themes/default/css/screen/content_ispc.css.bak.$$
sed -i '291i.icons16.icoWebFTP { background-image: url(\"../../icons/x16/folder_open.png\"); }' /var/www/ispconfig/themes/default/css/screen/content_ispc.css
diff /var/www/ispconfig/themes/default/css/screen/content_ispc.css /var/www/ispconfig/themes/default/css/screen/content_ispc.css.bak.$$ |less

echo ............. Commenting line 35 /var/www/webftp/ Backup on /var/www/webftp/$$
cp /var/www/webftp/ /var/www/webftp/$$
sed -i '35s/^/\/\/ /'  /var/www/webftp/
sed -i '35s/$/ \/\/commented out to add webftpi\/net2ftp/'  /var/www/webftp/
diff /var/www/webftp/ /var/www/webftp/$$  |less 

echo ............. Adding text on line 34  /var/www/webftp/ Backup on /var/www/webftp/$$
cp /var/www/webftp/ /var/www/webftp/$$

sed -i "34i \$ftp_server=null; \n \$ftp_server=trim\(\$_GET[\'servername\'], \'\\\\\"\'\); \n if\(!strlen\(\$ftp_server\)\){ \n \$ftp_server=\$_COOKIE[\'ftp_server\']; \n } \n else{ \n setcookie\(\"ftp_server\", \$ftp_server\); \n } \n if(strlen\(\$ftp_server\)\){ \n \$net2ftp_settings[\"allowed_ftpservers\"][1] = \$ftp_server; \n } \n else{ \n \$net2ftp_settings[\"allowed_ftpservers\"][1] = \"ALL\"; \n } \n 
" /var/www/webftp/

diff /var/www/webftp/ /var/www/webftp/$$  |less

BTW, i'm quite good with shell scripting, and a complete n00b when it comes to PHP or MySQL!
Could any one do the same thing for Z-Push? It would be awesome to have push-imap into ISPConfig!!

Attached Files
File Type: gz (1.2 KB, 670 views)

Last edited by fducloux; 15th March 2010 at 22:21. Reason: on line number 30, changed <\?php for <?php. if you download the .gz file you'll have to fix that before running!
Reply With Quote