$NetBSD: patch-aa,v 1.1.1.1 2000/10/21 19:02:32 rh Exp $ --- install.pl.orig Sat Sep 23 20:15:46 2000 +++ install.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!@@PREFIX@@/bin/perl #This is the install utility for ISPMan #I wrote it origionally for Slashcode some time back, but have modified it to be used with ISPMan. @@ -14,7 +14,6 @@ $HOSTNAME=$ENV{'HOSTNAME'}||`hostname`; chomp $HOSTNAME; $PWD=$ENV{'PWD'}; -system("clear"); #this hashref defines sections that we need to configure and their descriptions. #each key is a section eg ldap, mail, dns etc @@ -57,7 +56,7 @@ dns_vars => { 'description' => qq| These are DNS (named) specific variables - will put an empty named.conf.header and named.conf.footer in /etc/ispman/templates + will put an empty named.conf.header and named.conf.footer in @@PREFIX@@/etc/ispman/templates directory for you which you can later change according to your network. If you already have these files in place then they will be left untouched. |, @@ -122,55 +121,55 @@ }, apacheVhostsDir => { - default => '/home/httpd/virtual', + default => '@@HTDOCS@@', question => "Directory where the VirtualHosts will be kept\nEach domain will have its entry within this directory \nand each subhost will be created underneath that directory", }, apacheVhostsFile => { - default => '/etc/httpd/conf/vhosts.conf', + default => '@@PREFIX@@/etc/httpd/vhosts.conf', question => "The file where I should create VirtualHost Entries", }, apacheVhostsHeader => { - default => '/etc/ispman/templates/vhosts.conf.header', + default => '@@PREFIX@@/etc/ispman/templates/vhosts.conf.header', question => "I will prepend this file to the VirtualHosts file", }, apacheVhostsTemplate => { - default => '/etc/ispman/templates/vhosts.template', + default => '@@PREFIX@@/etc/ispman/templates/vhosts.template', question => "This is the template that will be used when creating config for Virtualhosts\nIf it does not exists then it will be created for you", }, apacheVhostsIP=> { - default => '192.168.1.1', + default => '@@IP@@', question => "This is the ip address that all virtual hosts will share", }, apacheVhostsFooter => { - default => '/etc/ispman/templates/vhosts.conf.footer', + default => '@@PREFIX@@/etc/ispman/templates/vhosts.conf.footer', question => "I will append this file to the VirtualHosts file", }, apacheReloadCommand => { - default => '/etc/rc.d/init.d/httpd reload', + default => '@@PREFIX@@/etc/rc.d/apache restart', question => "Command to reload apache.\nIf this command is present then it will be used instead \nof stoping and starting the daemon", }, apacheStopCommand => { - default => '/etc/rc.d/init.d/httpd stop', + default => '@@PREFIX@@/etc/rc.d/apache stop', question => "Command to stop apache", }, apacheStartCommand => { - default => '/etc/rc.d/init.d/httpd start', + default => '@@PREFIX@@/etc/rc.d/apache start', question => "Command to start apache", }, @@ -179,7 +178,7 @@ ldapInstallPath => { - default => '/etc/openldap', + default => '@@PREFIX@@/etc/openldap', question => "path to ldap conf directory.", }, @@ -205,7 +204,7 @@ }, imapHosts => { - default => 'mail', + default => 'localhost', question => "List all Cyrus mail servers that you have separated by space", }, @@ -261,49 +260,49 @@ }, namedStopCommand => { - default => '/etc/rc.d/init.d/named stop', + default => '/etc/rc.d/named stop', question => "Command to stop named", }, namedConfFile => { - default => '/etc/named.conf', + default => '/etc/namedb/named.conf', question => "Configuration file for named", }, namedStartCommand => { - default => '/etc/rc.d/init.d/named start', + default => '/etc/rc.d/named start', question => "Command to start named", }, namedConfHeaderFile => { - default => '/etc/ispman/templates/named.conf.header', + default => '@@PREFIX@@/etc/ispman/templates/named.conf.header', question => "Header file that I should prepend to the generated named.conf", }, namedConfFooterFile => { - default => '/etc/ispman/templates/named.conf.footer', + default => '@@PREFIX@@/etc/ispman/templates/named.conf.footer', question => "Header file that I should append to the generated named.conf", }, dnsMasterEmail => { - default => 'hostsmaster.yourdomain', + default => 'hostmaster.yourdomain', question => "Emailaddress of the dns master.\nThis is for SOA record", }, rootEmail => { - default => 'root@%%hostname%%', + default => 'root@localhost', question => "Email of the administrator.\nThis email adress is used to send emails if something fails", }, installDir => { - default => '/opt/ispman', - question => "Directory where you want to install ispman components.\nYou may choose to install in on an NFS partition so that you can share the same files with multiple machines.\nIt is recommended to install at /opt/ispman", + default => '@@PREFIX@@/share/ispman', + question => "Directory where you want to install ispman components.\nYou may choose to install in on an NFS partition so that you can share the same files with multiple machines.\nIt is recommended to install at @@PREFIX@@/share/ispman", }, sleepSecondsBetweenRestart => { @@ -315,10 +314,10 @@ }; -if (-e "/etc/ispman/conf/ispman.conf"){ +if (-e "@@PREFIX@@/etc/ispman/ispman.conf"){ $ISUPDATE=1; print "Existing ISPMan installation Exists\nReading defaults from config file\n"; - do "/etc/ispman/conf/ispman.conf"; + do "@@PREFIX@@/etc/ispman/ispman.conf"; *Config=*ISPMan::Config; $Config->{'imapHosts'}=join " ", @{$Config->{'imapHosts'}}; for (keys %$Config){ @@ -362,12 +361,7 @@ print getVar($_, 'default'); print "]: "; } - chomp(my $answer=<>); - if ($answer) { - $vars->{$_}{'default'}=$answer; - } else { - $vars->{$_}{'default'}=getVar($_, 'default'); - } + $vars->{$_}{'default'}=getVar($_, 'default'); } } @@ -376,10 +370,8 @@ sub write_config { - system("clear"); - print "Writting ispman.conf"; - backup("/etc/ispman/conf/ispman.conf"); - open ("F", ">/etc/ispman/conf/ispman.conf") or die "Cant open x"; + print "Writting ispman.conf.default"; + open ("F", ">@@PREFIX@@/etc/ispman/ispman.conf.default") or die "Cant open x"; print F "package ISPMan;\n"; my $key; @@ -411,16 +403,14 @@ - print "\nWritting /etc/ispman/templates/domain.ldif.template\n"; + print "\nWritting @@PREFIX@@/etc/ispman/templates/domain.ldif.template.default\n"; print "This template is an ldif template that is used when creating a new domain\n"; print "This template has probably my site defaults. You may want to change it a bit\n"; - backup("/etc/ispman/templates/domain.ldif.template"); - system("cp install-data/domain.ldif.template.dist /etc/ispman/templates/domain.ldif.template"); + system("cp install-data/domain.ldif.template.dist @@PREFIX@@/etc/ispman/templates/domain.ldif.template.default"); - print "\nWritting /etc/ispman/templates/vhosts.conf.template\n"; - backup("/etc/ispman/templates/vhosts.conf.template"); - system("cp install-data/vhosts.conf.template.dist /etc/ispman/templates/vhosts.conf.template"); + print "\nWritting @@PREFIX@@/etc/ispman/templates/vhosts.conf.template.default\n"; + system("cp install-data/vhosts.conf.template.dist @@PREFIX@@/etc/ispman/templates/vhosts.conf.template.default"); } @@ -442,7 +432,7 @@ print "*"x72, "\n"; if ($vars_info->{$_}{'optional'}) { print "You may skip this section to get the default values\nDo you want to set them up? y/n [y] "; - chomp(my $ans=<>); + my $ans="n"; if ($ans=~/^\s*n/i){ setDefaults(@{$vars_info->{$_}{'vars'}}); next; @@ -450,19 +440,16 @@ $vars_info->{$_}{'set'}=1; } configure(@{$vars_info->{$_}{'vars'}}); - system("clear"); } make_directories(); write_config(); } sub make_directories{ - system("clear"); print "\n\nMaking required directories\n"; system(qq| - mkdir -p /etc/ispman/templates - mkdir -p /etc/ispman/conf + mkdir -p @@PREFIX@@/etc/ispman/templates mkdir -p $vars->{'installDir'}{'default'} |); @@ -475,22 +462,22 @@ print "Copying cgi-bin to $vars->{'installDir'}{'default'}/ \n"; - system("cp -a ispman-web/cgi-bin $vars->{'installDir'}{'default'}/"); + system("cp -R ispman-web/cgi-bin $vars->{'installDir'}{'default'}/"); print "Copying htdocs to $vars->{'installDir'}{'default'}/ \n"; - system("cp -a ispman-web/htdocs $vars->{'installDir'}{'default'}/"); + system("cp -R ispman-web/htdocs $vars->{'installDir'}{'default'}/"); print "Copying bin to $vars->{'installDir'}{'default'}/ \n"; - system("cp -a ispman-utils/bin $vars->{'installDir'}{'default'}/"); + system("cp -R ispman-utils/bin $vars->{'installDir'}{'default'}/"); print "\nMaking dummy named.conf and vhosts.conf header and footer files\n"; system (qq| - echo '#this is a named.conf.header file' > $vars->{'namedConfHeaderFile'}{'default'} - echo '#this is a named.conf.footer file' > $vars->{'namedConfFooterFile'}{'default'} - echo '#this is a vhosts.conf.header file' > $vars->{'apacheVhostsHeader'}{'default'} - echo '#this is a vhosts.conf.footer file' > $vars->{'apacheVhostsFooter'}{'default'} + echo '#this is a named.conf.header file' > "$vars->{'namedConfHeaderFile'}{'default'}.default" + echo '#this is a named.conf.footer file' > "$vars->{'namedConfFooterFile'}{'default'}.default" + echo '#this is a vhosts.conf.header file' > "$vars->{'apacheVhostsHeader'}{'default'}.default" + echo '#this is a vhosts.conf.footer file' > "$vars->{'apacheVhostsFooter'}{'default'}.default" |); } @@ -501,7 +488,7 @@ sub makeldif{ print "\n\nMaking default ldif file. ispman.ldif\n\n"; -open "F", ">ispman.ldif"; +open "F", ">ispman.ldif.default"; print F qq|dn: $vars->{'ldapBaseDN'}{'default'} objectclass: top objectclass: organisation @@ -570,13 +557,12 @@ sub make_ldap_conf { print "\n\nShall I make ldap.conf for you? [Y/n]"; - my $install=<>; chomp $install; + my $install="y"; if ($install =~/^n$/i){ print "OK\n"; } else { print "Installing ldap.conf\n"; - backup("$vars->{'ldapInstallPath'}{'default'}/ldap.conf"); - open "F", ">$vars->{'ldapInstallPath'}{'default'}/ldap.conf"; + open "F", ">$vars->{'ldapInstallPath'}{'default'}/ldap.conf.ispman"; print F "host $vars->{'ldapHost'}{'default'}\n"; print F "base $vars->{'ldapBaseDN'}{'default'}\n"; print F "pam_login_attribute uid\n"; @@ -589,13 +575,12 @@ sub make_slapd_conf { print "Shall I make slapd.conf for you? [Y/n]"; - my $install=<>; chomp $install; + my $install="y"; if ($install =~/^n$/i){ print "OK\n"; } else { - backup("$vars->{'ldapInstallPath'}{'default'}/slapd.conf"); - open "F", ">$vars->{'ldapInstallPath'}{'default'}/slapd.conf"; + open "F", ">$vars->{'ldapInstallPath'}{'default'}/slapd.conf.ispman"; print F qq| include $vars->{'ldapInstallPath'}{'default'}/slapd.at.conf include $vars->{'ldapInstallPath'}{'default'}/slapd.oc.conf @@ -625,7 +610,6 @@ make_slapd_conf(); install(); -system("clear"); print "Enjoy!\n"; print qq| I have created an ldif file ispman.ldif