From 0296434e06652d7447e27bf841ba07e84b852f94 Mon Sep 17 00:00:00 2001 From: tzvonimir Date: Fri, 8 Nov 2024 18:17:11 +0100 Subject: [PATCH] Migrate LDA to ODA --- .env.example | 2 +- .github/workflows/release.yaml | 32 ++++++------- .gitignore | 2 +- CHANGELOG.md | 2 +- CONTRIBUTING.md | 6 +-- Dockerfile | 4 +- ISSUE_TEMPLATE.md | 2 +- LICENSE.txt | 2 +- Makefile | 6 +-- README.md | 30 ++++++------ cmd/cmd.go | 86 +++++++++++++++++----------------- cmd/collect.go | 2 +- cmd/version.go | 6 +-- collector/collector.go | 2 +- config/config.go | 4 +- config/os.go | 4 +- daemon/daemon.go | 12 ++--- daemon/services/lda.plist | 28 ----------- daemon/services/lda.service | 16 ------- database/database.go | 4 +- database/migrations.go | 2 +- docker-compose.yml | 2 +- install.sh | 14 +++--- resources/views/command.html | 2 +- resources/views/index.html | 2 +- resources/views/overview.html | 2 +- shell/shell.go | 24 +++++----- ubuntu-22.docker-compose.yml | 2 +- ubuntu.docker-compose.yml | 4 +- user/user.go | 16 +++---- 30 files changed, 139 insertions(+), 183 deletions(-) delete mode 100644 daemon/services/lda.plist delete mode 100644 daemon/services/lda.service diff --git a/.env.example b/.env.example index 185ffe2..dcc099a 100644 --- a/.env.example +++ b/.env.example @@ -1 +1 @@ -COMPOSE_PROJECT_NAME=lda +COMPOSE_PROJECT_NAME=oda diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index ce8a5cf..936ea9b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -25,19 +25,19 @@ jobs: - name: Build Binary for Linux run: | make build GOARCH=amd64 - tar -czvf "lda-linux-amd64.tar.gz" "lda" + tar -czvf "oda-linux-amd64.tar.gz" "oda" make build GOARCH=arm64 - tar -czvf "lda-linux-arm64.tar.gz" "lda" + tar -czvf "oda-linux-arm64.tar.gz" "oda" - uses: actions/upload-artifact@v4 with: - name: lda-linux-amd64.tar.gz - path: lda-linux-amd64.tar.gz + name: oda-linux-amd64.tar.gz + path: oda-linux-amd64.tar.gz - uses: actions/upload-artifact@v4 with: - name: lda-linux-arm64.tar.gz - path: lda-linux-arm64.tar.gz + name: oda-linux-arm64.tar.gz + path: oda-linux-arm64.tar.gz build-macos: runs-on: macos-latest @@ -58,19 +58,19 @@ jobs: - name: Build Binary for macOS run: | make build GOARCH=amd64 - tar -czvf "lda-darwin-amd64.tar.gz" "lda" + tar -czvf "oda-darwin-amd64.tar.gz" "oda" make build GOARCH=arm64 - tar -czvf "lda-darwin-arm64.tar.gz" "lda" + tar -czvf "oda-darwin-arm64.tar.gz" "oda" - uses: actions/upload-artifact@v4 with: - name: lda-darwin-amd64.tar.gz - path: lda-darwin-amd64.tar.gz + name: oda-darwin-amd64.tar.gz + path: oda-darwin-amd64.tar.gz - uses: actions/upload-artifact@v4 with: - name: lda-darwin-arm64.tar.gz - path: lda-darwin-arm64.tar.gz + name: oda-darwin-arm64.tar.gz + path: oda-darwin-arm64.tar.gz create-release: needs: [build-linux, build-macos] @@ -87,9 +87,9 @@ jobs: uses: softprops/action-gh-release@v2 with: files: | - artifacts/lda-darwin-arm64.tar.gz/lda-darwin-arm64.tar.gz - artifacts/lda-darwin-amd64.tar.gz/lda-darwin-amd64.tar.gz - artifacts/lda-linux-amd64.tar.gz/lda-linux-amd64.tar.gz - artifacts/lda-linux-arm64.tar.gz/lda-linux-arm64.tar.gz + artifacts/oda-darwin-arm64.tar.gz/oda-darwin-arm64.tar.gz + artifacts/oda-darwin-amd64.tar.gz/oda-darwin-amd64.tar.gz + artifacts/oda-linux-amd64.tar.gz/oda-linux-amd64.tar.gz + artifacts/oda-linux-arm64.tar.gz/oda-linux-arm64.tar.gz env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.gitignore b/.gitignore index 1ee379e..2364236 100644 --- a/.gitignore +++ b/.gitignore @@ -4,5 +4,5 @@ app.ini config.toml docs -lda* +oda* .vscode diff --git a/CHANGELOG.md b/CHANGELOG.md index 358c437..0f31a7f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -All notable changes to the LDA project will be documented in this file. +All notable changes to the ODA project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 491e9bd..c153af5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,7 +1,7 @@ -Contributing to LDA Project +Contributing to ODA Project =========================== -We welcome contributions and are thrilled you're considering contributing to the LDA project. This document outlines the contribution process and how you can report issues or help improve the code. +We welcome contributions and are thrilled you're considering contributing to the ODA project. This document outlines the contribution process and how you can report issues or help improve the code. Issues ------ @@ -19,4 +19,4 @@ Pull Requests * **Feature Proposals**: For substantial changes or new features, we recommend opening a discussion first, either through an issue, GitHub discussions, or direct communication. This allows for community input and guidance before significant effort is undertaken. * **Documentation Updates**: If your changes necessitate updates to the documentation, please include those in your PR. -Thank you for your interest in contributing to the LDA project. Your efforts help make this project better for everyone. +Thank you for your interest in contributing to the ODA project. Your efforts help make this project better for everyone. diff --git a/Dockerfile b/Dockerfile index 2d8e131..742e5fd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,6 @@ COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ WORKDIR /app -COPY --from=builder /src/lda ./ +COPY --from=builder /src/oda ./ -ENTRYPOINT ["/lda"] +ENTRYPOINT ["/oda"] diff --git a/ISSUE_TEMPLATE.md b/ISSUE_TEMPLATE.md index 098a400..eb4e122 100644 --- a/ISSUE_TEMPLATE.md +++ b/ISSUE_TEMPLATE.md @@ -31,5 +31,5 @@ ## Versions -- **LDA Version:** ... +- **ODA Version:** ... - **Operating System:** ... diff --git a/LICENSE.txt b/LICENSE.txt index 063f51b..451f170 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) The lda Authors +Copyright (c) The oda Authors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/Makefile b/Makefile index 3132767..3a35fee 100644 --- a/Makefile +++ b/Makefile @@ -6,8 +6,8 @@ CHANGES := $(shell test -n "$$(git status --porcelain)" && echo '+CHANGES' || tr PROTO_LOCATION := $(shell find proto -iname "proto" -exec echo "-I="{} \;) -PACKAGE = lda -TARGET = lda +PACKAGE = oda +TARGET = oda VERSION=$(shell git describe --tags --abbrev=0 || echo "x.x.x") COMMIT=$(shell git rev-parse --short HEAD) @@ -17,7 +17,7 @@ BRANCH=$(shell git rev-parse --abbrev-ref HEAD) UNAME := $(shell uname | tr A-Z a-z ) # docker registry prefix: -DOCKER_REGISTRY := registry.gitlab.codilas.com/codilas/devzero/lda +DOCKER_REGISTRY := registry.gitlab.codilas.com/codilas/devzero/oda # Setup the -ldflags option for go build here, interpolate the variable values LDFLAGS = -s -w -X config.Version=${VERSION} -X config.Commit=${COMMIT}${CHANGES} -X config.Branch=${BRANCH} diff --git a/README.md b/README.md index 9255da2..f824487 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,9 @@ ![License](https://img.shields.io/github/license/devzero-inc/local-developer-analytics) ![Version](https://img.shields.io/github/v/tag/devzero-inc/local-developer-analytics) -# LDA +# ODA -The **LDA** CLI is local developer analytics tool. It provides: +The **ODA** CLI is local developer analytics tool. It provides: - Tracking commands executed in user shell - Tracking processes running on users computer @@ -17,7 +17,7 @@ The **LDA** CLI is local developer analytics tool. It provides: ### Homebrew -You can install `lda` using [Homebrew][brew] (macOS or Linux): +You can install `oda` using [Homebrew][brew] (macOS or Linux): ```sh brew install <> @@ -25,12 +25,12 @@ brew install <> ### wget -You can install `lda` using `wget`: +You can install `oda` using `wget`: ```sh -wget https://github.com/devzero-inc/local-developer-analytics/releases/download//lda--.zip -unzip lda--.zip -mv lda /usr/local/bin +wget https://github.com/devzero-inc/local-developer-analytics/releases/download//oda--.zip +unzip oda--.zip +mv oda /usr/local/bin ``` ### Other methods @@ -47,23 +47,23 @@ Install from source: ## Install & Usage -LDA help interface provides summaries for commands and flags: +ODA help interface provides summaries for commands and flags: ```sh -lda --help +oda --help ``` After binary has been compiled we can install the service with the following commands: -* `lda install` => This will install the daemon, configure base directory, and inject configuration into the shell -* `lda start` => This will start the daemon -* `lda stop` => This will stop the daemon -* `lda uninstall` => This will uninstall the LDA and remove all configuration -* `lda serve` => This will serve the local dashbaord with data overview +* `oda install` => This will install the daemon, configure base directory, and inject configuration into the shell +* `oda start` => This will start the daemon +* `oda stop` => This will stop the daemon +* `oda uninstall` => This will uninstall the ODA and remove all configuration +* `oda serve` => This will serve the local dashbaord with data overview ## Community -For updates on the LDA CLI, [follow this repo on GitHub][repo]. +For updates on the ODA CLI, [follow this repo on GitHub][repo]. For information on contributing to this project, please see the [contributing guidelines](CONTRIBUTING.md). diff --git a/cmd/cmd.go b/cmd/cmd.go index af86c7d..3bb632a 100644 --- a/cmd/cmd.go +++ b/cmd/cmd.go @@ -34,7 +34,7 @@ func newInstallCmd() *cobra.Command { installCmd := &cobra.Command{ Use: "install", Short: "Install daemon runner", - Long: `Install daemon runner for LDA Project.`, + Long: `Install daemon runner for ODA Project.`, RunE: install, } @@ -47,17 +47,17 @@ func newInstallCmd() *cobra.Command { } func NewLdaCmd() *cobra.Command { - ldaCmd := &cobra.Command{ - Use: "lda", - Short: "Command line manager for LDA project.", - Long: `Command line manager for LDA Project. + odaCmd := &cobra.Command{ + Use: "oda", + Short: "Command line manager for ODA project.", + Long: `Command line manager for ODA Project. Complete documentation is available at https://devzero.io`, - Run: lda, + Run: oda, } - ldaCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "Verbosity") + odaCmd.PersistentFlags().BoolVarP(&Verbose, "verbose", "v", false, "Verbosity") - ldaCmd.AddCommand( + odaCmd.AddCommand( newVersionCmd(), newCollectCmd(), newStartCmd(), @@ -69,7 +69,7 @@ func NewLdaCmd() *cobra.Command { newConfigCmd(), ) - return ldaCmd + return odaCmd } // newUninstallCmd creates a new uninstall command @@ -77,7 +77,7 @@ func newUninstallCmd() *cobra.Command { uninstallCmd := &cobra.Command{ Use: "uninstall", Short: "Uninstall daemon runner", - Long: `Uninstall daemon runner for LDA Project.`, + Long: `Uninstall daemon runner for ODA Project.`, RunE: uninstall, } @@ -89,7 +89,7 @@ func newStartCmd() *cobra.Command { startCmd := &cobra.Command{ Use: "start", Short: "Start daemon runner", - Long: `Start daemon runner for LDA Project.`, + Long: `Start daemon runner for ODA Project.`, RunE: start, } @@ -101,7 +101,7 @@ func newStopCmd() *cobra.Command { stopCmd := &cobra.Command{ Use: "stop", Short: "Stop daemon runner", - Long: `Stop daemon runner for LDA Project.`, + Long: `Stop daemon runner for ODA Project.`, RunE: stop, } @@ -113,7 +113,7 @@ func newServeCmd() *cobra.Command { serveCmd := &cobra.Command{ Use: "serve", Short: "Serve local client", - Long: `Serve local frontend client for LDA Project.`, + Long: `Serve local frontend client for ODA Project.`, RunE: serve, } @@ -127,7 +127,7 @@ func newConfigCmd() *cobra.Command { configCmd := &cobra.Command{ Use: "config", Short: "Print current configuration", - Long: `Display current configuration for LDA Project.`, + Long: `Display current configuration for ODA Project.`, RunE: displayConfig, } @@ -139,7 +139,7 @@ func newReloadCmd() *cobra.Command { reloadCmd := &cobra.Command{ Use: "reload", Short: "Reload daemon runner", - Long: `Reload daemon runner for LDA Project.`, + Long: `Reload daemon runner for ODA Project.`, RunE: reload, } @@ -175,9 +175,9 @@ func setupConfig() { fmt.Fprintf(config.SysConfig.ErrOut, "Failed to get home directory: %s\n", err) os.Exit(1) } - ldaDir, err := config.GetLdaDir(homeDir, sudoExecUser) + odaDir, err := config.GetLdaDir(homeDir, sudoExecUser) if err != nil { - fmt.Fprintf(config.SysConfig.ErrOut, "Failed to get LDA directory: %s\n", err) + fmt.Fprintf(config.SysConfig.ErrOut, "Failed to get ODA directory: %s\n", err) os.Exit(1) } exePath, err := config.GetLdaBinaryPath() @@ -187,10 +187,10 @@ func setupConfig() { } // setting up optional application configuration - config.SetupConfig(ldaDir, sudoExecUser) + config.SetupConfig(odaDir, sudoExecUser) // setup database and run migrations - database.Setup(ldaDir, sudoExecUser) + database.Setup(odaDir, sudoExecUser) database.RunMigrations() // setting up the Logger @@ -206,7 +206,7 @@ func setupConfig() { Os: int64(osConf), OsName: osName, HomeDir: homeDir, - LdaDir: ldaDir, + LdaDir: odaDir, IsRoot: isRoot, ExePath: exePath, User: sudoExecUser, @@ -218,14 +218,14 @@ func setupConfig() { // Execute is the entry point for the command line func Execute() { - ldaCmd := NewLdaCmd() - if err := ldaCmd.Execute(); err != nil { - logging.Log.Err(err).Msg("Failed to execute main lda command") + odaCmd := NewLdaCmd() + if err := odaCmd.Execute(); err != nil { + logging.Log.Err(err).Msg("Failed to execute main oda command") os.Exit(1) } } -func lda(cmd *cobra.Command, _ []string) { +func oda(cmd *cobra.Command, _ []string) { if err := cmd.Help(); err != nil { logging.Log.Error().Err(err).Msg("Failed to show help") } @@ -247,12 +247,12 @@ func reload(_ *cobra.Command, _ []string) error { } dmn := daemon.NewDaemon(daemonConf, logging.Log) - fmt.Fprintln(config.SysConfig.Out, "Reloading LDA daemon...") + fmt.Fprintln(config.SysConfig.Out, "Reloading ODA daemon...") if err := dmn.ReloadDaemon(); err != nil { logging.Log.Error().Err(err).Msg("Failed to reload daemon") - return errors.Wrap(err, "failed to reload LDA daemon") + return errors.Wrap(err, "failed to reload ODA daemon") } - fmt.Fprintln(config.SysConfig.Out, "Reloading LDA daemon finished.") + fmt.Fprintln(config.SysConfig.Out, "Reloading ODA daemon finished.") return nil } @@ -272,12 +272,12 @@ func start(_ *cobra.Command, _ []string) error { } dmn := daemon.NewDaemon(daemonConf, logging.Log) - fmt.Fprintln(config.SysConfig.Out, "Starting LDA daemon...") + fmt.Fprintln(config.SysConfig.Out, "Starting ODA daemon...") if err := dmn.StartDaemon(); err != nil { logging.Log.Error().Err(err).Msg("Failed to start daemon") - return errors.Wrap(err, "failed to start LDA daemon") + return errors.Wrap(err, "failed to start ODA daemon") } - fmt.Fprintln(config.SysConfig.Out, "LDA daemon started.") + fmt.Fprintln(config.SysConfig.Out, "ODA daemon started.") return nil } @@ -297,12 +297,12 @@ func stop(_ *cobra.Command, _ []string) error { } dmn := daemon.NewDaemon(daemonConf, logging.Log) - fmt.Fprintln(config.SysConfig.Out, "Stopping LDA daemon...") + fmt.Fprintln(config.SysConfig.Out, "Stopping ODA daemon...") if err := dmn.StopDaemon(); err != nil { logging.Log.Error().Err(err).Msg("Failed to stop daemon") - return errors.Wrap(err, "failed to stop LDA daemon") + return errors.Wrap(err, "failed to stop ODA daemon") } - fmt.Fprintln(config.SysConfig.Out, "LDA daemon stopped.") + fmt.Fprintln(config.SysConfig.Out, "ODA daemon stopped.") return nil } @@ -356,10 +356,10 @@ func install(cmd *cobra.Command, _ []string) error { } dmn := daemon.NewDaemon(daemonConf, logging.Log) - fmt.Fprintln(config.SysConfig.Out, "Installing LDA daemon...") + fmt.Fprintln(config.SysConfig.Out, "Installing ODA daemon...") if err := dmn.InstallDaemonConfiguration(); err != nil { logging.Log.Error().Err(err).Msg("Failed to install daemon configuration") - return errors.Wrap(err, "failed to install LDA daemon configuration file") + return errors.Wrap(err, "failed to install ODA daemon configuration file") } for shellType, shellLocation := range user.Conf.ShellTypeToLocation { @@ -381,7 +381,7 @@ func install(cmd *cobra.Command, _ []string) error { if err := shl.InstallShellConfiguration(); err != nil { logging.Log.Error().Err(err).Msg("Failed to install shell configuration") - return errors.Wrap(err, "failed to install LDA shell configuration files") + return errors.Wrap(err, "failed to install ODA shell configuration files") } if err := shl.InjectShellSource(installFlags.nonInteractive); err != nil { @@ -389,7 +389,7 @@ func install(cmd *cobra.Command, _ []string) error { } } - fmt.Fprintln(config.SysConfig.Out, "LDA daemon installed successfully.") + fmt.Fprintln(config.SysConfig.Out, "ODA daemon installed successfully.") return nil } @@ -427,18 +427,18 @@ func uninstall(_ *cobra.Command, _ []string) error { if err := shl.DeleteShellConfiguration(); err != nil { logging.Log.Error().Err(err).Msg("Failed to delete shell configuration") - return errors.Wrap(err, "failed to delete LDA shell configuration files") + return errors.Wrap(err, "failed to delete ODA shell configuration files") } } - fmt.Fprintln(config.SysConfig.Out, "Uninstalling LDA daemon...") + fmt.Fprintln(config.SysConfig.Out, "Uninstalling ODA daemon...") if err := dmn.DestroyDaemonConfiguration(); err != nil { logging.Log.Error().Err(err).Msg("Failed to uninstall daemon configuration") - return errors.Wrap(err, "failed to uninstall LDA daemon configuration file") + return errors.Wrap(err, "failed to uninstall ODA daemon configuration file") } fmt.Fprintln(config.SysConfig.Out, `Daemon service files and shell configuration deleted successfully, - ~/.lda directory still holds database file, and your rc file stills has source script. + ~/.oda directory still holds database file, and your rc file stills has source script. If you wish to remove those, delete them manually`) return nil @@ -448,7 +448,7 @@ func displayConfig(_ *cobra.Command, _ []string) error { conf, err := user.GetConfig() if err != nil { logging.Log.Error().Err(err).Msg("Failed to get os config") - return errors.Wrap(err, "failed to get os config, please run 'lda install' first") + return errors.Wrap(err, "failed to get os config, please run 'oda install' first") } fmt.Fprintf(config.SysConfig.Out, "Current configuration: %+v \n", conf) @@ -467,7 +467,7 @@ func serve(cmd *cobra.Command, _ []string) error { err := http.ListenAndServe(fmt.Sprintf(":%v", portFlag), nil) if err != nil { - return errors.Wrap(err, "pass a port when calling serve; example: `lda serve -p 8987`") + return errors.Wrap(err, "pass a port when calling serve; example: `oda serve -p 8987`") } return nil } diff --git a/cmd/collect.go b/cmd/collect.go index 08d0dae..35eb0d3 100644 --- a/cmd/collect.go +++ b/cmd/collect.go @@ -48,7 +48,7 @@ func collect(cmd *cobra.Command, _ []string) error { user.Conf, err = user.GetConfig() if err != nil { logging.Log.Error().Err(err).Msg("Failed to get os config") - return errors.Wrap(err, "failed to get os config, please run 'lda install' first") + return errors.Wrap(err, "failed to get os config, please run 'oda install' first") } var grpcClient *client.Client diff --git a/cmd/version.go b/cmd/version.go index b383dc4..11595a0 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -12,13 +12,13 @@ import ( func newVersionCmd() *cobra.Command { return &cobra.Command{ Use: "version", - Short: "Version number of LDA.", - Long: `Display LDA version number.`, + Short: "Version number of ODA.", + Long: `Display ODA version number.`, Run: version, } } func version(_ *cobra.Command, _ []string) { - fmt.Fprintf(config.SysConfig.Out, "LDA v%s\n", config.Version) + fmt.Fprintf(config.SysConfig.Out, "ODA v%s\n", config.Version) } diff --git a/collector/collector.go b/collector/collector.go index d628884..cc5683f 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -19,7 +19,7 @@ import ( // TODO move this to /var/run or other appropriate location based on OS, // TODO /var/run has issues with permisisons os have to explore a bit more. -const SocketPath = "/tmp/lda.socket" +const SocketPath = "/tmp/oda.socket" // Collector collects command and system information type Collector struct { diff --git a/config/config.go b/config/config.go index 1850200..0862820 100644 --- a/config/config.go +++ b/config/config.go @@ -80,8 +80,8 @@ func SetupSysConfig() { } // SetupConfig initialize the configuration instance -func SetupConfig(ldaDir string, user *user.User) { - configPath := filepath.Join(ldaDir, "config.toml") +func SetupConfig(odaDir string, user *user.User) { + configPath := filepath.Join(odaDir, "config.toml") if _, err := os.Stat(configPath); errors.Is(err, os.ErrNotExist) { if err := util.WriteFileAndChown(configPath, []byte(configExample), 0644, user); err != nil { diff --git a/config/os.go b/config/os.go index 82b5f39..2856165 100644 --- a/config/os.go +++ b/config/os.go @@ -100,7 +100,7 @@ func GetHomeDir(isRoot bool, user *user.User) (string, error) { // GetLdaDir returns the directory for the shell configuration func GetLdaDir(homeDir string, user *user.User) (string, error) { - dir := filepath.Join(homeDir, ".lda") + dir := filepath.Join(homeDir, ".oda") if err := util.CreateDirAndChown(dir, os.ModePerm, user); err != nil { return "", err } @@ -108,7 +108,7 @@ func GetLdaDir(homeDir string, user *user.User) (string, error) { return dir, nil } -// GetLdaBinaryPath returns the path to the lda binary +// GetLdaBinaryPath returns the path to the oda binary func GetLdaBinaryPath() (string, error) { exePath, err := os.Executable() if err != nil { diff --git a/daemon/daemon.go b/daemon/daemon.go index 0b437af..528ff5a 100644 --- a/daemon/daemon.go +++ b/daemon/daemon.go @@ -21,12 +21,12 @@ import ( const ( PlistFilePath = "Library/LaunchAgents" PlistSudoFilePath = "/Library/LaunchDaemons" - PlistName = "lda.plist" + PlistName = "oda.plist" UserServicedFilePath = ".config/systemd/user" RootServicedFilePath = "/etc/systemd/system" - ServicedName = "lda.service" - LinuxDaemonTemplateLocation = "services/lda.service" - MacOSDaemonTemplateLocation = "services/lda.plist" + ServicedName = "oda.service" + LinuxDaemonTemplateLocation = "services/oda.service" + MacOSDaemonTemplateLocation = "services/oda.plist" ServicePermission = 0644 DirPermission = 0755 BaseCollectCommand = "collect" @@ -101,7 +101,7 @@ func (d *Daemon) InstallDaemonConfiguration() error { collectCmd := []string{} // TODO: fix this thing, as it is absolutly not robust, and it might not work in all cases - if len(commands) > 0 && commands[0] != "lda" { + if len(commands) > 0 && commands[0] != "oda" { // Extract the executable name from ExePath executableName := filepath.Base(d.config.ExePath) @@ -113,7 +113,7 @@ func (d *Daemon) InstallDaemonConfiguration() error { for _, command := range commands { d.logger.Debug().Msgf("Checking command path: %s", command) collectCmd = append(collectCmd, command) - if command == "lda" { + if command == "oda" { break } } diff --git a/daemon/services/lda.plist b/daemon/services/lda.plist deleted file mode 100644 index 25a59fd..0000000 --- a/daemon/services/lda.plist +++ /dev/null @@ -1,28 +0,0 @@ - - - Label - devzero.io.lda - ProgramArguments - - {{.BinaryPath}} - {{- range .CollectCommandSplit }} - {{.}} - {{- end }} - - RunAtLoad - - KeepAlive - - UserName - {{.Username}} - EnvironmentVariables - - HOME - {{.Home}} - - StandardOutPath - /tmp/devzero.io.lda.out.log - StandardErrorPath - /tmp/devzero.io.lda.err.log - - diff --git a/daemon/services/lda.service b/daemon/services/lda.service deleted file mode 100644 index bde2445..0000000 --- a/daemon/services/lda.service +++ /dev/null @@ -1,16 +0,0 @@ -[Unit] -Description=Devzero.io LDA Service -After=network.target - -[Service] -Environment="HOME={{.Home}}" -User={{.Username}} -Group={{.Group}} -Type=simple -ExecStart={{.BinaryPath}} {{.CollectCommand}} -Restart=always -StandardOutput=file:/tmp/devzero.io.lda.out.log -StandardError=file:/tmp/devzero.io.lda.err.log - -[Install] -WantedBy=default.target diff --git a/database/database.go b/database/database.go index 0451769..e431bb9 100644 --- a/database/database.go +++ b/database/database.go @@ -17,9 +17,9 @@ import ( var DB *sqlx.DB // Setup initializes the database connection. -func Setup(ldaDir string, user *user.User) { +func Setup(odaDir string, user *user.User) { - dbPath := filepath.Join(ldaDir, "lda.db") + dbPath := filepath.Join(odaDir, "oda.db") db, err := sqlx.Connect("sqlite", dbPath) if err != nil { diff --git a/database/migrations.go b/database/migrations.go index 1c80585..7e7f6f5 100644 --- a/database/migrations.go +++ b/database/migrations.go @@ -114,7 +114,7 @@ func createConfigTable() { os TEXT NOT NULL, os_name TEXT NOT NULL, home_dir TEXT NOT NULL, - lda_dir TEXT NOT NULL, + oda_dir TEXT NOT NULL, is_root BOOLEAN NOT NULL, exe_path TEXT NOT NULL );` diff --git a/docker-compose.yml b/docker-compose.yml index 2451392..4c96986 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,6 +1,6 @@ version: '3' services: - lda: + oda: container_name: ${COMPOSE_PROJECT_NAME} build: . \ No newline at end of file diff --git a/install.sh b/install.sh index 69f7625..c01454a 100755 --- a/install.sh +++ b/install.sh @@ -1,4 +1,4 @@ -LDA_VERSION=${LDA_VERSION:-v0.0.9} +ODA_VERSION=${ODA_VERSION:-v0.0.9} OS=${OS:-$(uname | tr '[:upper:]' '[:lower:]')} ARCH=${ARCH:-$(uname -m)} @@ -11,13 +11,13 @@ fi # Check if wget is available, otherwise fall back to curl if command -v wget &> /dev/null; then - downloader="wget -O lda-$OS-$ARCH.tar.gz" + downloader="wget -O oda-$OS-$ARCH.tar.gz" else - downloader="curl -L -o lda-$OS-$ARCH.tar.gz" + downloader="curl -L -o oda-$OS-$ARCH.tar.gz" fi # Download, unzip, and move binary in one go -$downloader https://github.com/devzero-inc/local-developer-analytics/releases/download/$LDA_VERSION/lda-$OS-$ARCH.tar.gz && \ -tar -xvf lda-$OS-$ARCH.tar.gz && \ -sudo mv lda /usr/local/bin/lda && \ -rm lda-$OS-$ARCH.tar.gz +$downloader https://github.com/devzero-inc/local-developer-analytics/releases/download/$ODA_VERSION/oda-$OS-$ARCH.tar.gz && \ +tar -xvf oda-$OS-$ARCH.tar.gz && \ +sudo mv oda /usr/local/bin/oda && \ +rm oda-$OS-$ARCH.tar.gz diff --git a/resources/views/command.html b/resources/views/command.html index b7d6c71..eb8f80a 100644 --- a/resources/views/command.html +++ b/resources/views/command.html @@ -61,7 +61,7 @@ src="https://dora.devzero.io/_next/static/media/devzero_logo.bd84b789.svg">

