mirror of
https://github.com/mivodev/mivo.git
synced 2026-01-26 05:25:42 +07:00
feat: Implement an installation process including a setup UI, database migrations, and admin account creation.
This commit is contained in:
@@ -54,8 +54,20 @@ fi
|
|||||||
# 4. Set Permissions
|
# 4. Set Permissions
|
||||||
echo "Step 4: Setting permissions..."
|
echo "Step 4: Setting permissions..."
|
||||||
chown -R www:www .
|
chown -R www:www .
|
||||||
|
chmod -R 755 .
|
||||||
chmod +x mivo
|
chmod +x mivo
|
||||||
chmod -R 755 public
|
chmod -R 755 public
|
||||||
|
|
||||||
|
# Ensure Database directory is writable
|
||||||
|
if [ ! -d "app/Database" ]; then
|
||||||
|
mkdir -p app/Database
|
||||||
|
chown www:www app/Database
|
||||||
|
fi
|
||||||
|
chmod 775 app/Database
|
||||||
|
if [ -f "app/Database/database.sqlite" ]; then
|
||||||
|
chmod 664 app/Database/database.sqlite
|
||||||
|
fi
|
||||||
|
|
||||||
# If there's a storage directory (MVC style usually has one)
|
# If there's a storage directory (MVC style usually has one)
|
||||||
if [ -d "storage" ]; then
|
if [ -d "storage" ]; then
|
||||||
chmod -R 775 storage
|
chmod -R 775 storage
|
||||||
|
|||||||
@@ -15,8 +15,12 @@ class InstallController extends Controller {
|
|||||||
header('Location: /login');
|
header('Location: /login');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$permissions = $this->checkPermissions();
|
||||||
|
|
||||||
return $this->view('install');
|
return $this->view('install', [
|
||||||
|
'permissions' => $permissions
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function process() {
|
public function process() {
|
||||||
@@ -25,6 +29,13 @@ class InstallController extends Controller {
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$permissions = $this->checkPermissions();
|
||||||
|
if (!$permissions['db_writable'] || !$permissions['root_writable']) {
|
||||||
|
\App\Helpers\FlashHelper::set('error', 'Izin Ditolak', 'Pastikan folder app/Database dan root direktori dapat ditulis oleh server web.');
|
||||||
|
header('Location: /install');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
$username = $_POST['username'] ?? 'admin';
|
$username = $_POST['username'] ?? 'admin';
|
||||||
$password = $_POST['password'] ?? 'admin';
|
$password = $_POST['password'] ?? 'admin';
|
||||||
|
|
||||||
@@ -63,6 +74,17 @@ class InstallController extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function checkPermissions() {
|
||||||
|
$dbDir = ROOT . '/app/Database';
|
||||||
|
$envFile = ROOT . '/.env';
|
||||||
|
|
||||||
|
return [
|
||||||
|
'db_writable' => is_writable($dbDir),
|
||||||
|
'env_writable' => file_exists($envFile) ? is_writable($envFile) : is_writable(ROOT),
|
||||||
|
'root_writable' => is_writable(ROOT)
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
private function isInstalled() {
|
private function isInstalled() {
|
||||||
// Check if .env exists and APP_KEY is set to something other than the default/example
|
// Check if .env exists and APP_KEY is set to something other than the default/example
|
||||||
$envPath = ROOT . '/.env';
|
$envPath = ROOT . '/.env';
|
||||||
|
|||||||
0
app/Database/.gitkeep
Normal file
0
app/Database/.gitkeep
Normal file
@@ -20,6 +20,26 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card p-6 sm:p-8 space-y-6">
|
<div class="card p-6 sm:p-8 space-y-6">
|
||||||
|
<?php if (isset($permissions) && (!$permissions['db_writable'] || !$permissions['root_writable'])): ?>
|
||||||
|
<div class="bg-red-500/10 border border-red-500/20 rounded-lg p-4 mb-6">
|
||||||
|
<div class="flex items-center gap-3 text-red-500 mb-2">
|
||||||
|
<i class="ph-bold ph-warning text-lg"></i>
|
||||||
|
<h4 class="font-bold text-sm">Peringatan Izin Direktori</h4>
|
||||||
|
</div>
|
||||||
|
<ul class="text-xs text-red-400 space-y-1 list-disc list-inside">
|
||||||
|
<?php if (!$permissions['db_writable']): ?>
|
||||||
|
<li>Folder <code>app/Database</code> harus writable (chmod 775/777).</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (!$permissions['root_writable']): ?>
|
||||||
|
<li>Root direktori harus writable untuk membuat file <code>.env</code>.</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
</ul>
|
||||||
|
<p class="text-[10px] text-red-400/70 mt-3 pt-3 border-t border-red-500/10">
|
||||||
|
Silakan perbaiki izin folder di server Anda sebelum melanjutkan.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<form action="/install" method="POST" class="space-y-6">
|
<form action="/install" method="POST" class="space-y-6">
|
||||||
|
|
||||||
<!-- Steps UI -->
|
<!-- Steps UI -->
|
||||||
|
|||||||
Reference in New Issue
Block a user