Re: A webhosting script?

2006-08-26 Thread Ted Mittelstaedt

- Original Message - 
From: Kyrre Nygård [EMAIL PROTECTED]
To: Tamouh H. [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Friday, August 25, 2006 10:44 AM
Subject: RE: A webhosting script?


 At 19:09 25.08.2006, Tamouh H. wrote:

 There are many control panels that do these sort of things. Some are
 free, others are not.
 
 Check WebMin, cPanel, DirectAdmin, Plesk, H-Sphere, RAQdevil.and
 tons more.

 Hello Tamouh, yeah I know man but this is exactly what I'm trying to
avoid.

 Not only are the visual and cognitive designs of these solutions so
 bad I'd rather get
 shot in the head than using them, they're also highly unnecessary. I agree
that
 some of the tasks they help people do might be too advanced for the
 average Joe but
 this is really not the way to go.


Before you start shooting down these solutions let an old hand here
give you some advice.

I am the top technical dog at a regional ISP here.  Recently we acquired a
snaller ISP.  This ISP was obviously run by someone who thought like you
do.  I am in charge of the integration of their systems into our systems.

We use webmin as a front end for our adminstrative stuff.  This ISP we
bought uses a custom-written solution.  It is your typical webinterface
on PHP that yakks to a mysql database.  A series of scripts on the
back end run every few minutes, sucking changes out of the mysql
database and distributing them to the various systems, like the mailserver,
authentication servers, etc.

Among one of the little gems I discovered a week after we bought them
was that the smart guy that wrote the front end had made a very simple
little programming error.  It was buried in the transfer script that is
supposed to keep the mail and radius servers in synchronization with
the mysql server.

This front end has been in operation for years.  It is at the point now
were the mysql system is so far out of sync with the actual devices
that there are -HUNDREDS- of customers getting free service that
were turned off for non-payment, there are even more hundreds of
customers listed in the accounting system that aren't in the actual
systems, yadda yadda yadda.  It is a holy fucking mess.  So bad that
in fact I'm doing a complete rush job on ash-canning all their systems
and getting the customer base folded into our systems as quickly
as possible.

When you consider that all these freeloaders affected the ISPs calculations
of how much circuit capacity they needed to buy, you might begin to
understand the gravity of the situation.  We are talking many thousands of
dollars spent on keeping pipes from being overloaded by buying ever
more circuit capacity, while meanwhile the revenue coming in kept going
down.  The only good thing about it was that I am pretty sure all
this was why we were able to buy the ISP at all.  If it had been run
properly, they would have been much less interested in selling, I am sure.

It is very much for want of a nail the war was lost.

Solutions like Webmin that everybody uses may not look pretty.  But
they have thousands of administrators like me in the world who are
banging on them, finding these little mistakes and getting the corrections
put into the maintainers.  There is absolutely no fucking way in hell
that you, working alone in your little office, can even hope to approach
the level of debugging that a program like Webmin has gone through.

Everybody that runs an ISP or web farm today that knows their
ass from a hole in the ground has scrapped their custom-written
solutions and gone to a widely-used solution, whether commercial or
open source, unless they are maybe the size of AOL.  And I'd much
rather not be working for an ISP like AOL that's losing more money
every year than all the readers of this list put together would make in
a lifetime.

Ted

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: A webhosting script?

2006-08-25 Thread Andy Greenwood

We use perl scripts here. Unfortunately, I can't provide any specific examples.

On 8/25/06, Kyrre Nygård [EMAIL PROTECTED] wrote:


Hello!

Does anybody run a webhosting business, where they've written
a simple Bash script to add new users to the system and set up their
domains, Apache virtual hosts, databases etc. all in one go?

I am looking for inspiration for my own script.

Thank you!

I truly wish to keep it real and avoid solutions like cPanel or Webmin.

All the best,
Kyrre

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: A webhosting script?

2006-08-25 Thread Kyrre Nygård

At 17:30 25.08.2006, Andy Greenwood wrote:
We use perl scripts here. Unfortunately, I can't provide any 
specific examples.


So stop trolling :)

Perl is obsolete anyway, thanks though.

All the best,
Kyrre


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: A webhosting script?

