Kaydet (Commit) 144b899d authored tarafından mertcelen's avatar mertcelen

Force extension dependency install added.

Force extension enable added.
Postgresql notification crash fixed.
Postgresql date problem fixed.
Extension  dependency installation command now uses --allow.
Postgresql automatic install added.
Default postgresql configuration updated.
üst bd220c0a
......@@ -25,4 +25,11 @@ MARKET_URL=https://market.liman.dev
MARKET_CLIENT_ID=
MARKET_CLIENT_SECRET=
RENDER_ENGINE_ADDRESS=https://127.0.0.1:5454
\ No newline at end of file
RENDER_ENGINE_ADDRESS=https://127.0.0.1:5454
DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=liman
DB_USERNAME=liman
DB_PASSWORD=
......@@ -29,6 +29,7 @@ jobs:
repository: limanmys/go
path: render_engine
token: ${{ secrets.CI_TOKEN }}
ref: "postgresql"
- uses: actions/cache@v2
with:
path: ~/.npm
......@@ -98,7 +99,7 @@ jobs:
Architecture: amd64
Priority: important
Description: Liman MYS
Depends: gpg, zip, unzip, nginx, redis, php-redis, php7.3-fpm, php7.3-curl, php7.3, php7.3-sqlite3, php7.3-snmp, php7.3-mbstring, php7.3-xml, php7.3-zip, php7.3-posix, libnginx-mod-http-headers-more-filter, libssl1.1, supervisor
Depends: gpg, zip, unzip, nginx, redis, php-redis, php7.3-fpm, php7.3-curl, php7.3, php7.3-sqlite3, php7.3-snmp, php7.3-mbstring, php7.3-xml, php7.3-zip, php7.3-posix, libnginx-mod-http-headers-more-filter, libssl1.1, supervisor, postgresql, php7.3-pgsql, pgloader
""" > DEBIAN/control
cd ../
dpkg-deb -Zgzip --build package
......
......@@ -23,3 +23,4 @@ config/liman.php
storage/extension_updates
storage/docs
public/docs
storage/liman_render
\ No newline at end of file
......@@ -15,6 +15,9 @@ use Illuminate\Support\Str;
use mervick\aesEverywhere\AES256;
use GuzzleHttp\Client;
use App\Models\Token;
use App\Jobs\ExtensionDependenciesJob;
use Illuminate\Contracts\Bus\Dispatcher;
use App\Models\AdminNotification;
/**
* Class OneController
......@@ -200,6 +203,63 @@ class OneController extends Controller
]);
}
public function forceEnableExtension()
{
$flag =extension()->update([
"status" => "1"
]);
if($flag){
return respond("Eklenti başarıyla aktifleştirildi!");
}else{
return respond("Eklenti aktifleştirilirken bir hata oluştu!",201);
}
}
public function forceDepInstall()
{
$flag =extension()->update([
"status" => "0"
]);
$file = file_get_contents("/liman/extensions/" .strtolower(extension()->name) . "/db.json");
$json = json_decode($file,true);
if(json_last_error() != JSON_ERROR_NONE){
return respond("Eklenti dosyası okunurken bir hata oluştu!",201);
}
if (array_key_exists("dependencies",$json) && $json["dependencies"] != ""){
$job = (new ExtensionDependenciesJob(
extension(),
$json["dependencies"]
))->onQueue('system_updater');
// Dispatch job right away.
$job_id = app(Dispatcher::class)->dispatch($job);$job = (new ExtensionDependenciesJob(
extension(),
$json["dependencies"]
))->onQueue('system_updater');
// Dispatch job right away.
$job_id = app(Dispatcher::class)->dispatch($job);
AdminNotification::create([
"title" =>
extension()->display_name . " eklentisinin bağımlılıkları yükleniyor!",
"type" => "",
"message" =>
extension()->display_name .
" eklentisinin bağımlılıkları yükleniyor, bu süre içerisinde eklentiyi kullanamazsınız.",
"level" => 3,
]);
return respond("İşlem başlatıldı!");
}else{
return respond("Bu eklentinin hiçbir bağımlılığı yok!",201);
}
}
/**
* @return JsonResponse|Response
*/
......
......@@ -33,6 +33,16 @@ Route::post(
'Extension\SettingsController@allServersApi'
)->name('extensions_api');
Route::post(
'/ayarlar/eklenti/zorlaBagimlilikKur',
'Extension\OneController@forceDepInstall'
)->name('extension_force_dep_install')->middleware("admin");
Route::post(
'/ayarlar/eklenti/zorlaAktiflestir',
'Extension\OneController@forceEnableExtension'
)->name('extension_force_enable')->middleware("admin");
// Extension Details Route
Route::get(
'/eklentiler/{extension_id}',
......
......@@ -382,7 +382,7 @@ if (!function_exists('adminNotifications')) {
function adminNotifications()
{
return AdminNotification::where([
"read" => "false",
"read" => false,
])
->orderBy('updated_at', 'desc')
->get();
......@@ -782,6 +782,7 @@ if (!function_exists('setEnv')) {
return false;
}
shell_exec('php /liman/server/artisan config:clear');
shell_exec("sed -i -e :a -e '/^\n*$/{\$d;N;ba' -e '}' /liman/server/.env");
return true;
}
}
......
......@@ -37,7 +37,7 @@ class ExtensionDependenciesJob implements ShouldQueue
{
$package = $this->dependencies;
$tmp = "/tmp/" . str_random(16);
$installCommand = "if [ -z '\$(find /var/cache/apt/pkgcache.bin -mmin -60)' ]; then sudo apt-get update; fi;DEBIAN_FRONTEND=noninteractive sudo apt-get install -o Dpkg::Use-Pty=0 -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' $package -qqy --force-yes >" . $tmp . " 2>&1";
$installCommand = "if [ -z '\$(find /var/cache/apt/pkgcache.bin -mmin -60)' ]; then sudo apt-get update; fi;DEBIAN_FRONTEND=noninteractive sudo apt-get install -o Dpkg::Use-Pty=0 -o Dpkg::Options::='--force-confdef' -o Dpkg::Options::='--force-confold' $package -qqy --allow >" . $tmp . " 2>&1";
rootSystem()->runCommand($installCommand);
$checkCommand = "dpkg --get-selections | grep -v deinstall | awk '{print $1}' | grep -xE '" . str_replace(" ","|", $package) ."'";
$installed = rootSystem()->runCommand($checkCommand);
......
......@@ -24,4 +24,9 @@ trait UsesUuid
{
return 'string';
}
public function getDateFormat()
{
return 'Y-m-d H:i:sO';
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -58,8 +58,8 @@ return [
'driver' => 'pgsql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'database' => env('DB_DATABASE', 'liman'),
'username' => env('DB_USERNAME', 'liman'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'prefix' => '',
......
......@@ -40,6 +40,14 @@
"target" => "addLicenseToExtension",
"icon" => " context-menu-icon-add"
],
"Bağımlılıkları Yükle" => [
"target" => "forceInstallDepencencies",
"icon" => "fa-box-open"
],
"Zorla Aktifleştir" => [
"target" => "forceActivateExtension",
"icon" => "fa-check-double"
],
"Sil" => [
"target" => "delete",
"icon" => " context-menu-icon-delete"
......@@ -60,6 +68,30 @@
"submit_text" => "Ekle"
])
@include('modal',[
"id"=>"forceActivateExtension",
"title" => "Zorla Aktifleştir",
"text" => "Bu eklentiyi zorla aktifleştirmek istediğinize emin misiniz?",
"url" => route('extension_force_enable'),
"next" => "reload",
"inputs" => [
"extension_id:extension_id" => "extension_id:hidden"
],
"submit_text" => "Aktifleştir"
])
@include('modal',[
"id"=>"forceInstallDepencencies",
"title" => "Bağımlılıkları Yükle",
"text" => "Bu eklentinin bağımlılıklarını tekrar yüklemek istediğinize emin misiniz?",
"url" => route('extension_force_dep_install'),
"next" => "reload",
"inputs" => [
"extension_id:extension_id" => "extension_id:hidden"
],
"submit_text" => "Yükle"
])
@include('modal',[
"id"=>"extSettings",
"title" => "Ayarlar",
......
......@@ -49,10 +49,14 @@ fi
# Database Creation
if [ -f "/liman/database/liman.sqlite" ]; then
echo "Database file found."
else
touch /liman/database/liman.sqlite
chmod 700 /liman/database/liman.sqlite
sudo -u postgres createuser liman
sudo -u postgres createdb liman -O liman
RANDOM_PASSWORD=$(LC_ALL=C tr -dc 'A-Za-z0-9' </dev/urandom | head -c 25 ; echo)
sudo -u postgres psql -U postgres -d postgres -c "alter user \"liman\" with password '$RANDOM_PASSWORD';"
sed -i '/DB_PASSWORD/d' /liman/server/.env
printf "DB_PASSWORD=$RANDOM_PASSWORD\n" | tee -a /liman/server/.env
/usr/bin/pgloader /liman/server/storage/migration.load
mv /liman/database/liman.sqlite /liman/database/liman.sqlite.bak
fi
# Update Php and Fpm to run as liman user.
......
LOAD DATABASE
FROM sqlite:///liman/database/liman.sqlite
INTO postgresql:///liman
WITH include drop, create tables, create indexes,quote identifiers
CAST type datetime to timestamptz;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment