aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authortechknowlogick <techknowlogick@users.noreply.github.com>2018-05-16 21:35:07 -0400
committerBo-Yi Wu <appleboy.tw@gmail.com>2018-05-17 09:35:07 +0800
commit8176345c0ed7f947d9748a9b1774ad00f5199281 (patch)
tree3f0d9d6b11e98c5a41c5e7fbbcf5b79435be5ca8 /cmd
parentecfc401eaa707914d487574134fcd9e3bbeac60d (diff)
downloadgitea-8176345c0ed7f947d9748a9b1774ad00f5199281.tar.gz
gitea-8176345c0ed7f947d9748a9b1774ad00f5199281.zip
Add cli commands to regen hooks & keys (#3979)
* Add cli commands to regen hooks & keys * make fmt * Allow passing path to config as an option * add docs
Diffstat (limited to 'cmd')
-rw-r--r--cmd/admin.go58
1 files changed, 58 insertions, 0 deletions
diff --git a/cmd/admin.go b/cmd/admin.go
index 5492b9a2db..6c79141eab 100644
--- a/cmd/admin.go
+++ b/cmd/admin.go
@@ -25,6 +25,7 @@ var (
subcmdCreateUser,
subcmdChangePassword,
subcmdRepoSyncReleases,
+ subcmdRegenerate,
},
}
@@ -80,6 +81,41 @@ var (
Usage: "Synchronize repository releases with tags",
Action: runRepoSyncReleases,
}
+
+ subcmdRegenerate = cli.Command{
+ Name: "regenerate",
+ Usage: "Regenerate specific files",
+ Subcommands: []cli.Command{
+ microcmdRegenHooks,
+ microcmdRegenKeys,
+ },
+ }
+
+ microcmdRegenHooks = cli.Command{
+ Name: "hooks",
+ Usage: "Regenerate git-hooks",
+ Action: runRegenerateHooks,
+ Flags: []cli.Flag{
+ cli.StringFlag{
+ Name: "config, c",
+ Value: "custom/conf/app.ini",
+ Usage: "Custom configuration file path",
+ },
+ },
+ }
+
+ microcmdRegenKeys = cli.Command{
+ Name: "keys",
+ Usage: "Regenerate authorized_keys file",
+ Action: runRegenerateKeys,
+ Flags: []cli.Flag{
+ cli.StringFlag{
+ Name: "config, c",
+ Value: "custom/conf/app.ini",
+ Usage: "Custom configuration file path",
+ },
+ },
+ }
)
func runChangePassword(c *cli.Context) error {
@@ -195,3 +231,25 @@ func getReleaseCount(id int64) (int64, error) {
},
)
}
+
+func runRegenerateHooks(c *cli.Context) error {
+ if c.IsSet("config") {
+ setting.CustomConf = c.String("config")
+ }
+
+ if err := initDB(); err != nil {
+ return err
+ }
+ return models.SyncRepositoryHooks()
+}
+
+func runRegenerateKeys(c *cli.Context) error {
+ if c.IsSet("config") {
+ setting.CustomConf = c.String("config")
+ }
+
+ if err := initDB(); err != nil {
+ return err
+ }
+ return models.RewriteAllPublicKeys()
+}