2006-08-25 Thread Duane Hill
On Friday, August 25, 2006 at 3:45:08 PM, Kyrre confabulated:

 At 17:30 25.08.2006, Andy Greenwood wrote:
We use perl scripts here. Unfortunately, I can't provide any 
specific examples.

 So stop trolling :)

 Perl is obsolete anyway, thanks though.

So, if Perl is obsolete, what does a guy use for a replacement?

-- 
This message was sent using 100% recycled electrons.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: A webhosting script?

2006-08-25 Thread Tamouh H.
 
 Hello!
 
 Does anybody run a webhosting business, where they've written 
 a simple Bash script to add new users to the system and set 
 up their domains, Apache virtual hosts, databases etc. all in one go?
 
 I am looking for inspiration for my own script.
 
 Thank you!
 
 I truly wish to keep it real and avoid solutions like cPanel 
 or Webmin.
 
 All the best,
 Kyrre
 

There are many control panels that do these sort of things. Some are free, 
others are not.

Check WebMin, cPanel, DirectAdmin, Plesk, H-Sphere, RAQdevil.and tons more.

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


RE: A webhosting script?

2006-08-25 Thread fbsd
Check the questions archives for subject Scripts to Manage Virtual
Hosts and
subject Apache 2 hosts and apache www/data directory and
directory structuer for a web server and Apache vhost directive
problem and Virtual Host.

Bottom line here is search the archives for answers.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Behalf Of Kyrre
Nygard
Sent: Friday, August 25, 2006 9:13 AM
To: [EMAIL PROTECTED]
Subject: A webhosting script?



Hello!

Does anybody run a webhosting business, where they've written
a simple Bash script to add new users to the system and set up their
domains, Apache virtual hosts, databases etc. all in one go?

I am looking for inspiration for my own script.

Thank you!

I truly wish to keep it real and avoid solutions like cPanel or
Webmin.

All the best,
Kyrre

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to
[EMAIL PROTECTED]

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: A webhosting script?

2006-08-25 Thread Scott Oertel
I wrote a simple one that could use improvement a while back for a 
FreeBSD box I had, you could use it as a reference point. It's developed 
in python though.


-Scott

Duane Hill wrote:

On Friday, August 25, 2006 at 3:45:08 PM, Kyrre confabulated:

  

At 17:30 25.08.2006, Andy Greenwood wrote:

We use perl scripts here. Unfortunately, I can't provide any 
specific examples.
  


  

So stop trolling :)



  

Perl is obsolete anyway, thanks though.



So, if Perl is obsolete, what does a guy use for a replacement?

  


___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]

Re: A webhosting script?

2006-08-25 Thread Scott Oertel

For some reason the script doesn't really show up, ill just paste it here:

#!/usr/local/bin/python
#
# Site managment tool
# Written by: Scott Oertel
#


# imports
import os, sys, re, pwd
from crypt import crypt
import time, commands

global httpd_conf
httpd_conf = '/usr/local/etc/apache22/vhosts.conf'

class AddSite:
   def __init__(self, username, password, domain):
   self.username = username
   self.password = password
   self.domain = domain
   def run(self):
   self.AddUser()
   self.AddVhost()
   apacheStatus = 
