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 {
|
||||
if(enablePluginSystem){
|
||||
val installedPlugins = plugin.PluginSystem.plugins
|
||||
val updatablePlugins = getAvailablePlugins(installedPlugins).filter(_.status == "updatable")
|
||||
admin.plugins.html.installed(installedPlugins, updatablePlugins)
|
||||
} else NotFound
|
||||
})
|
||||
|
||||
post("/admin/plugins/_update", pluginForm)(adminOnly { form =>
|
||||
if(enablePluginSystem){
|
||||
deletePlugins(form.pluginIds)
|
||||
installPlugins(form.pluginIds)
|
||||
redirect("/admin/plugins")
|
||||
} else NotFound
|
||||
})
|
||||
|
||||
post("/admin/plugins/_delete", pluginForm)(adminOnly { form =>
|
||||
if(enablePluginSystem){
|
||||
deletePlugins(form.pluginIds)
|
||||
redirect("/admin/plugins")
|
||||
} else NotFound
|
||||
})
|
||||
|
||||
get("/admin/plugins/available")(adminOnly {
|
||||
if(enablePluginSystem){
|
||||
val installedPlugins = plugin.PluginSystem.plugins
|
||||
val availablePlugins = getAvailablePlugins(installedPlugins).filter(_.status == "available")
|
||||
admin.plugins.html.available(availablePlugins)
|
||||
} else NotFound
|
||||
})
|
||||
|
||||
post("/admin/plugins/_install", pluginForm)(adminOnly { form =>
|
||||
if(enablePluginSystem){
|
||||
installPlugins(form.pluginIds)
|
||||
redirect("/admin/plugins")
|
||||
} else NotFound
|
||||
})
|
||||
|
||||
get("/admin/plugins/console")(adminOnly {
|
||||
if(enablePluginSystem){
|
||||
admin.plugins.html.console()
|
||||
} else NotFound
|
||||
})
|
||||
|
||||
post("/admin/plugins/console")(adminOnly {
|
||||
if(enablePluginSystem){
|
||||
val script = request.getParameter("script")
|
||||
val result = plugin.ScalaPlugin.eval(script)
|
||||
Ok()
|
||||
} else NotFound
|
||||
})
|
||||
|
||||
// TODO Move these methods to PluginSystem or Service?
|
||||
|
||||
@@ -191,4 +191,7 @@ object SystemSettingsService {
|
||||
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 util.Directory
|
||||
import plugin.PluginUpdateJob
|
||||
import service.SystemSettingsService
|
||||
|
||||
object AutoUpdate {
|
||||
|
||||
@@ -168,18 +169,15 @@ object AutoUpdate {
|
||||
*/
|
||||
class AutoUpdateListener extends ServletContextListener {
|
||||
import org.quartz.impl.StdSchedulerFactory
|
||||
import org.quartz.JobBuilder._
|
||||
import org.quartz.TriggerBuilder._
|
||||
import org.quartz.SimpleScheduleBuilder._
|
||||
import AutoUpdate._
|
||||
|
||||
private val logger = LoggerFactory.getLogger(classOf[AutoUpdateListener])
|
||||
private val scheduler = StdSchedulerFactory.getDefaultScheduler
|
||||
|
||||
override def contextInitialized(event: ServletContextEvent): Unit = {
|
||||
val datadir = event.getServletContext.getInitParameter("gitbucket.home")
|
||||
if(datadir != null){
|
||||
System.setProperty("gitbucket.home", datadir)
|
||||
val dataDir = event.getServletContext.getInitParameter("gitbucket.home")
|
||||
if(dataDir != null){
|
||||
System.setProperty("gitbucket.home", dataDir)
|
||||
}
|
||||
org.h2.Driver.load()
|
||||
|
||||
@@ -210,6 +208,7 @@ class AutoUpdateListener extends ServletContextListener {
|
||||
logger.debug("End schema update")
|
||||
}
|
||||
|
||||
if(SystemSettingsService.enablePluginSystem){
|
||||
getDatabase(context).withSession { implicit session =>
|
||||
logger.debug("Starting plugin system...")
|
||||
try {
|
||||
@@ -229,6 +228,7 @@ class AutoUpdateListener extends ServletContextListener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def contextDestroyed(sce: ServletContextEvent): Unit = {
|
||||
scheduler.shutdown()
|
||||
|
||||
@@ -11,9 +11,11 @@
|
||||
<li@if(active=="system"){ class="active"}>
|
||||
<a href="@path/admin/system">System Settings</a>
|
||||
</li>
|
||||
@if(service.SystemSettingsService.enablePluginSystem){
|
||||
<li@if(active=="plugins"){ class="active"}>
|
||||
<a href="@path/admin/plugins">Plugins</a>
|
||||
</li>
|
||||
}
|
||||
<li>
|
||||
<a href="@path/console/login.jsp">H2 Console</a>
|
||||
</li>
|
||||
|
||||
Reference in New Issue
Block a user