- LDA dashboard + ODA dashboard

A project by DevZero diff --git a/resources/views/index.html b/resources/views/index.html index 1dfd088..ee1a84d 100644 --- a/resources/views/index.html +++ b/resources/views/index.html @@ -45,7 +45,7 @@ src="https://dora.devzero.io/_next/static/media/devzero_logo.bd84b789.svg">

- LDA dashboard + ODA dashboard

A project by DevZero diff --git a/resources/views/overview.html b/resources/views/overview.html index e748cea..5743959 100644 --- a/resources/views/overview.html +++ b/resources/views/overview.html @@ -60,7 +60,7 @@ src="https://dora.devzero.io/_next/static/media/devzero_logo.bd84b789.svg">

- LDA dashboard + ODA dashboard

A project by DevZero diff --git a/shell/shell.go b/shell/shell.go index 3a84efb..776647b 100644 --- a/shell/shell.go +++ b/shell/shell.go @@ -19,7 +19,7 @@ import ( ) const ( - ldaScript = "lda.sh" + odaScript = "oda.sh" execPermissions = 0755 CollectorName = "collector.sh" CollectorScript = "scripts/collector.sh" @@ -42,19 +42,19 @@ var ( sourceScripts = map[config.ShellType]string{ config.Zsh: ` -# LDA shell source -if [ -f "$HOME/.lda/zsh.sh" ]; then - source "$HOME/.lda/zsh.sh" +# ODA shell source +if [ -f "$HOME/.oda/zsh.sh" ]; then + source "$HOME/.oda/zsh.sh" fi`, config.Bash: ` -# LDA shell source -if [ -f "$HOME/.lda/bash.sh" ]; then - source "$HOME/.lda/bash.sh" +# ODA shell source +if [ -f "$HOME/.oda/bash.sh" ]; then + source "$HOME/.oda/bash.sh" fi`, config.Fish: ` -# LDA shell source -if test -f "$HOME/.lda/fish.sh" - source "$HOME/.lda/fish.sh" +# ODA shell source +if test -f "$HOME/.oda/fish.sh" + source "$HOME/.oda/fish.sh" end`, } @@ -148,7 +148,7 @@ func (s *Shell) InstallShellConfiguration() error { // DeleteShellConfiguration removes the shell configuration func (s *Shell) DeleteShellConfiguration() error { - filePath := filepath.Join(s.Config.LdaDir, "lda.sh") + filePath := filepath.Join(s.Config.LdaDir, "oda.sh") if err := os.Remove(filePath); err != nil { s.logger.Err(err).Msg("Failed to remove shell configuration") @@ -201,7 +201,7 @@ func (s *Shell) InjectShellSource(nonInteractive bool) error { s.logger.Debug().Msgf("Shell config file: %s", shellConfigFile) // Check if the script is already present to avoid duplicates - if !util.IsScriptPresent(shellConfigFile, "LDA shell source") { + if !util.IsScriptPresent(shellConfigFile, "ODA shell source") { if err := util.AppendToFile(shellConfigFile, source); err != nil { s.logger.Error().Msg("Failed to append to the file") return err diff --git a/ubuntu-22.docker-compose.yml b/ubuntu-22.docker-compose.yml index c94c50f..4f4949c 100644 --- a/ubuntu-22.docker-compose.yml +++ b/ubuntu-22.docker-compose.yml @@ -1,6 +1,6 @@ version: '3' services: - lda: + oda: build: context: . dockerfile: ./Dockerfile.ubuntu-22 diff --git a/ubuntu.docker-compose.yml b/ubuntu.docker-compose.yml index e7a022e..3956225 100644 --- a/ubuntu.docker-compose.yml +++ b/ubuntu.docker-compose.yml @@ -1,11 +1,11 @@ version: "3" services: - lda: + oda: build: context: . dockerfile: ./Dockerfile.ubuntu - container_name: lda-ubuntu + container_name: oda-ubuntu restart: unless-stopped volumes: - ./:/app diff --git a/user/user.go b/user/user.go index e1f98fe..e87f6ba 100644 --- a/user/user.go +++ b/user/user.go @@ -35,11 +35,11 @@ type Config struct { OsName string `json:"os_name" db:"os_name"` // HomeDir is the user home directory HomeDir string `json:"home_dir" db:"home_dir"` - // LdaDir is the home LDA directory where all configurations are stored. - LdaDir string `json:"lda_dir" db:"lda_dir"` + // LdaDir is the home ODA directory where all configurations are stored. + LdaDir string `json:"oda_dir" db:"oda_dir"` // IsRoot is a value to check if the user is root IsRoot bool `json:"is_root" db:"is_root"` - // ExePath is the path to the lda binary + // ExePath is the path to the oda binary ExePath string `json:"exe_path" db:"exe_path"` // ShellTypeToLocation is a map of shell type to location ShellTypeToLocation map[config.ShellType]string `json:"shell_type_to_location" db:"shell_type_to_location"` @@ -62,8 +62,8 @@ func GetConfig() (*Config, error) { // InsertConfig inserts Config used to configure the system func InsertConfig(osConfig Config) error { - query := `INSERT INTO config (os, os_name, home_dir, lda_dir, is_root, exe_path) - VALUES (:os, :os_name, :home_dir, :lda_dir, :is_root, :exe_path)` + query := `INSERT INTO config (os, os_name, home_dir, oda_dir, is_root, exe_path) + VALUES (:os, :os_name, :home_dir, :oda_dir, :is_root, :exe_path)` _, err := database.DB.NamedExec(query, osConfig) if err != nil { @@ -102,7 +102,7 @@ func UpdateConfig(osConfig Config) error { os = :os, os_name = :os_name, home_dir = :home_dir, - lda_dir = :lda_dir, + oda_dir = :oda_dir, is_root = :is_root, exe_path = :exe_path WHERE id = :id` @@ -153,7 +153,7 @@ func ConfigureUserSystemInfo(currentConf *Config) { // allow for non-user interrupted flow var result string - autoupdate := os.Getenv("LDA_AUTO_UPDATE_CONFIG") + autoupdate := os.Getenv("ODA_AUTO_UPDATE_CONFIG") if strings.EqualFold(autoupdate, "true") { result = YesUpdate } @@ -245,7 +245,7 @@ func CompareConfig(existingConf, currentConf *Config) (bool, []string) { diffs = append(diffs, fmt.Sprintf("Home Directory changed from %s to %s", existingConf.HomeDir, currentConf.HomeDir)) } if existingConf.LdaDir != currentConf.LdaDir { - diffs = append(diffs, fmt.Sprintf("LDA Directory changed from %s to %s", existingConf.LdaDir, currentConf.LdaDir)) + diffs = append(diffs, fmt.Sprintf("ODA Directory changed from %s to %s", existingConf.LdaDir, currentConf.LdaDir)) } if existingConf.IsRoot != currentConf.IsRoot { diffs = append(diffs, fmt.Sprintf("IsRoot status changed from %t to %t", existingConf.IsRoot, currentConf.IsRoot))