neden çalışmıyon...

This commit is contained in:
Aliberk Sandıkçı 2023-08-21 16:45:11 +03:00
parent 74497f2f47
commit 749a690b6c
Signed by: asandikci
GPG key ID: 25C67A03B5666BC1
12 changed files with 186 additions and 35 deletions

View file

@ -13,14 +13,15 @@ RUN apt-get update
RUN apt-get upgrade -y
### INSTALL USEFUL UTILITIES ###
RUN apt-get install curl wget tree nano -y
RUN apt-get install curl wget tree nano procps -y
### INSTALL BUILD DEPENDENCIES ###
RUN apt-get install dh-golang -y
RUN apt-get install dh-golang dh-make -y
RUN apt-get install dh-make-golang -y
RUN apt-get install golang-github-sevlyar-go-daemon-dev -y
RUN apt-get install golang-golang-x-exp-dev -y
### CONFIGURATIONS ###
# Enable UTF8 Encoding
RUN echo "LC_ALL=en_US.UTF-8" >> /etc/environment

49
Makefile Normal file
View file

@ -0,0 +1,49 @@
REPO_NAME="ahenk-go"
REPO_LINK="https://git.aliberksandikci.com.tr/liderahenk/${REPO_NAME}"
DAEMON_NAME="ahenk-go"
OLD_DAEMON_NAME="ahenkd-go"
PYTHON_DAEMON_NAME="ahenkd"
CONF_DIR="/etc/ahenk-go/"
TEMP_DIR="$(mktemp -d)"
MAIN_DIR="${TEMP_DIR}/${REPO_NAME}/"
info:
@echo "Made by Aliberk Sandıı - 2023"
@echo "preclean: for cleaning old files, configurations"
@echo "TODO test: Test go files"
@echo "install: Build and install ahenk-go"
@echo "TODO uninstall: Uninstall ahenk-go"
@echo "TODO clean: for postclean"
preclean:
sudo rm -rf /usr/bin/$(DAEMON_NAME)
sudo rm -rf /usr/bin/${OLD_DAEMON_NAME}
sudo rm -rf /usr/bin/${PYTHON_DAEMON_NAME}
@# TODO systemd control for both three process for docker
@# REVIEW are both killall and systemctl commands running?
@pgrep -x ${DAEMON_NAME} && (sudo killall "${DAEMON_NAME}" || sudo systemctl disable "${DAEMON_NAME}" || sudo systemctl stop "${DAEMON_NAME}") || echo "no ${DAEMON_NAME} found"
@pgrep -x ${OLD_DAEMON_NAME} && (sudo killall "${OLD_DAEMON_NAME}" || sudo systemctl disable "${OLD_DAEMON_NAME}" || sudo systemctl stop "${OLD_DAEMON_NAME}") || echo "no ${OLD_DAEMON_NAME} found"
@# TODO
@# echo -e "Do you want to remove python implementation of ahenk if installed in system?"
# read -rp "(Y/N) " input
@pgrep -x ${PYTHON_DAEMON_NAME} && (sudo killall "${PYTHON_DAEMON_NAME}" || sudo systemctl disable "${PYTHON_DAEMON_NAME}" || sudo systemctl stop "${PYTHON_DAEMON_NAME}") || echo "no ${PYTHON_DAEMON_NAME} found"
sudo systemctl daemon-reload
sudo rm -rf ${CONF_DIR}
@echo -e "PRE-CLENING DONE\n"
test:
install:
go build -o ${DESTDIR}/usr/bin/${REPO_NAME} ./cmd/ahenk-go/
@sudo mkdir -p "${CONF_DIR}"
uninstall:
clean: #postclean:

View file

@ -71,7 +71,7 @@ func main() {
log.Print("STARTED AS NO-DAEMON")
}
} else {
log.Print("Please enter a valid option !")
panic("Please enter a valid option !")
}
PluginManager()
log.Print("Plugin Manager Started Succesfully")

View file

@ -0,0 +1,33 @@
package main
import "log"
// type Greeter interface {
// Greet()
// }
func PluginManager() {
// LoadPlugin("resources")
// // 4. use the module
// greeter.Greet()
// greeter.Myvar()
// // for {
// // logPlugin(greeter.AgentInfo())
// // time.Sleep(30 * time.Second)
// // }
log.Print("plugin manager started succesfully")
}
// func logPlugin(mp map[string]interface{}) {
// fmt.Printf("\nOs Info:\n")
// for i, v := range mp {
// fmt.Printf("%v: %v\n", i, v)
// }
// }
// // TODO response to Lider
// // func createResponse() {
// // }

View file

