Author Topic: OpenVZ with CWP  (Read 813 times)

0 Members and 1 Guest are viewing this topic.

Offline
*
OpenVZ with CWP
« on: March 12, 2017, 03:54:42 PM »
Hello people,
As for now that you can use CWP just for shared hosting I decided to create a module for OpenVZ with some functions:
Admin Panel:
1. Install OpenVZ on your system (keep in mind that installing OpenVZ requires reboot for new kernel!!!)
2. Create containers
3. Set IPv4 & IPv6 to the containers
User Panel:
1. Boot container
2. Shutdown container
3. Reboot container
4. Reinstall container
5. SSH Console to the container through CWP
6. Change hostname
7. Change root password
I will also try to make a module where you add more servers and you create/delete containers through just 1 main CWP.
I also have plan to make the same for KVM and Xen, but I`m still waiting for 2x Dell PowerEdge 1950 and 1x Dell PowerEdge 2950(I know they are old rigs, but are good for testing) from UK and for the moment I have a free server which supports only OpenVZ.
All the scripts/modules will be provided for FREE FOREVER from me, but ionCube crypted. Some people will say "I want open source". I don`t agree with that since I saw a post in the forum that somebody want to change the logo of CWP and I don`t like that when somebody is offering something good to you for free you want to change logo/copyright to sign it on your name.I will provide my full source code unencrypted to CWP developers if they want to improve it or add it to a new version(I know that my way of writing PHP code sux, so may be they will rewrite it full, but ... ).
If you have any ideas what else can be added for OpenVZ I will be happy if you share them with me.
Thank you for reading and wait for the first release.
Current uptime:

Offline
*
Re: OpenVZ with CWP
« Reply #1 on: March 14, 2017, 07:47:28 AM »
Got some strange problem on the admin panel:
Code: [Select]
$root_file = "/root/.my.cnf"; -> From which file to get mysql password
$lines = file($root_file); -> Open file
list($password, $pass) = explode("=", $lines[1]); -> Get the password after =
$sql = new mysqli('localhost', 'root', $pass, 'root_cwp'); -> Making connection to the database(as the example in php.net)

if (!$sql) { -> Checking if connection was successful
    echo "Error: Unable to connect to MySQL." . PHP_EOL; -> Error message
    echo "<br>Debugging errno: " . mysqli_connect_errno() . PHP_EOL; -> Error number
    echo "<br>Debugging error: " . mysqli_connect_error() . PHP_EOL; -> Error
    exit;
}

$query = "SELECT username FROM user ORDER BY id"; -> Query
$result = mysqli_query($sql, $query); -> Execute query
while ($row = mysqli_fetch_array($result)) { -> Fetching the array
        $user = '<option value=". $row[\'username\'] .">'; -> Setting $user for dropdown menu
    }

And here comes the error:
Code: [Select]
Warning: mysqli::__construct(): (HY000/1045): Access denied for user 'root'@'localhost' (using password: YES) in /usr/local/cwpsrv/htdocs/resources/admin/modules/openvz_cct.php on line 52I checked error 1045 in MariaDB.com:
Code: [Select]
1045 28000 ER_ACCESS_DENIED_ERROR Access denied for user '%s'@'%s' (using password: %s)Maybe because the last 2 days I slept only 2 hours and I`m making a mistake which I can`t see. If somebody see it please correct me. Will be appreciated.
Current uptime:

Offline
*
Re: OpenVZ with CWP
« Reply #2 on: March 14, 2017, 12:00:50 PM »
when using files from linux (like password from a file) you should check that there is no new lines, empty spaces....
AntiDDoS Protection (web + mail)
http://centos-webpanel.com/website-ddos-protection-proxy

Join our Development Team and get paid !
http://centos-webpanel.com/develope-modules-for-cwp


Services Monitoring & RBL Monitoring
http://centos-webpanel.com/services-monitor


Do you need Fast and FREE Support included for your CWP linux server?
http://centos-webpanel.com/noc-partner-list
Installation Instructions
http://centos-webpanel.com/installation-instructions
Get Fast Support Here
http://centos-webpanel.com/support-services

Offline
*
Re: OpenVZ with CWP
« Reply #3 on: March 14, 2017, 12:05:04 PM »
Ok, I didn`t go to sleep. I continued to try to fix my error, but I`m still stuck. I wrote down the things new way using PDO, but now I got a new error:
Code: [Select]
$file = "/root/.my.cnf";
$lines = file($file);
list($password, $pass) = explode("=", $lines[1]);
class Database{
    // specify your own database credentials
    private $host = "127.0.0.1";
    private $db_name = "root_cwp";
    private $username = "root";
    private $password = $pass; -> Line 13 making the error;
    public $conn;

    // get the database connection
    public function getConnection(){

        $this->conn = null;

        try{
            $this->conn = new PDO("mysql:host=" . $this->host . ";dbname=" . $this->db_name, $this->username, $this->password);
        }catch(PDOException $exception){
            echo "Connection error: " . $exception->getMessage();
        }

        return $this->conn;
    }
}
And in one moment:
Code: [Select]
Fatal error: Constant expression contains invalid operations in /usr/local/cwpsrv/htdocs/resources/admin/modules/database.php on line 13
Never got an error like that before, so please somebody help me with it.
Current uptime:

Offline
*
Re: OpenVZ with CWP
« Reply #4 on: March 14, 2017, 12:10:50 PM »
when using files from linux (like password from a file) you should check that there is no new lines, empty spaces....
When I use that way:
Code: [Select]
$file = "/root/.my.cnf";
$lines = file($file);
list($password, $pass) = explode("=", $lines[1]);
The command echo returns everything that I need:
Code: [Select]
echo $pass; returns the password for MariaDB(MySQL) from the file. But using it with connection function/class gives an error.
Current uptime:

Offline
*
Re: OpenVZ with CWP
« Reply #5 on: March 18, 2017, 09:05:04 PM »
Sorry guys, I've been busy last days with one of my companies and I didn't had time to continue with OpenVZ. Next few days I'll try to find some free time and to finish the admin panel at least. With the speed the project is going and with the no free time I've got ... I see the first release around june. Sorry about that. I will keep you informed how is it going.
Current uptime:

Offline
*
Re: OpenVZ with CWP
« Reply #6 on: April 04, 2017, 07:56:31 PM »
Ok, guys, some bad news. As I see you can`t install OpenVZ on CentOS 7.x:
Code: [Select]
---> Package vzkernel.x86_64 0:2.6.32-042stab120.20 will be installed
--> Processing Dependency: /sbin/mkinitrd for package: vzkernel-2.6.32-042stab120.20.x86_64
--> Processing Dependency: /sbin/mkinitrd for package: vzkernel-2.6.32-042stab120.20.x86_64

Packages skipped because of dependency problems:
    vzkernel-2.6.32-042stab120.20.x86_64 from openvz-kernel-rhel6
[root@odyn ~]#

It`s not supported anymore. You have to install virtualizor or proxmox. Both I don`t like. So we keep up to CentOS 6.8 (Final) even after it`s EOL.
Current uptime:

Offline
*
Re: OpenVZ with CWP
« Reply #7 on: June 23, 2017, 01:58:56 AM »
Hello again from me. After "rm -rf /" few times on the developing machine because I got angry on the OpenVZ, vzctl and php<->bash, last night around 4:30 I started from zero. The admin panel is ready up to: view VMs, start VM, stop VM, suspend VM and delete(destroy) VM. Create VM is done on 40%. This is ready in 2h. Everything is responsive, so it`s supposed to be available to be looking good on mobile devices.  If the VM is stopped you will see only "Start" button, if the VM is started you will see only "Stop" button. The same for suspend/unsuspend. I will post few images on saturday or sunday, because now I am far away from the developing machine and I don`t have access to it(only local).
Current uptime: