Skip to content

Commit

Permalink
Merge pull request #478 from andreapollastri/4.x
Browse files Browse the repository at this point in the history
Server Name + Stats and Installation Fix
  • Loading branch information
andreapollastri authored Mar 17, 2024
2 parents 542b5f7 + 0df15bc commit 320f6ff
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,6 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
VITE_APP_NAME="${APP_NAME}"

PANEL_SERVER_IP=changeme
PANEL_SERVER_NAME=changeme
PANEL_CIPI_PASSWORD=changeme
PANEL_MYSQL_PASSWORD=changeme
14 changes: 7 additions & 7 deletions app/Filament/Widgets/StatsOverview.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Filament\Widgets;

use App\Models\Site;
use App\Models\Stat as StatModel;
use Filament\Widgets\StatsOverviewWidget as BaseWidget;
use Filament\Widgets\StatsOverviewWidget\Stat;
Expand All @@ -12,9 +13,9 @@ class StatsOverview extends BaseWidget

protected function getStats(): array
{
$ip = '123.123.123.123'; // TODO: Get server IP
$name = 'Staging VPS'; // TODO: Get server name
$sites = 23; // TODO: Get number of sites
$ip = config('panel.serverIp');
$name = config('panel.serverName');
$sites = Site::count();
$stats = StatModel::latest()->first();
$chart = StatModel::limit(120)
->orderBy('created_at', 'desc')
Expand All @@ -30,18 +31,17 @@ protected function getStats(): array
Stat::make('Sites', $sites)
->description('Hosted sites')
->descriptionIcon('heroicon-m-computer-desktop'),
Stat::make('CPU', $stats->cpu.'%')
Stat::make('CPU', (isset($stats->cpu)) ? $stats->cpu : '0'.'%')
->description('CPU usage')
->descriptionIcon('heroicon-m-cpu-chip')
->chart($chart->pluck('cpu')->reverse()->toArray()),
Stat::make('RAM', $stats->ram.'%')
Stat::make('RAM', (isset($stats->ram)) ? $stats->ram : '0'.'%')
->description('RAM usage')
->descriptionIcon('heroicon-m-rectangle-stack')
->chart($chart->pluck('ram')->reverse()->toArray()),
Stat::make('HDD', $stats->hdd)
Stat::make('HDD', (isset($stats->hdd)) ? $stats->hdd : '0%')
->description('HDD usage')
->descriptionIcon('heroicon-m-server'),

];
}
}
2 changes: 2 additions & 0 deletions config/panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@
],
'force_2fa' => env('PANEL_FORCE_2FA', false),
'ip_dns_mapping' => env('PANEL_IP_DNS_MAPPING', '.sslip.io'),
'serverIp' => env('PANEL_SERVER_IP'),
'serverName' => env('PANEL_SERVER_NAME'),
];
18 changes: 7 additions & 11 deletions go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ sleep 1s
CREATE DATABASE IF NOT EXISTS cipi;
EOF
clear

sudo rm -rf /var/www/html
cd /var/www && git clone https://github.com/$GITREPOSITORY.git html
cd /var/www/html && git pull
Expand All @@ -523,22 +524,21 @@ sudo chmod -R o+w /var/www/html/bootstrap/cache
sudo chmod -R 775 /var/www/html/bootstrap/cache
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 775 /var/www/html
PANELSETUP=/var/www/panel.sh
sudo touch $PANELSETUP
sudo cat > $PANELSETUP <<EOF

cd /var/www/html && unlink .env
cd /var/www/html && cp .env.example .env
cd /var/www/html && composer install --no-interaction
sudo chown -R www-data:www-data /var/www/html
sudo su -l www-data -s /bin/bash -c "cd /var/www/html && composer install --no-interaction"
sudo su -l www-data -s /bin/bash -c "cd /var/www/html && php artisan key:generate"
rpl -i -w "APP_ENV=local" "APP_ENV=production" /var/www/html/.env
rpl -i -w "APP_DEBUG=true" "APP_DEBUG=false" /var/www/html/.env
rpl -i -w "APP_URL=http://localhost" "APP_URL=https://cipi-$SERVERIPWITHDASH$IPDOMAIN" /var/www/html/.env
rpl -i -w "DB_PASSWORD=changeme" "DB_PASSWORD=$DATABASEPASSWORD" /var/www/html/.env
rpl -i -w "PANEL_SERVER_IP=changeme" "PANEL_SERVER_IP=$SERVERIP" /var/www/html/.env
rpl -i -w "PANEL_SERVER_NAME=changeme" "PANEL_SERVER_NAME=cipi-$SERVERIPWITHDASH" /var/www/html/.env
rpl -i -w "PANEL_CIPI_PASSWORD=changeme" "PANEL_CIPI_PASSWORD=$USERPASSWORD" /var/www/html/.env
rpl -i -w "PANEL_MYSQL_PASSWORD=changeme" "PANEL_MYSQL_PASSWORD=$DATABASEPASSWORD" /var/www/html/.env
sudo su -l www-data -s /bin/bash -c "cd /var/www/html && composer install --no-interaction"
sudo su -l www-data -s /bin/bash -c "cd /var/www/html && php artisan key:generate"
cd /var/www/html && php artisan config:clear
cd /var/www/html && php artisan migrate --seed --force
cd /var/www/html && php artisan storage:link
Expand All @@ -547,10 +547,8 @@ cd /var/www/html && php artisan route:cache
cd /var/www/html && php artisan view:cache
cd /var/www/html && php artisan optimize
sudo chown -R www-data:www-data /var/www/html
EOF
su -c "sh $PANELSETUP" cipi
sudo unlink $PANELSETUP

sudo chmod -R 775 /var/www/html
git config --global --add safe.directory /var/www/html


# FINE TUNING
Expand All @@ -560,8 +558,6 @@ echo "Fine tuning..."
echo "${reset}"
sleep 1s

sudo chown www-data:www-data -R /var/www/html
sudo chmod -R 775 /var/www/html
sudo echo 'DefaultStartLimitIntervalSec=1s' >> /usr/lib/systemd/system/user@.service
sudo echo 'DefaultStartLimitBurst=50' >> /usr/lib/systemd/system/user@.service
sudo echo 'StartLimitBurst=0' >> /usr/lib/systemd/system/user@.service
Expand Down

0 comments on commit 320f6ff

Please sign in to comment.