#!/usr/bin/perl ###################################################### # This is Freeiris Install script by hoowa sun ###################################################### $|=1; use FindBin qw($Bin); #use strict; require "$Bin/perl/site/lib/Asterisk/config.pm"; # checking and settings before install my @perlcode = ( 'web/htdocs/adminp_billing.cgi', 'web/htdocs/user_account.cgi', 'web/htdocs/user.cgi', 'web/htdocs/adminp.cgi', 'web/htdocs/user_addressbook.cgi', 'web/htdocs/user_charge.cgi', 'web/htdocs/adminp_webcontrol.cgi', 'web/htdocs/user_api.cgi', 'web/htdocs/user_statistics.cgi', 'web/htdocs/demo.cgi', 'web/htdocs/user_c2c.cgi', 'bin/freeirisaamp.pl', 'bin/freeirisbill.pl', 'bin/freeirisd', 'agi/balance.agi', 'agi/authaccount.agi', 'agi/outboundlcr.agi' ); my $compatible = { 'linux'=>{ }, 'freebsd'=>{ }, }; my $VERSION = '2.0'; # get opts and set input output my $OPTS = &getopts; my $INPUT = STDIN; my $OUTPUT = STDOUT; my $ERRPUT = STDERR; $OUTPUT = $OPTS->{output} if (defined $OPTS->{output}); $INPUT = $OPTS->{input} if (defined $OPTS->{input}); $ERRPUT = $OPTS->{errput} if (defined $OPTS->{errput}); # check root ? &println('error',"Your must logon as root !") if ($< ne '0'); &println(undef,qq~ Welcome to FreeIris install script $VERSION hoowa.sun ---------------------------------------------------------- WARNING: Freeiris is is free Open Source software. IT COMES WITHOUT WARRANTY OF ANY KIND. ---------------------------------------------------------- ~); # input type if (exists $OPTS->{help}) { &app_usage(); } elsif (defined $OPTS->{autoconf}) { &app_autoconf_setup(); } else { &app_setup(); } # function app sub app_autoconf_setup { my %INFO; #-----------read auto conf file my $allconf = &config_parse($OPTS->{autoconf}); &println('error','can not open autconf file') if (!$allconf); &println('step'," Run install under auto conf mode!"); #------------checking if (-d"/etc/freeiris/") { my $oldfreeiris = new Asterisk::config(file=>"/etc/freeiris/freeiris.conf"); $oldfreeiris = $oldfreeiris->fetch_values_arrayref(section=>'general',key=>'freeiris_root')->[0]; &println('response',"We found an other freeiris on $oldfreeiris! \n Do you want to del it (yes/no)?\n"); if ($allconf->{'general'}{'overwrite'} eq 'yes') { &del_dir($oldfreeiris); } else{ println('error'," You must remove old version.!\n"); } } %INFO = %{$allconf->{'autoconf'}}; $INFO{'asterisk_conf_obj'} = new Asterisk::config(file=>"$INFO{'asterisk_conf'}/asterisk.conf"); &println('response',qq~ ----------------------------------------------------------------- Your Configuration : OS : $INFO{'os'} Publish : $INFO{'publish'} OS Kernel : $INFO{'kernel'} Asterisk config : $INFO{'asterisk_conf'} mysql command line : $INFO{'mysql_cmd'} install prefix : $INFO{'freeiris_target'} perl intepreter : $INFO{'perl_intepreter'} httpd conf : $INFO{'httpd_conf'} mysql db host : $INFO{'dbhost'} mysql db user : $INFO{'dbuser'} mysql db pass : (*) mysql db name : $INFO{'dbname'} mysql db port : $INFO{'dbport'} website language : $INFO{'language'} ----------------------------------------------------------------- AUTO CONF INSTALL now! ~); &_install(\%INFO); exit; } sub app_setup { &println('input',"Do you agree with License(in COPYING file) (yes/no)?"); my $input = ; chomp($input); if ($input ne 'yes') { &println('','Thank you!');exit; } #----------Getting information my (%INFO); &println('step','Getting information...'); $INFO{'os'} = $^O; &println('response',"Operation System : $INFO{'os'}"); if ($INFO{'os'} eq 'linux' && -e"/etc/redhat-release") { $INFO{'publish'} = 'redhat'; } else { $INFO{'publish'} = 'unknow'; } &println('response',"Publish Version : $INFO{'publish'}"); $INFO{'kernel'} = `uname -r`; chomp($INFO{'kernel'}); &println('response',"Linux Kernel : $INFO{'kernel'}"); #----------Getting information--------checking if (-d"/etc/freeiris/") { my $oldfreeiris = new Asterisk::config(file=>"/etc/freeiris/freeiris.conf"); $oldfreeiris = $oldfreeiris->fetch_values_arrayref(section=>'general',key=>'freeiris_root')->[0]; &println('input',"We found an other freeiris on $oldfreeiris! \n Do you want to del it (yes/no)?\n"); my $delete = <$INPUT>; chomp($delete); if ($delete eq 'yes') { &del_dir($oldfreeiris); } else{ println('error'," You must remove old version.!\n"); } } #-----------------asterisk my $checkasterisk; foreach (split(/\n/,`ps -o pid,command -C 'asterisk'`)) { next if ($_ =~ /$$\s/); # no self next if ($_ !~ /asterisk/); # no other line $checkasterisk=1; last; } if (!$checkasterisk) { &println('error',"asterisk not run, please startup asterisk frist!"); } while (1) { if (!-d"/etc/asterisk") { &println('input',"Please input your asterisk etc folder path ?"); $INFO{'asterisk_conf'} = <$INPUT>; chomp($INFO{'asterisk_conf'}); } else { $INFO{'asterisk_conf'} = '/etc/asterisk'; } if (!-d$INFO{'asterisk_conf'} || !-e"$INFO{'asterisk_conf'}/asterisk.conf") { &println('failed',"asterisk.conf not found in $INFO{'asterisk_conf'}/asterisk.conf!"); $INFO{'asterisk_conf'}=''; } else { &println('response',"asterisk.conf : $INFO{'asterisk_conf'}/asterisk.conf"); $INFO{'asterisk_conf_obj'} = new Asterisk::config(file=>"$INFO{'asterisk_conf'}/asterisk.conf"); last; } } #是否有asterisk cdr mysql if (!-e$INFO{'asterisk_conf_obj'}->fetch_values_arrayref(section=>'directories',key=>'astmoddir')->[0]."/cdr_addon_mysql.so") { &println('error',"CDR MYSQL not install! Please install asterisk-addons package"); } #是否有mysql和mysql client while (1) { if (!-e"/usr/bin/mysql") { &println('input',"Please input mysql command path ?"); $INFO{'mysql_cmd'} = <$INPUT>; chomp($INFO{'mysql_cmd'}); } else { $INFO{'mysql_cmd'} = '/usr/bin/mysql'; } if (!-e$INFO{'mysql_cmd'} || !eval{"$INFO{'mysql_cmd'} --version"}) { &println('failed',"mysql client command failed not found in $INFO{'mysql_cmd'}!"); $INFO{'mysql_cmd'}=''; } else { &println('response',"mysql client command : $INFO{'mysql_cmd'}"); last; } } #----------------checking install while (1) { my $target = '/usr/local/freeiris'; &println('input',"Please input install target folder (default $target)?"); $INFO{'freeiris_target'} = <$INPUT>; chomp($INFO{'freeiris_target'}); $INFO{'freeiris_target'} = $target if ($INFO{'freeiris_target'} eq ''); if (-d$INFO{'freeiris_target'}) { &println('failed',"freeiris target folder ".$INFO{'freeiris_target'}." already exists!"); $INFO{'freeiris_target'}=''; } else { &println('response',"freeiris target : $INFO{'freeiris_target'}"); last; } } #----------------checking perl while (1) { if ($INFO{'os'} ne 'linux') { &println('input',"Please input perl intepreter path ?"); $INFO{'perl_intepreter'} = <$INPUT>; chomp($INFO{'perl_intepreter'}); if (!-e$INFO{'perl_intepreter'}) { &println('failed',"perl intepreter not exists!"); next; } my $stat = `$INFO{'perl_intepreter'} $Bin/perlmod.list`; if ($stat ne 'OK') { &println('error',"freeiris required perl modules not install, please see perlmod.list!"); } else { &println('response',"perl intepreter : $INFO{'perl_intepreter'}"); last; } # OS Linux } else { &println('input',"0. bundled perl\n 1. customize\n Please choose Perl intepreter (default 0)?"); $INFO{'perl_intepreter'} = <$INPUT>; chomp($INFO{'perl_intepreter'}); # BUNDLED PERL if ($INFO{'perl_intepreter'} eq '0' || $INFO{'perl_intepreter'} eq '') { &println('response',"perl intepreter : (bundled)"); last; # USER LOCAL PERL } elsif ($INFO{'perl_intepreter'} eq '1') { &println('input',"Please input perl intepreter path ?"); $INFO{'perl_intepreter'} = <$INPUT>; chomp($INFO{'perl_intepreter'}); if (!-e$INFO{'perl_intepreter'}) { &println('failed',"perl intepreter not exists!"); next; } my $stat = `$INFO{'perl_intepreter'} $Bin/perlmod.list`; if ($stat ne 'OK') { &println('error',"freeiris required perl modules not install, please see perlmod.list!"); } else { &println('response',"perl intepreter : $INFO{'perl_intepreter'}"); last; } } } } #----------set---httpd conf file my $httpd_conf; $httpd_conf = '/etc/httpd/conf' if (-e"/etc/httpd/conf/httpd.conf"); while (1) { if ($httpd_conf ne '') { &println('input',"Your httpd.conf file at $httpd_conf (yes/no/cancel) (default yes)?"); my $input = <$INPUT>; chomp($input); if ($input eq 'yes' || $input eq '') { $INFO{'httpd_conf'} = $httpd_conf; last; } elsif ($input eq 'cancel') { last; } else { $httpd_conf=''; next; } } else { &println('input',"Please input your httpd.conf file path ?"); my $input = <$INPUT>; chomp($input); if (-e"$input/httpd.conf") { $httpd_conf = $input; next; } else { last; } } } #----------set---database variables while (1) { &println('input',"Please input Mysql address (default 127.0.0.1)?"); my $dbhost = <$INPUT>; chomp($dbhost); $dbhost = '127.0.0.1' if ($dbhost eq '' || $dbhost eq 'localhost'); &println('input',"Please input Mysql port (default 3306)?"); my $dbport = <$INPUT>; chomp($dbport); $dbport = 3306 if ($dbport eq ''); my $dbname; while (1) { &println('input',"Please input Mysql databasename ?"); $dbname = <$INPUT>; chomp($dbname); last if ($dbname ne ''); } my $dbuser; while (1) { &println('input',"Please input Mysql username ?"); $dbuser = <$INPUT>; chomp($dbuser); last if ($dbuser ne ''); } my $dbpass; &println('input',"Please input Mysql user password ?"); $dbpass = <$INPUT>; chomp($dbpass); #try to connect &println('response',"Try to Connect MySQL Server......"); my $trycon = `$INFO{'mysql_cmd'} --host $dbhost --port=$dbport --database=$dbname --user=$dbuser --password=$dbpass --silent --execute='select "OK"'`; if ($trycon =~ /^OK/) { &println('response',"Connect MySQL Server successfully !......"); $INFO{'dbhost'}=$dbhost; $INFO{'dbuser'}=$dbuser; $INFO{'dbpasswd'}=$dbpass; $INFO{'dbname'}=$dbname; $INFO{'dbport'}=$dbport; last; } &println('response',"Connect MySQL Server Failed !......"); } #-----settings default language enviroment if (-d"$Bin/web/template") { my (@language); opendir(DIR,"$Bin/web/template") or die "Error: Can't find $Bin/web/template"; foreach (grep { !/^\./ && -d "$Bin/web/template/$_" } readdir(DIR)) { push(@language,$_); &println(''," $#language $_"); } closedir(DIR); my ($weblanguage,$savelanguage); &println('input',"Please Input NUM of Web Display Language(default is english):"); $weblanguage = <$INPUT>; chomp($weblanguage); if ($weblanguage eq '' || !$language[$weblanguage]) { $savelanguagestr = 'english'; } else { $savelanguagestr = $language[$weblanguage]; } $INFO{'language'} = $savelanguagestr; } &println('response',qq~ ----------------------------------------------------------------- Your Configuration : OS : $INFO{'os'} Publish : $INFO{'publish'} OS Kernel : $INFO{'kernel'} Asterisk config : $INFO{'asterisk_conf'} mysql command line : $INFO{'mysql_cmd'} install prefix : $INFO{'freeiris_target'} perl intepreter : $INFO{'perl_intepreter'} httpd conf : $INFO{'httpd_conf'} mysql db host : $INFO{'dbhost'} mysql db user : $INFO{'dbuser'} mysql db pass : (*) mysql db name : $INFO{'dbname'} mysql db port : $INFO{'dbport'} website language : $INFO{'language'} ----------------------------------------------------------------- Continue Will copying all files to your computer(yes/no)~); if (<$INPUT> =~ /yes/) { # continue to do install step &_install(\%INFO); } else { println('error'," Install user abort!\n"); } exit; } sub _install { my $info = shift; my %info = %$info; $INFO{'good_msg'} = "installed result : \n"; $info{'good_msg'} .= "Installed freeiris to : $INFO{'freeiris_target'}\n"; #----------FILES COPYING &println('step',"Copying files to $info{'freeiris_target'}..."); &println('response',"Creating folder $info{'freeiris_target'}"); system("mkdir $info{'freeiris_target'}"); system("mkdir $info{'freeiris_target'}/agi"); system("mkdir $info{'freeiris_target'}/bin"); system("mkdir $info{'freeiris_target'}/etc"); system("mkdir $info{'freeiris_target'}/lib"); system("mkdir $info{'freeiris_target'}/log"); #system("mkdir $info{'freeiris_target'}/perl"); system("mkdir $info{'freeiris_target'}/sounds"); system("mkdir $info{'freeiris_target'}/web"); system("mkdir /var/spool/freeiris"); system("mkdir /var/spool/freeiris/backup"); &println('response',"Copying files to $info{'freeiris_target'}/"); system("cp -pRf $Bin/agi/ $info{'freeiris_target'}/"); system("cp -pRf $Bin/bin/ $info{'freeiris_target'}/"); system("cp -pRf $Bin/etc/ $info{'freeiris_target'}/"); system("cp -pRf $Bin/lib/ $info{'freeiris_target'}/"); #log #system("cp -pRf $Bin/perl/ $info{'freeiris_target'}/"); system("cp -pRf $Bin/sounds/ $info{'freeiris_target'}/"); system("cp -pRf $Bin/web/ $info{'freeiris_target'}/"); # intall bundle perl? #&println('response',"Force install bundled perl in /usr/local/freeiris..."); system("mkdir /usr/local/freeiris") if (!-d"/usr/local/freeiris/"); system("cp -pRf $Bin/perl/ /usr/local/freeiris"); $info{'good_msg'} .= "Installed bundled perl to : /usr/local/freeiris/perl/\n"; #----------SETUP &println('step',"Setup freeiris..."); &println('response',"Softlink $info{'freeiris_target'}/etc/freeiris to /etc/freeiris"); $info{'good_msg'} .= "maked link to : /etc/freeiris\n"; system("rm -rf /etc/freeiris"); system("ln -sf $info{'freeiris_target'}/etc/freeiris /etc/freeiris"); &println('response',"Softlink $info{'freeiris_target'}/agi/*.agi to ".$info{'asterisk_conf_obj'}->fetch_values_arrayref(section=>'directories',key=>'astagidir')->[0]."/*.agi"); $info{'good_msg'} .= "maked link to : your asterisk agi-bin / *.agi\n"; system("ln -sf $info{'freeiris_target'}/agi/* ".$info{'asterisk_conf_obj'}->fetch_values_arrayref(section=>'directories',key=>'astagidir')->[0]."/"); &println('response',"Softlink $info{'freeiris_target'}/sounds/freeiris to ".$info{'asterisk_conf_obj'}->fetch_values_arrayref(section=>'directories',key=>'astdatadir')->[0]."/sounds/freeiris"); $info{'good_msg'} .= "maked link to : your asterisk sounds / freeiris\n"; system("ln -sf $info{'freeiris_target'}/sounds/freeiris ".$info{'asterisk_conf_obj'}->fetch_values_arrayref(section=>'directories',key=>'astdatadir')->[0]."/sounds/freeiris"); &println('response',"Overwrite $info{'freeiris_target'}/etc/voipconf.dist/* to $info{'asterisk_conf'}/"); $info{'good_msg'} .= "overwrite your asterisk config files\n"; system("cp -pRf $info{'freeiris_target'}/etc/voipconf.dist/* $info{'asterisk_conf'}/"); #设置文件权限 &println('response',"Setting Permission to all config files..."); system("chmod -R 777 $info{'freeiris_target'}/etc"); system("chmod -R 777 $info{'freeiris_target'}/log"); system("chmod -R 777 $info{'freeiris_target'}/sounds/freeiris"); system("chmod -R 777 $info{'asterisk_conf'}"); system("chmod -R 777 /var/spool/freeiris"); system("chmod -R 777 /var/spool/freeiris/backup"); system("chmod -R 755 $info{'freeiris_target'}/web/htdocs/*.cgi"); system("chmod -R 755 $info{'freeiris_target'}/web/htdocs/bill/*.cgi"); system("chmod -R 755 $info{'freeiris_target'}/agi/*.agi"); system("chmod -R 755 $info{'freeiris_target'}/bin/*"); $info{'good_msg'} .= "chmod target files permission\n"; #设置perl头信息 if (-e$info{'perl_intepreter'}) { foreach my $file (@perlcode) { next if (!-e"$info{'freeiris_target'}/$file"); &println('response',"Setting perl header $info{'freeiris_target'}/$file"); my ($buf,$body); open(NEWHEAD,"$info{'freeiris_target'}/$file") or die "can't read $file: $!"; while (read(NEWHEAD,$buf,1024)) { $body .= $buf; } close(NEWHEAD); open(NEWHEAD,">$info{'freeiris_target'}/$file") or die "can't write $file: $!"; print NEWHEAD "#!".$info{'perl_intepreter'}."\n".$body; close(NEWHEAD); } $info{'good_msg'} .= "used customized perl instand of bundled perl\n"; } #设置httpd if ($info{'httpd_conf'} ne '') { my $curhttpd_body = `cat $info{'httpd_conf'}/httpd.conf`; if ($curhttpd_body !~ /freeiris_httpd2/) { open(HTTPD,">>$info{'httpd_conf'}/httpd.conf") or die "can't append to httpd.conf : $!"; print HTTPD "\ninclude /etc/freeiris/freeiris_httpd2.conf\n"; close(HTTPD); &println('response',"append to httpd conf : $info{'httpd_conf'}/httpd.conf"); $info{'good_msg'} .= "auto append freeiris_httpd2.conf in your httpd.conf\n"; } } else { $info{'end_msg'} = qq~You need to manual append follow line end of your httpd.conf: include /etc/freeiris/freeiris_httpd2.conf ~; &println('response',"httpd conf : not set"); } #修改freeiris_httpd2.conf if ($info{'freeiris_target'} ne '/usr/local/freeiris') { open(READ,"$info{'freeiris_target'}/etc/freeiris/freeiris_httpd2.conf") or die "can't open $info{'freeiris_target'}/etc/freeiris/freeiris_httpd2.conf : $!"; my @fhcon=; close(READ); open(SAVE,">$info{'freeiris_target'}/etc/freeiris/freeiris_httpd2.conf") or die "can't write $info{'freeiris_target'}/etc/freeiris/freeiris_httpd2.conf : $!"; foreach (@fhcon) { $_ =~ s/\/usr\/local\/freeiris/$info{'freeiris_target'}/g; print SAVE $_; } close(SAVE); } #设置mysql #------------------------------------------------------------------------------- &println('step',"database configuration..."); if (-e"$Bin/doc/database") { &println('response',"Auto Create tables......"); system("$info{'mysql_cmd'} --host $info{'dbhost'} --port=$info{'dbport'} --database=$info{'dbname'} --user=$info{'dbuser'} --password=$info{'dbpasswd'} < $Bin/doc/database"); } &println('response',"saving database config to freeiris and asterisk !......"); my $freeiris_conf = new Asterisk::config(file=>$info{'freeiris_target'}.'/etc/freeiris/freeiris.conf'); $freeiris_conf->assign_editkey(section=>'general',key=>'dbhost',new_value=>$info{'dbhost'}); $freeiris_conf->assign_editkey(section=>'general',key=>'dbuser',new_value=>$info{'dbuser'}); $freeiris_conf->assign_editkey(section=>'general',key=>'dbpasswd',new_value=>$info{'dbpasswd'}); $freeiris_conf->assign_editkey(section=>'general',key=>'dbname',new_value=>$info{'dbname'}); $freeiris_conf->assign_editkey(section=>'general',key=>'dbport',new_value=>$info{'dbport'}); $freeiris_conf->assign_editkey(section=>'general',key=>'freeiris_root',new_value=>$info{'freeiris_target'}); $freeiris_conf->assign_editkey(section=>'general',key=>'asterisk_conf',new_value=>$info{'asterisk_conf'}); $freeiris_conf->save_file(); my $cdr_mysql_conf = new Asterisk::config(file=>$info{'asterisk_conf'}.'/cdr_mysql.conf'); $cdr_mysql_conf->assign_editkey(section=>'global',key=>'hostname',new_value=>$info{'dbhost'}); $cdr_mysql_conf->assign_editkey(section=>'global',key=>'user',new_value=>$info{'dbuser'}); $cdr_mysql_conf->assign_editkey(section=>'global',key=>'password',new_value=>$info{'dbpasswd'}); $cdr_mysql_conf->assign_editkey(section=>'global',key=>'dbname',new_value=>$info{'dbname'}); $cdr_mysql_conf->assign_editkey(section=>'global',key=>'port',new_value=>$info{'dbport'}); $cdr_mysql_conf->save_file(); $info{'good_msg'} .= "initializtion mysql database\n"; #设置默认系统语言环境 &println('step',"setting language enviroment..."); my $freeiris_conf = new Asterisk::config(file=>$info{'freeiris_target'}.'/etc/freeiris/freeiris.conf'); $freeiris_conf->assign_editkey(section=>'web',key=>'language',new_value=>$info{'language'}); $freeiris_conf->save_file(); &println('response',"current web display language is ".$info{'language'}); #设置自动启动 &println('step',"saving freeirisd services..."); if ($info{'publish'} eq 'redhat') { &println('response',"Install Freeiris Stuff Daemon Services into Init.d"); $info{'good_msg'} .= "Installed freeirisd.sh to chkconfig and 345 on\n"; system("cp -pRf $Bin/utils/freeirisd.sh /etc/init.d/"); system("chmod 755 /etc/init.d/freeirisd.sh"); system("chkconfig --add freeirisd.sh"); # system("chcon -t texrel_shlib_t /astercon2/usr/lib/asterisk/modules/*.so"); #修改自动启动 if ($info{'freeiris_target'} ne '/usr/local/freeiris') { open(READ,"/etc/init.d/freeirisd.sh") or die "can't open /etc/init.d/freeirisd.sh : $!"; my @fhcon=; close(READ); open(SAVE,">/etc/init.d/freeirisd.sh") or die "can't write /etc/init.d/freeirisd.sh : $!"; foreach (@fhcon) { $_ =~ s/\/usr\/local\/freeiris/$info{'freeiris_target'}/g; print SAVE $_; } close(SAVE); } } elsif ($info{'os'} eq 'linux') { my $rclocal; $rclocal = '/etc/rc.d/rc.local' if (-e'/etc/rc.d/rc.local'); $rclocal = '/etc/rc.local' if (-e'/etc/rc.local'); if ($rclocal ne '') { &println('response',"Install Freeiris Stuff Daemon Services into $rclocal"); $info{'good_msg'} .= "Installed freeirisd to rc.local\n"; my $rclocal_file = `cat $rclocal`; if ($rclocal_file !~ /freeirisd/) { my @rclf = split(/\n/,$rclocal_file); open(ASTCONSD,">$rclocal") or die "Can't Write $rclocal: $!"; for (my $i=0;$i<=$#rclf ;$i++) { print ASTCONSD "\n$info{'freeiris_target'}/bin/freeirisd &\n" if ($i==1); print ASTCONSD $rclf[$i]."\n"; } close(ASTCONSD); } } else { $info{'end_msg'} .= qq~You need to auto start : $info{'freeiris_target'}/bin/freeirisd & ~; } } else { $info{'end_msg'} .= qq~You need to auto start : $info{'freeiris_target'}/bin/freeirisd & ~; } &println('step',"Install completed!\n"); print "\n------------------------------------------------------------------\n"; print $info{'good_msg'}; print "------------------------------------------------------------------\n\n"; print qq~----------------------------------------------- - - - Freeiris Opensource Telephony Project - - - - Installed on your system! - - - - admin panel : - - http://yourhost/freeiris/adminp.do - - default user : admin - - default password : admin - - - - you many need to reboot!!! - - - - - - - - - - Freeiris Development Team. hoowa sun - - - - www.freeiris.org - - - ----------------------------------------------- ~; if ($info{'end_msg'} ne '') { print "\n\n\n------------------------------------------------------------------\n"; print "WARNNING : \n"; print $info{'end_msg'}; print "\n------------------------------------------------------------------\n"; } return(); } sub app_usage { &println(undef,qq~ usage: ./setup [options] --help This help screen --input input handle default STDIN --output output handle default STDOUT --errput errput handle default STDERR --autoconf need file name for No ask mode auto intstall, --autoconf=./utils/redhat.fac Warnning! autoconf without any checking only for advance users. ~); exit; } # wirless sub println { my $type = shift; my $msg = shift; if ($type eq 'step') { print $OUTPUT "\n[STEP] $msg\n"; } elsif ($type eq 'input') { print $OUTPUT " [INPUT] $msg"; } elsif ($type eq 'response') { print $OUTPUT " [RESPONSE] $msg\n"; } elsif ($type eq 'failed') { print $OUTPUT " [FAILED] $msg\n"; } elsif ($type eq 'error') { print $ERRPUT "\n[ERROR] $msg\n\n"; exit; } else { print $OUTPUT "$msg\n"; } return(); } sub getopts { my %OPTIONS; for (my $i=0;$i<=$#ARGV ;$i++) { my ($key,$value)=split(/\=/,$ARGV[$i]); $key=~s/\-\-//; $OPTIONS{$key}=$value; } return(\%OPTIONS); } sub config_parse { my (%CONFIG,$last_section); open(CONF,"$_[0]") or die "Can't Open $_[0] : $!"; while () { # trim chomp($_); $_ =~ s/\;(.*)//; next if ($_ eq ''); if ($_ =~ /\[(.+)\]/) { $last_section=$1; $CONFIG{$last_section}={}; next; } if ($_ =~ /(.+)\=\>(.+)/ || $_ =~ /(.+)\=(.+)/) { my $key = $1; my $value = $2; chomp($key); $key =~ s/^\s+//; $key =~ s/\s+$//; chomp($value); $value =~ s/^\s+//; $value =~ s/\s+$//; $CONFIG{$last_section}{$key}=$value; } } close(CONF); return(\%CONFIG); } sub del_dir { my $old_target = shift; system("rm -rf $old_target"); system("rm -rf /etc/freeiris"); &println('response',"The old version had been removed! \n We'll install a new version now \n"); return(); } exit;