Skip to content

Commit

Permalink
Merge pull request #328 from andreapollastri/3.x
Browse files Browse the repository at this point in the history
Fixes
  • Loading branch information
andreapollastri authored Dec 13, 2021
2 parents 725e321 + 712398e commit 3f3d881
Show file tree
Hide file tree
Showing 26 changed files with 245 additions and 143 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

(no unreleased versions)

## [3.1.11] - 2021-12-13

### Added
- Sites Log Rotation Logic

### Fixed
- Solved APP login issue
- Solved PHP switch error
- Cipi commands
- Composer Update
- Favicon
- Readme file
- Minor Fix

### Removed
- Unused namespaces

## [3.1.10] - 2021-12-11

### Fixed
Expand Down
25 changes: 13 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Visit website: https://cipi.sh
Cipi Documentation is available at: https://cipi.sh/docs.html.

## Installation
```
```bash
wget -O - https://cipi.sh/go.sh | bash
```
#### Installation on AWS
Expand All @@ -46,27 +46,28 @@ $ ssh ubuntu@<your server IP address>
$ ubuntu@aws:~$ sudo -s
$ root@aws:~# wget -O - https://cipi.sh/go.sh | bash
```
Remember to open ports: 22, 80 and 443.
Remember to open ports: 22, 80 and 443!

#### Installation Note
Before you can use Cipi, please make sure your server fulfils these requirements:

- Ubuntu 20.04 x86_64 LTS (Fresh installation)
- If the server is virtual (VPS), OpenVZ may not be supported (Kernel 2.6)
- If the server is virtual (VPS), OpenVZ may not be supported
- We are checking Cipi compatibility within Oracle / ARM (not full supported yet)

Hardware Requirement: More than 1GB of HDD / At least 1 core processor / 512MB minimum RAM / At least 1 public IP Address (NAT VPS is not supported) / External firewall / For VPS providers such as AWS, those providers already include an external firewall for your VPS. Please open port 22, 80 and 443 to install Cipi.
Hardware Requirement: More than 1GB of HD / At least 1 core processor / 512MB minimum RAM / At least 1 public IP Address (IPv6 and NAT VPS are not supported) / For VPS providers such as AWS, those providers already include an external firewall for your VPS. Please open port 22, 80 and 443 to install Cipi.

Installation may take up to about 30 minutes which may also depend on your server's internet speed. After the installation is completed, you are ready to use Cipi to manage your servers.

To correctly manage remote servers Cipi has to be on a public IP address. Do not use it in localhost!
To correctly manage remote servers Cipi has to be on a public IP address (IPv4). Do not use it in localhost!

## Cipi LEMP environment
- nginx: 1.18
- PHP-FPM: 8.1, 8.0, 7.4
- MySql: 8
- node: 16
- npm: 8
- Composer: 2.x
- Composer: 2

## Screenshots

Expand All @@ -80,16 +81,16 @@ To correctly manage remote servers Cipi has to be on a public IP address. Do not
Cipi is easy, stable, powerful and free for any personal and commercial use and it's a perfect alternative to Runcloud, Ploi.io, Serverpilot, Forge, Moss.sh and similar software...

