#!/usr/bin/perl
#############################################################################
#                                                                           #
# This copyright data applies to all source files                           #
#                                                                           #
# WebShell, Copyright (c) 2002 Steven Wishart, All Rights Reserved.         #
#                                                                           #
#      Module  : dbsetup                                                    #
#        Type  : Perl Source file                                           #
# Description  : Script to set up Database for the Config application       #
#                                                                           #
# This software is provided `AS IS' and without any express or implied      #
# warranties, including, without limitation, the implied waranties of       #
# merchantabulity and fitness for a particular purpose.                     #
#                                                                           #
# Redistribution and use of source are permitted provided that:             #
#                                                                           #
# (1) source distributions may not be sold for profit on physical media     #
# such as disks, tapes, and CD-ROMS, without expressed written permission   #
# from the author.                                                          #
#                                                                           #
#############################################################################
# --> Modify Table to Create in WebShell Database
$table = "config";
#
#
#
# ----------------------------------------------------------------------#
# Don't change anything below this line, unless you know what you doing #
# ----------------------------------------------------------------------#
#
#
#
# -----------> Start of Config Options
$database = "webshell";
$user = "webshell";
$passwd = "webshell";
$rootuser = "root";
$rootpasswd = "";
$config_db = "mysql";
$sql_interpreter = "/usr/bin/mysql";
$sql_admin = "/usr/bin/mysqladmin";
# -----------> End of Config Options

print "\n\n\nWebShell, Copyright (c) 2002 Steven Wishart, All Rights Reserved\n\n";

print "What is the root password for MySQL? ";
system("stty -echo");
$ans = <>; chomp $ans;
print "\n";
$rootpasswd = $ans;
system("stty echo");

while( ! -x $sql_interpreter )
{
  print "Where is the mysql interpreter located? ";
  $ans = <$sql_interpreter>; chomp $ans;
  $sql_interpreter = $ans;
}

while( ! -x $sql_admin )
{
  print "Where is mysqladmin located? ";
  $ans = <$sql_admin>; chomp $ans;
  $sql_admin = $ans;
}

# create the table needed to store the information
open(SQL, "|$sql_interpreter -u $rootuser -p$rootpasswd $database");

print SQL "create table $table (";
print SQL "id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,";    # 0
print SQL "author varchar(30),";  	                    # 1
print SQL "site varchar(100),";  	                    # 2
print SQL "sitename varchar(100),";                         # 3
print SQL "programdir varchar(100),";                       # 4
print SQL "bindir varchar(30),";  	                    # 5
print SQL "datadir varchar(30),";  	                    # 6
print SQL "imagedir varchar(30),";  	                    # 7
print SQL "helpdir varchar(30),";  	                    # 8
print SQL "logdir varchar(30),";  	                    # 9
print SQL "rootdir varchar(100),";  	                    # 10
print SQL "errorlog varchar(100),";  	                    # 11
print SQL "syslog varchar(100),";  	                    # 12
print SQL "adminemail varchar(50),";  	                    # 13
print SQL "adminlevel INT,";                                # 14 
print SQL "emaildomain varchar(50),";  	                    # 15
print SQL "domainname varchar(50),";  	                    # 16
print SQL "true INT,";		  	                    # 17
print SQL "false INT,";		  	                    # 18
print SQL "month varchar(100),";  	                    # 19
print SQL "month2 varchar(100),";  	                    # 20
print SQL "chdir_mode INT,";	  	                    # 21
print SQL "chmod_mode INT,";		                    # 22
print SQL "chown_mode INT,";		                    # 23
print SQL "chgrp_mode INT,";		                    # 24
print SQL "rootdirsite varchar(100),"; 	                    # 25
print SQL "version varchar(30),";  	                    # 26
print SQL "fortune varchar(50),";  	                    # 27
print SQL "fortunedisable char,";	                    # 28
print SQL "privatesystem char,";	                    # 29
print SQL "privatesystemmsg varchar(100),";  	            # 30
print SQL "privatesystempasswd varchar(50)";	            # 31
print SQL ");";

close SQL;

open(SQL, "|$sql_interpreter -u $rootuser -p$rootpasswd $database");
print SQL "insert into $table (";
print SQL "id,";   				            # 0
print SQL "author,";		  	                    # 1
print SQL "site,"; 		 	                    # 2
print SQL "sitename,";         		                    # 3
print SQL "programdir,";                   		    # 4
print SQL "bindir,";  	                    	            # 5
print SQL "datadir,";  			                    # 6
print SQL "imagedir,";		  	                    # 7
print SQL "helpdir,"; 		 	                    # 8
print SQL "logdir,";		  	                    # 9
print SQL "rootdir,";		  	                    # 10
print SQL "errorlog,"; 		 	                    # 11
print SQL "syslog,";  			                    # 12
print SQL "adminemail,";  		                    # 13
print SQL "adminlevel,";	                            # 14 
print SQL "emaildomain,";	  	                    # 15
print SQL "domainname,";	  	                    # 16
print SQL "true,";		  	                    # 17
print SQL "false,";		  	                    # 18
print SQL "month,";  			                    # 19
print SQL "month2,";		  	                    # 20
print SQL "chdir_mode,";	  	                    # 21
print SQL "chmod_mode,";		                    # 22
print SQL "chown_mode,";		                    # 23
print SQL "chgrp_mode,";		                    # 24
print SQL "rootdirsite,";		                    # 25
print SQL "version,";			                    # 26
print SQL "fortune,";			                    # 27
print SQL "fortunedisable,";			            # 28
print SQL "privatesystem,";			            # 29
print SQL "privatesystemmsg,";			            # 30
print SQL "privatesystempasswd";		            # 31
print SQL ") ";                

# CHANGE THESE VALUES ONLY
print SQL "values (";
print SQL "'1',";   				            # 0
print SQL "'Steven Wishart',";   			    # 1
print SQL "'http://myrapid.com/webshell',";	 		    # 2
print SQL "'WebShell, Copyright (c) 2002 Steven Wishart, All Rights Reserved',";  # 3
print SQL "'/home/WebShell',";	  		            # 4
print SQL "'bin',";		  		            # 5
print SQL "'data',";		  		            # 6
print SQL "'images',";		  		            # 7
print SQL "'help',";		  		            # 8
print SQL "'logs',";		  		            # 9
print SQL "'/home/users',";		 	            # 10
print SQL "'error.log',";		 	            # 11
print SQL "'webshell.log',";		 	            # 12
print SQL "'youremail\@yourdomain.com',";	 	    # 13
print SQL "'6',";	 			            # 14
print SQL "'myrapid.com',";		 	            # 15
print SQL "'myrapid.com',";		 	            # 16
print SQL "'1',";			 	            # 17
print SQL "'0',";			 	            # 18
print SQL "'Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov, Dec',";       # 19
print SQL "'January, February, March, April, May, June, July, August, September, October, November, December',"; # 20
print SQL "'0770',";			 	            # 21
print SQL "'00666',";			 	            # 22
print SQL "'1000',";			 	            # 23
print SQL "'1000',";			 	            # 24
print SQL "'http://myrapid.com/users',";	            # 25
print SQL "'0.01',";				            # 26
print SQL "'/usr/games/fortune',";			    # 27
print SQL "'N',";			   	            # 28
print SQL "'N',";			   	            # 29
print SQL "'This is a Private System, please contact webshell\@myrapid.com for an account.',";  # 30
print SQL "'passwd12'";			   	            # 31

print SQL ");"; 
close SQL;

print "$table Table Creation complete.\n\n";
