Sunday, October 11, 2009

PureFTP w/ MySQL

1)yum install mysql mysql-server httpd php php-mysql php-mbstring pure-ftpd

chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start

chkconfig --levels 235 httpd on
/etc/init.d/httpd start

2)mysqladmin -u root password *pwd*
mysqladmin -h server1.localhost.localdomain -u root password *pwd*

If you have CentOS 5 --> http://centos.karan.org/el4/misc/testing/i386/RPMS

3) groupadd -g 2001 ftpgroup
useradd -u 2001 -s /bin/false -d /bin/null -c "pureftpd user" -g ftpgroup ftpuser

mysql -u root -p

CREATE DATABASE pureftpd;
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost' IDENTIFIED BY 'ftpdpass';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP ON pureftpd.* TO 'pureftpd'@'localhost.localdomain' IDENTIFIED BY 'ftpdpass';
FLUSH PRIVILEGES;
USE pureftpd;
CREATE TABLE ftpd (
User varchar(16) NOT NULL default '',
status enum('0','1') NOT NULL default '0',
Password varchar(64) NOT NULL default '',
Uid varchar(11) NOT NULL default '-1',
Gid varchar(11) NOT NULL default '-1',
Dir varchar(128) NOT NULL default '',
ULBandwidth smallint(5) NOT NULL default '0',
DLBandwidth smallint(5) NOT NULL default '0',
comment tinytext NOT NULL,
ipaccess varchar(15) NOT NULL default '*',
QuotaSize smallint(5) NOT NULL default '0',
QuotaFiles int(11) NOT NULL default 0,
PRIMARY KEY (User),
UNIQUE KEY User (User)
) TYPE=MyISAM;quit;

4)vi /etc/pure-ftpd/pure-ftpd.conf



ChrootEveryone yes
MySQLConfigFile /etc/pure-ftpd/pureftpd-mysql.conf
CreateHomeDir yes
5)vi /etc/pure-ftpd/pureftpd-mysql.conf

MYSQLSocket /var/lib/mysql/mysql.sock
#MYSQLServer localhost
#MYSQLPort 3306
MYSQLUser pureftpd
MYSQLPassword ftpdpass
MYSQLDatabase pureftpd
#MYSQLCrypt md5, cleartext, crypt() or password() - md5 is VERY RECOMMENDABLE uppon cleartext
MYSQLCrypt md5
MYSQLGetPW SELECT Password FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetUID SELECT Uid FROM ftpd WHERE User="\L" AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetGID SELECT Gid FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MYSQLGetDir SELECT Dir FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthUL SELECT ULBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetBandwidthDL SELECT DLBandwidth FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTASZ SELECT QuotaSize FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")
MySQLGetQTAFS SELECT QuotaFiles FROM ftpd WHERE User="\L"AND status="1" AND (ipaccess = "*" OR ipaccess LIKE "\R")

6)mysql -u root -p
USE pureftpd;
INSERT INTO `ftpd` (`User`, `status`, `Password`, `Uid`, `Gid`, `Dir`,
`ULBandwidth`, `DLBandwidth`, `comment`, `ipaccess`, `QuotaSize`,
`QuotaFiles`) VALUES ('exampleuser', '1', MD5('secret'), '2001',
'2001', '/home/www.example.com', '100', '100', '', '*', '50', '0');


7)chkconfig --levels 235 pure-ftpd on
/etc/init.d/pure-ftpd start

Saturday, October 3, 2009

Vi Tips #2

Word Boundaries

:%s/\/testing123/g

BackReferences

Use \(\) to make backreferences

%s/\(specification\)/new \1/g

Thursday, October 1, 2009

Auto Yum Script to install all Deps for OCS Inventory Server and Agent

yum -y install perl-XML-Simple perl-DBI perl-DBD-MySQL perl-Apache-DBI perl-Net-IP perl-SOAP-Lite
yum -y install perl-XML-SAX
yum -y install perl-XML-SAX-Base
yum -y install perl-libwww-perl-5.805-1.1.1
yum -y install perl-Compress-Zlib
yum -y install perl-IO-Compress
yum -y install perl-Compress-Zlib
yum -y install perl-Net-CIDR
yum -y install perl-Test-Mock-LWP
yum -y install perl-Test-Mock-LWP
yum -y install perl-Daemon-Generic
yum -y install perl-Unix-PID.noarch
yum -y install perl-Proc-PID-File.noarch
yum -y install perl-Net-IPv4Addr.noarch
yum -y install perl-Net-Interface.i386
yum -y install perl-Net-IP-CMatch.i386
yum -y install perl-Net-IPv4Addr.noarch
yum -y install perl-Net-IPv6Addr.noarch
perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers()"

/Zlib.pm conflicts between attempted installs of perl-IO-Compress- and perl-Compress-Zlib

Tested On - CentOS 5.1

Had this error come up when trying to install perl-IO-Compress

Resolved it by

1)yum update perl
2)yum -y install perl-Compress-Zlib
3)yum -y install perl-IO-Compress
4)yum -y install perl-Compress-Zlib

Followers