This commit is contained in:
2025-04-12 15:51:39 +03:00
parent 5ca34a572a
commit 8070112bf2
45 changed files with 2728 additions and 1196 deletions

15
repo.go
View File

@ -31,6 +31,7 @@ import (
"gitea.plemya-x.ru/Plemya-x/ALR/internal/config"
database "gitea.plemya-x.ru/Plemya-x/ALR/internal/db"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/types"
"gitea.plemya-x.ru/Plemya-x/ALR/internal/utils"
"gitea.plemya-x.ru/Plemya-x/ALR/pkg/repos"
)
@ -54,6 +55,8 @@ func AddRepoCmd() *cli.Command {
},
},
Action: func(c *cli.Context) error {
utils.ExitIfNotRoot()
ctx := c.Context
name := c.String("name")
@ -87,6 +90,11 @@ func AddRepoCmd() *cli.Command {
os.Exit(1)
}
if utils.DropCapsToAlrUser() != nil {
slog.Error(gotext.Get("Can't drop privileges"))
os.Exit(1)
}
db := database.New(cfg)
err = db.Init(ctx)
if err != nil {
@ -119,6 +127,8 @@ func RemoveRepoCmd() *cli.Command {
},
},
Action: func(c *cli.Context) error {
utils.ExitIfNotRoot()
ctx := c.Context
name := c.String("name")
@ -179,6 +189,11 @@ func RefreshCmd() *cli.Command {
Usage: gotext.Get("Pull all repositories that have changed"),
Aliases: []string{"ref"},
Action: func(c *cli.Context) error {
if utils.DropCapsToAlrUser() != nil {
slog.Error(gotext.Get("Can't drop privileges"))
os.Exit(1)
}
ctx := c.Context
cfg := config.New()
err := cfg.Load()