commands.getstatusoutput('/usr/local/etc/rc.d/apache22.sh reload')

   if apacheStatus[0] != 0:
   print Apache reload failed!
   print apacheStatus[1]
   sys.exit()
  
   def losuj_salt (self, lenght = 8):

   '''Generate random salt from letters and digits. '''
   import random
   # pool for random bytes
   # pool = range (48, 127)
   pool = []
   for x in range (48, 127):
   pool.append (chr (x))
   s = [ '$1$' ] # start of salt indicating md5 encryption
   i = 0
   # check whether salt is between 0 and 8 (including both)
   if lenght  0:
   lenght = 0
   if lenght  8:
   lenght = 8
   # Generate up to 8 random, printable characters
   while i  lenght:
   s.append (s[i] + random.choice ( pool ))
   i += 1
   return s[lenght] + '$'
  
  
   def AddVhost(self):

   vhostDirective = '''
  
   ### vhost for #domain# ###
  
   VirtualHost *:80

   ServerAdmin [EMAIL PROTECTED]
   DocumentRoot #domainDir#
   ServerName #domain#
   ServerAlias www.#domain#
   ErrorLog /var/log/apache/#domain#-error_log
   CustomLog /var/log/apache/#domain#-access_log common
   SuexecUserGroup #user# #user#
   /VirtualHost
  
   ### end vhost for #domain# ###
  
   '''

   confObj = open(httpd_conf, 'a')
   os.mkdir(self.homeDir + /html, 0775)
   os.chown(self.homeDir + /html, pwd.getpwnam(self.username)[2], 
pwd.getpwnam(self.username)[3])

   vhostDirective = re.sub(#domain#, self.domain, vhostDirective)
   vhostDirective = re.sub(#domainDir#, self.homeDir + html, 
vhostDirective)

   vhostDirective = re.sub(#user#, self.username, vhostDirective)
   vhostObj = open(httpd_conf, 'a')
   vhostObj.write(vhostDirective)
  
   def AddUser(self):

 #check if site exists
 vhost_fileObj = open(httpd_conf, 'r')
 vhost_file = vhost_fileObj.read()
 try:
   pwd.getpwnam(self.username)
   sys.stderr.write(That username is already in use!\n)
   sys.exit()
 except KeyError:
   pass
 if re.search(r'[#]{3}[\s]+vhost\sfor\s(%s)[\s][#]{3}' % 
self.domain, vhost_file) != None:

   sys.stderr.write(That domain already has a vhost entry.\n)
   sys.exit()
 else:
   ## add the user/vhost ##
   # generate home directory
   name, tld = self.domain.split('.')
   self.homeDir = /home/ + tld + / + name + /
   hash = crypt(self.password, self.losuj_salt())
   tmpfile = open(/root/tmp/jsiIKw23, w)
   tmpfile.write(hash)
   tmpfile.close()
   # add the user
   groupStatus = commands.getstatusoutput(pw groupadd %s % self.username)
   pwStatus = commands.getstatusoutput(pw user add -n %s -G %s -d %s 
-s /bin/date -m -H 0  /root/tmp/jsiIKw23 % (self.username, 
self.username, self.homeDir))

   if groupStatus[0] != 0 or pwStatus[0] != 0:
   print User creation failed.
   print groupStatus
   print pwStatus
   sys.exit()
   # remove the temp file
   #os.remove(/tmp/jsiIKw23)
   # permissions setup
   try:
   os.chown(self.homeDir, pwd.getpwnam(self.username)[2], 
pwd.getpwnam(self.username)[3])

   except KeyError:
   print Setting folder permissions failed, trying again..,
   time.sleep(3)
   os.chown(self.homeDir, pwd.getpwnam(self.username)[2], 
pwd.getpwnam(self.username)[3])

   print Success!
  


class DeleteSite:
   def __init__(self, username, domain):
   self.username = username
   self.domain = domain
   def run(self):
   rmuserStatus = commands.getstatusoutput(/usr/sbin/rmuser -y %s % 
self.username)

   if rmuserStatus[0] != 0:
   print Ran into trouble deleting the username!
   print rmuserStatus[1]
   sys.exit(2)
   else:
   self.deleteVhost()
   apacheStatus = 
commands.getstatusoutput('/usr/local/etc/rc.d/apache22.sh reload')

   if apacheStatus[0] != 0:
   print Apache reload failed!
   print apacheStatus[1]
   sys.exit()
  
   def deleteVhost(self):

   vhostFile = open(httpd_conf, r)
   vhostFileData = vhostFile.read()
   vhostFileData = re.sub(r'[#]{3}[\s]+vhost\sfor\s(' + self.domain + 
')[\s][#]{3}[\n\t\n\t@A-Za-z\*\s0-9:\./\-_]+[#]{3}\send\svhost\sfor\s(' 
+ self.domain + ')\s[#]{3}[\n\t]+'

  , '', vhostFileData)
   vhostFile.close()
   vhostFile = open(httpd_conf, w)
   vhostFile.write(vhostFileData)
   vhostFile.close()
  
def usage():

   print '''Site Management Tool v1.0

Usage:

./site.py -a --user=username --pass=password --domain=domain
./site.py -d --user=username --domain=domain
./site.py -s --domain=domain

-s to suspend a site. 

RE: A webhosting script?

2006-08-25 Thread Kyrre Nygård

At 19:09 25.08.2006, Tamouh H. wrote:

There are many control panels that do these sort of things. Some are 
free, others are not.


Check WebMin, cPanel, DirectAdmin, Plesk, H-Sphere, RAQdevil.and 
tons more.


Hello Tamouh, yeah I know man but this is exactly what I'm trying to avoid.

Not only are the visual and cognitive designs of these solutions so 
bad I'd rather get

shot in the head than using them, they're also highly unnecessary. I agree that
some of the tasks they help people do might be too advanced for the 
average Joe but

this is really not the way to go.

Thanks,
Kyrre

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: A webhosting script?

2006-08-25 Thread Greg Barniskis

Duane Hill wrote:

On Friday, August 25, 2006 at 3:45:08 PM, Kyrre confabulated:


At 17:30 25.08.2006, Andy Greenwood wrote:
We use perl scripts here. Unfortunately, I can't provide any 
specific examples.



So stop trolling :)



Perl is obsolete anyway


giggle And that's not trolling? ;)

Without getting into a way-OT my favorite language is better'n 
yours flamefest, if you really want inspiration for the pure 
shell way, look at ports/sysutils/ezjail and its flavours 
framework for templating new jails with users, ports, post-install 
scripts, etc. All shell.


Requires 6.1-RELEASE-p3 or later due to a jail-related rc bug.

--
Greg Barniskis, Computer Systems Integrator
South Central Library System (SCLS)
Library Interchange Network (LINK)
gregb at scls.lib.wi.us, (608) 266-6348
___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: A webhosting script?

2006-08-25 Thread Kyrre Nygård

At 19:47 25.08.2006, Greg Barniskis wrote:


giggle And that's not trolling? ;)


I'd say check the facts. Though I know a lot of people are 
emotionally attached to things of the past and I'm sorry if anybody 
feels offended.



Without getting into a way-OT my favorite language is better'n 
yours flamefest, if you really want inspiration for the pure 
shell way, look at ports/sysutils/ezjail and its flavours 
framework for templating new jails with users, ports, post-install 
scripts, etc. All shell.


Man, just the words you gave me has already made my mouth all watery. 
I'll surely check it out, and thanks a whole lot.


All the best,
Kyrre

___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]


Re: A webhosting script?

2006-08-25 Thread Paul Schmehl
--On Friday, August 25, 2006 17:45:08 +0200 Kyrre Nygård 
[EMAIL PROTECTED] wrote:



At 17:30 25.08.2006, Andy Greenwood wrote:

We use perl scripts here. Unfortunately, I can't provide any
specific examples.


So stop trolling :)

Perl is obsolete anyway, thanks though.

You must be kidding.  I have a server that runs a message board built on 
perl, and it does very nicely.


When's the last time a web-based perl application had all the problems that 
php has routinely?


Paul Schmehl ([EMAIL PROTECTED])
Adjunct Information Security Officer
The University of Texas at Dallas
http://www.utdallas.edu/ir/security/


Re: A webhosting script?

2006-08-25 Thread Andy Greenwood

I certainly didn't mean to troll :-) I was just trying to say that
it's more than doable in perl. Unfortunately, I'm constricted by
non-disclosure agreements I had to sign before I took on my current
position. Glad you got what you were looking for though :-)

On 8/25/06, Paul Schmehl [EMAIL PROTECTED] wrote:

--On Friday, August 25, 2006 17:45:08 +0200 Kyrre Nygård
[EMAIL PROTECTED] wrote:

 At 17:30 25.08.2006, Andy Greenwood wrote:
 We use perl scripts here. Unfortunately, I can't provide any
 specific examples.

 So stop trolling :)

 Perl is obsolete anyway, thanks though.

You must be kidding.  I have a server that runs a message board built on
perl, and it does very nicely.

When's the last time a web-based perl application had all the problems that
php has routinely?

Paul Schmehl ([EMAIL PROTECTED])
Adjunct Information Security Officer
The University of Texas at Dallas
http://www.utdallas.edu/ir/security/



___
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to [EMAIL PROTECTED]