@ -0,0 +1,25 @@
package main
// // Load Plugin with plugin name and function name
// func LoadPlugin(plugName, funcName string) {
// plug, err := plugin.Open("../../plugins/resources/main.so")
// if err != nil {
// fmt.Println(err)
// os.Exit(1)
// }
// symGreeter, err := plug.Lookup("Greeter")
// if err != nil {
// fmt.Println(err)
// os.Exit(1)
// }
// var greeter Greeter
// greeter, ok := symGreeter.(Greeter)
// if !ok {
// fmt.Println("unexpected type from module symbol")
// os.Exit(1)
// }
// }
// // NEXT move plugin-manager.go main here !

View file

@ -1,30 +0,0 @@
package main
import (
"ahenk-go/pkg/plugins/resources"
"fmt"
"log"
"time"
)
func PluginManager() {
log.Print("Plugin Manager Started")
for {
logPlugin(resources.AgentInfo())
time.Sleep(30 * time.Second)
}
}
func logPlugin(mp map[string]interface{}) {
fmt.Printf("\nOs Info:\n")
for i, v := range mp {
fmt.Printf("%v: %v\n", i, v)
}
}
// TODO response to Lider
// func createResponse() {
// }

5
debian/changelog vendored Normal file
View file

@ -0,0 +1,5 @@
ahenk-go (0.0.1-1) UNRELEASED; urgency=low
* Initial release
-- Aliberk Sandıı <asandikci@aliberksandikci.com.tr> Mon, 21 Aug 2023 13:05:24 +0000

27
debian/control vendored Normal file
View file

@ -0,0 +1,27 @@
Source: ahenk-go
Maintainer: Aliberk Sandıı <asandikci@aliberksandikci.com.tr>
Uploaders: Aliberk Sandıı <asandikci@aliberksandikci.com.tr>
Section: utils
Testsuite: autopkgtest-pkg-go
Priority: optional
Build-Depends: debhelper-compat (= 13),
dh-golang,
golang-any,
golang-github-sevlyar-go-daemon-dev,
golang-golang-x-exp-dev
Standards-Version: 4.6.0
Vcs-Browser: https://git.aliberksandikci.com.tr/Liderahenk/go-ahenk
Vcs-Git: https://git.aliberksandikci.com.tr/Liderahenk/go-ahenk.git
Homepage: https://liderahenk.org
Rules-Requires-Root: no
XS-Go-Import-Path: git.aliberksandikci.com.tr/Liderahenk/ahenk-go
Package: ahenk-go
Architecture: any
Depends: ${misc:Depends},
${shlibs:Depends}
Built-Using: ${misc:Built-Using}
Description: The client side of the Lider Ahenk Project
Lider Ahenk is an open source project which provides solutions
to manage, monitor and audit unlimited number of different
systems and users on a network.

13
debian/copyright vendored Normal file
View file

@ -0,0 +1,13 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: ahenk-go
Upstream-Contact: Aliberk Sandıı <asandikci@aliberksandikci.com.tr>
Source: https://git.aliberksandikci.com.tr/Liderahenk/ahenk-go
Files: *
Copyright: 2023 Aliberk Sandıı <asandikci@aliberksandikci.com.tr>
License: LGPL-3.0+
Files: debian/*
Copyright: 2023 Aliberk Sandıı <asandikci@aliberksandikci.com.tr>
License: LGPL-3.0+
Comment: Debian packaging is licensed under the same terms as upstream

10
debian/rules vendored Normal file
View file

@ -0,0 +1,10 @@
#!/usr/bin/make -f
%:
dh $@ --builddirectory=_build --buildsystem=golang --with=golang
override_dh_auto_install:
dh_auto_install -- --no-source
# dh_systemd_enable || true
# dh_systemd_start || true
dh_installsystemd

View file

@ -1,10 +1,13 @@
package resources
package main
import (
"ahenk-go/pkg/osinfo"
"fmt"
"runtime"
)
type greeting string
// return instant resource usage information
func ResourceUsage() map[string]string {
data := map[string]string{
@ -27,7 +30,7 @@ func ResourceUsage() map[string]string {
}
// return general Agent information (that changes rarely)
func AgentInfo() map[string]interface{} {
func (g greeting) AgentInfo() map[string]interface{} {
data := map[string]interface{}{
"System": runtime.GOOS, "Release": osinfo.GetKernelInfo()["Release"],
// TODO 'agentVersion': self.get_agent_version(),
@ -67,3 +70,13 @@ func Info() map[string]string {
// inf["machine_oriented"] = "false"
return inf
}
func (g greeting) Greet() {
fmt.Println("Hello Universe")
}
func (g greeting) Myvar() {
fmt.Println("I am here")
}
// this is exported
var Greeter greeting

View file

@ -1,6 +1,11 @@
#!/bin/bash
### Ahenk Agent Local Installation Script
### IMPORTANT NOTICE !
# Consider to use makefile for building or .deb file for installing package,
# using this scripts is not suggested anymore !
### --------------------- ###
### --> Prerequisites
# git