mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 22:15:51 +01:00
(refs #505)Disable the plugin system in default
This commit is contained in:
@@ -85,41 +85,55 @@ trait SystemSettingsControllerBase extends ControllerBase {
|
|||||||
})
|
})
|
||||||
|
|
||||||
get("/admin/plugins")(adminOnly {
|
get("/admin/plugins")(adminOnly {
|
||||||
val installedPlugins = plugin.PluginSystem.plugins
|
if(enablePluginSystem){
|
||||||
val updatablePlugins = getAvailablePlugins(installedPlugins).filter(_.status == "updatable")
|
val installedPlugins = plugin.PluginSystem.plugins
|
||||||
admin.plugins.html.installed(installedPlugins, updatablePlugins)
|
val updatablePlugins = getAvailablePlugins(installedPlugins).filter(_.status == "updatable")
|
||||||
|
admin.plugins.html.installed(installedPlugins, updatablePlugins)
|
||||||
|
} else NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/plugins/_update", pluginForm)(adminOnly { form =>
|
post("/admin/plugins/_update", pluginForm)(adminOnly { form =>
|
||||||
deletePlugins(form.pluginIds)
|
if(enablePluginSystem){
|
||||||
installPlugins(form.pluginIds)
|
deletePlugins(form.pluginIds)
|
||||||
redirect("/admin/plugins")
|
installPlugins(form.pluginIds)
|
||||||
|
redirect("/admin/plugins")
|
||||||
|
} else NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/plugins/_delete", pluginForm)(adminOnly { form =>
|
post("/admin/plugins/_delete", pluginForm)(adminOnly { form =>
|
||||||
deletePlugins(form.pluginIds)
|
if(enablePluginSystem){
|
||||||
redirect("/admin/plugins")
|
deletePlugins(form.pluginIds)
|
||||||
|
redirect("/admin/plugins")
|
||||||
|
} else NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/admin/plugins/available")(adminOnly {
|
get("/admin/plugins/available")(adminOnly {
|
||||||
val installedPlugins = plugin.PluginSystem.plugins
|
if(enablePluginSystem){
|
||||||
val availablePlugins = getAvailablePlugins(installedPlugins).filter(_.status == "available")
|
val installedPlugins = plugin.PluginSystem.plugins
|
||||||
admin.plugins.html.available(availablePlugins)
|
val availablePlugins = getAvailablePlugins(installedPlugins).filter(_.status == "available")
|
||||||
|
admin.plugins.html.available(availablePlugins)
|
||||||
|
} else NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/plugins/_install", pluginForm)(adminOnly { form =>
|
post("/admin/plugins/_install", pluginForm)(adminOnly { form =>
|
||||||
installPlugins(form.pluginIds)
|
if(enablePluginSystem){
|
||||||
redirect("/admin/plugins")
|
installPlugins(form.pluginIds)
|
||||||
|
redirect("/admin/plugins")
|
||||||
|
} else NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
get("/admin/plugins/console")(adminOnly {
|
get("/admin/plugins/console")(adminOnly {
|
||||||
admin.plugins.html.console()
|
if(enablePluginSystem){
|
||||||
|
admin.plugins.html.console()
|
||||||
|
} else NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
post("/admin/plugins/console")(adminOnly {
|
post("/admin/plugins/console")(adminOnly {
|
||||||
val script = request.getParameter("script")
|
if(enablePluginSystem){
|
||||||
val result = plugin.ScalaPlugin.eval(script)
|
val script = request.getParameter("script")
|
||||||
Ok()
|
val result = plugin.ScalaPlugin.eval(script)
|
||||||
|
Ok()
|
||||||
|
} else NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
// TODO Move these methods to PluginSystem or Service?
|
// TODO Move these methods to PluginSystem or Service?
|
||||||
|
|||||||
@@ -191,4 +191,7 @@ object SystemSettingsService {
|
|||||||
else value
|
else value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO temporary flag
|
||||||
|
val enablePluginSystem = Option(System.getProperty("enable.plugin")).getOrElse("false").toBoolean
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import util.ControlUtil._
|
|||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import util.Directory
|
import util.Directory
|
||||||
import plugin.PluginUpdateJob
|
import plugin.PluginUpdateJob
|
||||||
|
import service.SystemSettingsService
|
||||||
|
|
||||||
object AutoUpdate {
|
object AutoUpdate {
|
||||||
|
|
||||||
@@ -168,18 +169,15 @@ object AutoUpdate {
|
|||||||
*/
|
*/
|
||||||
class AutoUpdateListener extends ServletContextListener {
|
class AutoUpdateListener extends ServletContextListener {
|
||||||
import org.quartz.impl.StdSchedulerFactory
|
import org.quartz.impl.StdSchedulerFactory
|
||||||
import org.quartz.JobBuilder._
|
|
||||||
import org.quartz.TriggerBuilder._
|
|
||||||
import org.quartz.SimpleScheduleBuilder._
|
|
||||||
import AutoUpdate._
|
import AutoUpdate._
|
||||||
|
|
||||||
private val logger = LoggerFactory.getLogger(classOf[AutoUpdateListener])
|
private val logger = LoggerFactory.getLogger(classOf[AutoUpdateListener])
|
||||||
private val scheduler = StdSchedulerFactory.getDefaultScheduler
|
private val scheduler = StdSchedulerFactory.getDefaultScheduler
|
||||||
|
|
||||||
override def contextInitialized(event: ServletContextEvent): Unit = {
|
override def contextInitialized(event: ServletContextEvent): Unit = {
|
||||||
val datadir = event.getServletContext.getInitParameter("gitbucket.home")
|
val dataDir = event.getServletContext.getInitParameter("gitbucket.home")
|
||||||
if(datadir != null){
|
if(dataDir != null){
|
||||||
System.setProperty("gitbucket.home", datadir)
|
System.setProperty("gitbucket.home", dataDir)
|
||||||
}
|
}
|
||||||
org.h2.Driver.load()
|
org.h2.Driver.load()
|
||||||
|
|
||||||
@@ -210,21 +208,23 @@ class AutoUpdateListener extends ServletContextListener {
|
|||||||
logger.debug("End schema update")
|
logger.debug("End schema update")
|
||||||
}
|
}
|
||||||
|
|
||||||
getDatabase(context).withSession { implicit session =>
|
if(SystemSettingsService.enablePluginSystem){
|
||||||
logger.debug("Starting plugin system...")
|
getDatabase(context).withSession { implicit session =>
|
||||||
try {
|
logger.debug("Starting plugin system...")
|
||||||
plugin.PluginSystem.init()
|
try {
|
||||||
|
plugin.PluginSystem.init()
|
||||||
|
|
||||||
scheduler.start()
|
scheduler.start()
|
||||||
PluginUpdateJob.schedule(scheduler)
|
PluginUpdateJob.schedule(scheduler)
|
||||||
logger.debug("PluginUpdateJob is started.")
|
logger.debug("PluginUpdateJob is started.")
|
||||||
|
|
||||||
logger.debug("Plugin system is initialized.")
|
logger.debug("Plugin system is initialized.")
|
||||||
} catch {
|
} catch {
|
||||||
case ex: Throwable => {
|
case ex: Throwable => {
|
||||||
logger.error("Failed to initialize plugin system", ex)
|
logger.error("Failed to initialize plugin system", ex)
|
||||||
ex.printStackTrace()
|
ex.printStackTrace()
|
||||||
throw ex
|
throw ex
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,9 +11,11 @@
|
|||||||
<li@if(active=="system"){ class="active"}>
|
<li@if(active=="system"){ class="active"}>
|
||||||
<a href="@path/admin/system">System Settings</a>
|
<a href="@path/admin/system">System Settings</a>
|
||||||
</li>
|
</li>
|
||||||
<li@if(active=="plugins"){ class="active"}>
|
@if(service.SystemSettingsService.enablePluginSystem){
|
||||||
<a href="@path/admin/plugins">Plugins</a>
|
<li@if(active=="plugins"){ class="active"}>
|
||||||
</li>
|
<a href="@path/admin/plugins">Plugins</a>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
<li>
|
<li>
|
||||||
<a href="@path/console/login.jsp">H2 Console</a>
|
<a href="@path/console/login.jsp">H2 Console</a>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
Reference in New Issue
Block a user