## Mobile App
Christian Giupponi (co-founder of ZeroUno Agency - https://zerouno.io/) developed Cipi Mobile Application.<br>
ANDROID VERSION: https://play.google.com/store/apps/details?id=it.christiangiupponi.cipi<br>
IOS VERSION: Coming soon!<br><br>
Christian Giupponi (https://zerouno.io) has developed the Cipi Mobile App.<br>
Android: https://play.google.com/store/apps/details?id=it.christiangiupponi.cipi<br>
iOS: Coming soon!<br><br>

## Cipi Roadmap... what's next?

<h4>Version 4 on May 2022</h4>
- Cipi Version 4 (half 2022)
- Laravel 9 support
- Backup on s3
- Minor Improvements!
- Apps installer
- ...

## Contributing
Thank you for considering contributing to the Cipi Project (code, issues, feedbacks, stars, promo, beers) :)
Expand Down
3 changes: 0 additions & 3 deletions app/Console/Commands/ActiveSetupCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

namespace App\Console\Commands;

use App\Models\Server;
use phpseclib3\Net\SSH2;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;

class ActiveSetupCount extends Command
{
Expand Down
29 changes: 14 additions & 15 deletions app/Console/Commands/CipiUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Models\Server;
use phpseclib3\Net\SSH2;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Http;

class CipiUpdate extends Command
{
Expand Down Expand Up @@ -58,22 +57,22 @@ public function handle()
$server->save();
}

// 2021-12-10 and 2021-12-09 patches
$servers = Server::where('build', '<', '202112101')->get();
// 2021-12-10 and 2021-12-09 patches
$servers = Server::where('build', '<', '202112101')->get();

foreach ($servers as $server) {
$ssh = new SSH2($server->ip, 22);
$ssh->login('cipi', $server->password);
$ssh->setTimeout(360);
$ssh->exec('echo '.$server->password.' | sudo -S sudo wget '.config('app.url').'/sh/client-patch/202112101');
$ssh->exec('echo '.$server->password.' | sudo -S sudo dos2unix 202112101');
$ssh->exec('echo '.$server->password.' | sudo -S sudo bash 202112101');
$ssh->exec('echo '.$server->password.' | sudo -S sudo unlink 202112101');
$ssh->exec('exit');
foreach ($servers as $server) {
$ssh = new SSH2($server->ip, 22);
$ssh->login('cipi', $server->password);
$ssh->setTimeout(360);
$ssh->exec('echo '.$server->password.' | sudo -S sudo wget '.config('app.url').'/sh/client-patch/202112101');
$ssh->exec('echo '.$server->password.' | sudo -S sudo dos2unix 202112101');
$ssh->exec('echo '.$server->password.' | sudo -S sudo bash 202112101');
$ssh->exec('echo '.$server->password.' | sudo -S sudo unlink 202112101');
$ssh->exec('exit');

$server->build = '202112101';
$server->save();
}
$server->build = '202112101';
$server->save();
}

$server = Server::where('default', 1)->first();

Expand Down
59 changes: 59 additions & 0 deletions app/Console/Commands/LogRotate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace App\Console\Commands;

use App\Models\Server;
use phpseclib3\Net\SSH2;
use Illuminate\Console\Command;

class LogRotate extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'cipi:logrotate';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Site Log Rotation';

/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}

/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
$servers = Server::all();

foreach ($servers as $server) {
foreach ($server->sites as $site) {
$ssh = new SSH2($server->ip, 22);
$ssh->login('cipi', $server->password);
$ssh->setTimeout(360);
$ssh->exec('echo '.$server->password.' | sudo -S sudo unlink /home/'.$site->username.'/log/access_bk_'.date('N').'.log');
$ssh->exec('echo '.$server->password.' | sudo -S sudo mv /home/'.$site->username.'/log/access.log /home/'.$site->username.'/log/access_bk_'.date('N').'.log');
$ssh->exec('echo '.$server->password.' | sudo -S sudo unlink /home/'.$site->username.'/log/error_bk_'.date('N').'.log');
$ssh->exec('echo '.$server->password.' | sudo -S sudo mv /home/'.$site->username.'/log/error.log /home/'.$site->username.'/log/error_bk_'.date('N').'.log');
$ssh->exec('exit');
}
}

return 0;
}
}
9 changes: 5 additions & 4 deletions app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ class Kernel extends ConsoleKernel
* @var array
*/
protected $commands = [
//
\App\Console\Commands\ActiveSetupCount::class,
\App\Console\Commands\LogRotate::class,
\App\Console\Commands\ServerSetupCheck::class,
\App\Console\Commands\CipiUpdate::class,
];

/**
Expand All @@ -25,9 +28,8 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->command('servers:setupcheck')->everyMinute();

$schedule->command('cipi:update')->dailyAt('12:05');

$schedule->command('cipi:logrotate')->dailyAt('00:00');
$schedule->command('cipi:activesetupcount')->dailyAt('03:03');
}

Expand All @@ -39,7 +41,6 @@ protected function schedule(Schedule $schedule)
protected function commands()
{
$this->load(__DIR__.'/Commands');

require base_path('routes/console.php');
}
}
26 changes: 26 additions & 0 deletions app/Http/Controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,32 @@
class AuthController extends Controller
{

/**
* Auth login via username and password for mobile app
*
*/
public function appLogin(Request $request)
{
$request->validate([
'username' => 'required',
'password' => 'required',
]);

$user = Auth::attempt($request->username, $request->password);

if (!$user) {
return response()->json([
'message' => __('cipi.invalid_login_message'),
'errors' => __('cipi.invalid_login')
], 401);
}

return response()->json([
'username' => $user->username,
'apikey' => $user->apikey
]);
}

/**
* JWT Auth login via username and password
*
Expand Down
1 change: 0 additions & 1 deletion app/Http/Controllers/ShellController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace App\Http\Controllers;

use App\Models\Site;
use App\Models\Alias;
use App\Models\Server;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\Storage;
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/VerifyCsrfToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ class VerifyCsrfToken extends Middleware
* @var array
*/
protected $except = [
//
'app/login',
];
}
1 change: 0 additions & 1 deletion app/Jobs/DeleteAliasSSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use App\Models\Alias;
use phpseclib3\Net\SSH2;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
Expand Down
1 change: 0 additions & 1 deletion app/Jobs/DeleteSiteSSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use App\Models\Site;
use phpseclib3\Net\SSH2;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
Expand Down
1 change: 0 additions & 1 deletion app/Jobs/EditSiteBasepathSSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use App\Models\Site;
use phpseclib3\Net\SSH2;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
Expand Down
1 change: 0 additions & 1 deletion app/Jobs/EditSiteDeploySSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use App\Models\Site;
use phpseclib3\Net\SSH2;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
Expand Down
1 change: 0 additions & 1 deletion app/Jobs/EditSiteDomainSSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use App\Models\Site;
use phpseclib3\Net\SSH2;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
Expand Down
3 changes: 2 additions & 1 deletion app/Jobs/EditSitePhpSSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use App\Models\Site;
use phpseclib3\Net\SSH2;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
Expand Down Expand Up @@ -41,8 +40,10 @@ public function handle()
$ssh->login('cipi', $this->site->server->password);
$ssh->setTimeout(360);
$ssh->exec('echo '.$this->site->server->password.' | sudo -S sudo rpl -i "php'.$this->oldphp.'-fpm" "php'.$this->site->php.'-fpm" /etc/nginx/sites-available/'.$this->site->username.'.conf');
$ssh->exec('echo '.$this->site->server->password.' | sudo -S sudo rpl -i "php'.$this->oldphp.'-fpm" "php'.$this->site->php.'-fpm" /etc/nginx/sites-enabled/'.$this->site->username.'.conf');
foreach ($this->site->aliases as $alias) {
$ssh->exec('echo '.$this->site->server->password.' | sudo -S sudo rpl -i "php'.$this->oldphp.'-fpm" "php'.$this->site->php.'-fpm" /etc/nginx/sites-available/'.$alias->domain.'.conf');
$ssh->exec('echo '.$this->site->server->password.' | sudo -S sudo rpl -i "php'.$this->oldphp.'-fpm" "php'.$this->site->php.'-fpm" /etc/nginx/sites-enabled/'.$alias->domain.'.conf');
}
$ssh->exec('echo '.$this->site->server->password.' | sudo -S sudo mv /etc/php/'.$this->oldphp.'/fpm/pool.d/'.$this->site->username.'.conf /etc/php/'.$this->site->php.'/fpm/pool.d/'.$this->site->username.'.conf');
$ssh->exec('echo '.$this->site->server->password.' | sudo -S sudo rpl "listen = /run/php/php'.$this->oldphp.'-fpm-'.$this->site->username.'.sock" "listen = /run/php/php'.$this->site->php.'-fpm-'.$this->site->username.'.sock" /etc/php/'.$this->site->php.'/fpm/pool.d/'.$this->site->username.'.conf');
Expand Down
1 change: 0 additions & 1 deletion app/Jobs/EditSiteSupervisorSSH.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Jobs;

use App\Models\Site;
use phpseclib3\Net\SSH2;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
Expand Down
3 changes: 1 addition & 2 deletions app/Models/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Models;

use App\Models\Cron;
use App\Models\Site;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
Expand All @@ -18,7 +17,7 @@ class Server extends Model
'created_at',
'updated_at'
];

public function sites()
{
return $this->hasMany(Site::class)->where('panel', false);
Expand Down
Loading

0 comments on commit 3f3d881

Please sign in to comment.