The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to add new scripts...

Discussion in 'cPanel Developers' started by azrael, Jan 29, 2004.

  1. azrael

    azrael Active Member

    Joined:
    Jul 20, 2003
    Messages:
    33
    Likes Received:
    0
    Trophy Points:
    6
    hint] How to add new scripts...

    1) install any scripts in WHM

    2) open /usr/local/cpanel/addon/

    3) pico install

    #!/usr/bin/perl

    BEGIN {
    push(@INC,"/usr/local/cpanel");
    }

    use SafeFile;

    #VARIBLES
    # <----Don't need modify ----
    my $domain = '%domain%';
    my $installpath = '%installpath%';
    my $modulename = '%modulename%';
    my $modulepath = '%modulepath%';
    my $homedir = '%homedir%';
    my $user = '%user%';
    my $installdir = '%installdir%';
    my $publichtml = '%public_html%';
    my $sqldb = '%sqldb%';
    my $sqluser = '%sqluser%';
    my $sqlpass = '%sqlpass%';
    my $sqlserver = '%sqlhost%';


    print "install at $installdir.\n";
    #----->

    system("mysql -u${sqluser} -p${sqlpass} ${sqldb} < $installdir/morning.sql");
    #<----- your scripts sql

    system("mv $installdir/pkg/* $installdir/");


    # regsrep("file to edit","old","new"); fuction can change your config file
    regsrep("$installdir/config_db.php","con_db_host","con_db_host=\"$sqlserver\";");
    # pls change config_db.php your config file
    #when row is the same "old", replace to "new"

    regsrep("$installdir/config_db.php","con_db_id","con_db_id=\"$sqluser\";");
    regsrep("$installdir/config_db.php","con_db_pass","con_db_pass=\"$sqlpass\";");
    regsrep("$installdir/config_db.php","con_db_name","con_db_name=\"$sqldb\";");
    #like this you can replace your files.


    unlink("$installdir/config_db.php.tmpeditlib");


    #do we need this?
    #regsrepunlink("$installdir/config.tmpeditlib");

    #chmod(707,"$installdir/session");
    #chmod(707,"$installdir/session/*");
    #chmod(707,"$installdir/board_data/*.php");

    #system("rm","-rf","$installdir/install");

    print "<br><br><b>Complete! </b><br>\n";

    #print "<br>You can access the admin interface at: <a href=\"http://$domain/$installpath/admin/\">http://${domain}${installpath}/admin/admin_setup.php</a> with the username: ${username}, and the password:
    #${password}.<br>\n";
    print "<br>access : <a href=\"http://${domain}${installpath}/admin.php\" target=_blank>http://${domain}${installpath}/admin.php</a><br><br>\n";

    # <----Don't modify ----
    sub regsrep {
    my($file,$old,$new) = @_;
    $filelock = SafeFile::safeopen(\*FH,"$file");
    $fileeditlock = SafeFile::safeopen(\*FHT,">$file.tmpeditlib");
    while(<FH>) {
    if ($_ =~ /^$/ || $_ eq "\n" || $_ eq "\r\n") {
    print FHT "$_";
    } elsif($_ =~ /$old/) {
    $result = $1;
    my $mnew = $new;
    $mnew =~ s/\$1/$result/g;
    print FHT "$mnew\n";
    } else {
    print FHT $_;
    }
    }
    SafeFile::safeclose(\*FH,$filelock);
    SafeFile::safeclose(\*FHT,$fileeditlock);
    $fileeditlock = SafeFile::safeopen(\*FHT,"$file.tmpeditlib");
    $filelock = SafeFile::safeopen(\*FH,">$file");
    while(<FHT>) { print FH $_ };
    SafeFile::safeclose(\*FH,$filelock);
    SafeFile::safeclose(\*FHT,$fileeditlock);
    }

    #--->

    4) pico cpanel-pkg

    5) gzip pkg
    tar -cvf your scripts
    gzip your scripts.tar

    6) Make install folder
    mkdir new_scripts
    cd new_scripts
    put in files and scripts.tar.gz
    you can put in license.txt(pls refer cpanel-pkg

    You can see them in usercp.

    sorry. I am not native....
     
    #1 azrael, Jan 29, 2004
    Last edited: Jan 30, 2004
Loading...

Share This Page