Outils pour utilisateurs

Outils du site


blog

Notes GOGS forge git serveur github like

Voir aussi :

Voir :

wget https://dl.gogs.io/gogs_v0.9.141_linux_amd64.zip
unzip gogs_v0.9.141_linux_amd64.zip
 
cd gogs

Gogs ne fonctionne pas directement avec git-shell

fatal: Could not read from remote repository.
Please make sure you have the correct access rights
# Delete
passwd -d git
 
# Lock
passwd -l git
 
usermod -s /bin/bash git

/etc/ssh/sshd_config

AllowUsers plop git

Match User git
    PasswordAuthentication no
service ssh restart
apt-get install supervisor

/etc/supervisor/conf.d/gogs.conf

[program:gogs]
directory=/home/git/gogs/
command=/home/git/gogs/gogs web
autostart=true
autorestart=true
startsecs=10
stdout_logfile=/var/log/gogs/stdout.log
stdout_logfile_maxbytes=1MB
stdout_logfile_backups=10
stdout_capture_maxbytes=1MB
stderr_logfile=/var/log/gogs/stderr.log
stderr_logfile_maxbytes=1MB
stderr_logfile_backups=10
stderr_capture_maxbytes=1MB
user = git
environment = HOME="/home/git", USER=git"

Pour faire fonctionner SMTP et avoir les notifications par mails :

/home/git/gogs/custom/conf/app.ini

[mailer]
SKIP_VERIFY = true

Sur poste client

Il est possible d'utiliser HTTP(S) ou SSH

Exemple de conf SSH pour utiliser un proxy d'entreprise

~/.ssh/config

Host git.acme.fr
    User git
    Hostname git.acme.fr
    Port 443
    ProxyCommand /usr/bin/corkscrew 192.168.56.1 3128 %h %p

Conf complète app.ini

/home/git/gogs/custom/conf/app.ini

APP_NAME = Gogs: Go Git Service
RUN_USER = git
RUN_MODE = prod
 
[database]
DB_TYPE  = sqlite3
HOST     = 127.0.0.1:3306
NAME     = gogs
USER     = root
PASSWD   = 
SSL_MODE = disable
PATH     = data/gogs.db
 
[repository]
ROOT = /home/git/gogs-repositories
 
[server]
DOMAIN       = git.acme.fr
HTTP_PORT    = 3000
ROOT_URL     = https://git.acme.fr/
DISABLE_SSH  = false
SSH_PORT     = 443
OFFLINE_MODE = true
 
[mailer]
ENABLED = true
HOST    = localhost:25
FROM    = GOGS <git@acme.fr>
USER    = 
PASSWD  = 
SKIP_VERIFY = true
 
[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL     = true
DISABLE_REGISTRATION   = true
ENABLE_CAPTCHA         = false
REQUIRE_SIGNIN_VIEW    = true
 
[picture]
DISABLE_GRAVATAR        = true
ENABLE_FEDERATED_AVATAR = false
 
[session]
PROVIDER = file
 
[log]
MODE      = file
LEVEL     = Info
ROOT_PATH = /home/git/gogs/log
 
[security]
INSTALL_LOCK = true
SECRET_KEY   = JziSLMT87mxkURM
2025/03/24 15:06

AWS Réseau

Note en vrac

aws create-dhcp-options --dhcp-configurations ntp-servers

create-dhcp-options
associate-dhcp-options 
describe-dhcp-options 

ntp-servers


                {
                    "Key": "ntp-servers",
                    "Values": [
                        {
                            "Value": "169.254.169.123"
                        }
                    ]

					
-----
aws ec2 create-dhcp-options --dhcp-configurations Key=domain-name,Values=plop.aws Key=domain-name-servers,Values=AmazonProvidedDNS Key=ntp-servers,Values=10.240.98.16

FIXME

2025/03/24 15:06

Notes go golang

Tuto

Voir tuto Api :

Début du tuto

restapi.go

package main
 
import(
//	"encoding/json"
	"log"
	"net/http"
//	"math/rand"
//	"strconv"
	"github.com/gorilla/mux"
)
 
type Book struct {
	ID string `json:"id"`
	Isbn string `json:"isbn"`
	Title string `json:"title"`
	Author *Author `json:"author"`
}
 
type Author struct {
	Firstname string `json:"fistname"`
	Lastname string `json:"lastname"`
}
 
func getBooks(w http.ResponseWriter, r *http.Request) {
 
}
 
func getBook(w http.ResponseWriter, r *http.Request) {
}
func createBook(w http.ResponseWriter, r *http.Request) {
}
func updateBook(w http.ResponseWriter, r *http.Request) {
}
func deleteBook(w http.ResponseWriter, r *http.Request) {
}
 
func main() {
	r := mux.NewRouter()
 
	r.HandleFunc("/api/books", getBooks).Methods("GET")
	r.HandleFunc("/api/books/{id}", getBook).Methods("GET")
	r.HandleFunc("/api/books", createBook).Methods("POST")
	r.HandleFunc("/api/books/{id}", updateBook).Methods("PUT")
	r.HandleFunc("/api/books/{id}", deleteBook).Methods("DELETE")
 
	log.Fatal(http.ListenAndServe(":8085", r))
}

Install & config

sudo apt-get install -t jessie-backports golang
mkdir -p $HOME/go/bin
#export GOPATH=$HOME/go
 
# go install plop.go
export GOBIN="$HOME/go/bin"
 
export PATH="$PATH:~/.local/bin/"
export GOHOME="$HOME/go"
export GO111MODULE=on
export PATH="$PATH:$HOME/go/bin/"

~/.bashrc

export GOPATH=$HOME/work
export GOBIN=$HOME/work/bin
export PATH=$PATH:$HOME/work/bin

Exemple avec Terraform

Voir aussi OpenTofu

go get -u github.com/hashicorp/terraform

Ce qui revient à :

mkdir -p ~/work/src/github.com/hashicorp/
cd ~/work/src/github.com/hashicorp/
git clone https://github.com/hashicorp/terraform

Puis

cd ~/work/src/github.com/hashicorp/terraform
cat README.md
make updatedeps
make
go install

Dev bonnes pratiques

Compilation

Option de ldflags

go build -ldflags="-help" ./main.go

Language

Types

Lancer des commandes systèmes

Pb voir : http://stackoverflow.com/questions/23723955/how-can-i-pass-a-slice-as-a-variadic-input

exec.go

// http://www.darrencoxall.com/golang/executing-commands-in-go/
 
package main
 
import (
        "fmt"
        "os"
        "os/exec"
        "log"
        //"flag"
        //"strings"
)
 
func main() {
        s := os.Args[1:]
        fmt.Println(s)
        //cmd := exec.Command(s[:])             // Error !
        cmd := exec.Command(s[0], s[1], s[2])
        //out, err := cmd.Output()              // Whithout Stdout
        out, err := cmd.CombinedOutput()        // Whith StdErr
        if err != nil {
                fmt.Println("Error")
                fmt.Printf("%s", out)
                log.Fatal(err)
        }
        fmt.Printf("%s", out)
}
go run exec.go ls /tmp/ /

Tests unitaire

fact.go

package main

func fact(x int) int {
        if (x == 0) || (x == 1) {
                return 1
        }
        return x * fact(x-1)
}

fact_test.go

package main

import "testing"

func TestFact(t *testing.T) {
        if fact(0) != 1 {
                //t.Fail() // Erreur sans message
                t.Error("Err with 0")
        }
        if fact(1) != 1 {
                t.Error("Err with 1")
        }
        if fact(4) != 24 {
                t.Error("Err with 4")
        }
}
go test fact.go fact_test.go
ok      command-line-arguments  0.001s

Outils

Gosh un shell interactif

IDE

Vscode / Codium

LiteIDE X

snap install liteide-tpaw

IntelliJ IDEA

Code qualité
Crosscompil

OS et architectures supportées

go tool dist list
env GOOS=android GOARCH=arm64 go build -o /arm64bins/app

Pour voir la liste des architectures supportée

go tool dist list
Tour
export GO111MODULE=on
export GOPATH=$HOME/code/go
go install golang.org/x/website/tour@latest
go get golang.org/x/website/tour@latest
~/code/go/bin/tour

ou : https://go.dev/tour/welcome/1

Debuger

Jupyter Notebook

Ordiphone / Android / téléphone mobile

2025/03/24 15:06
,

Notes GNUnet

il vous faudra ouvrir les ports 2086 et 1080 en TCP et UDP.

gnunet-config -s nat -o DISABLEV6 -V YES

gnunet-config -c /etc/gnunet.conf -s nat -o DISABLEV6

BEHIND_NAT = YES EXTERNAL_ADDRESS = <ip publique>

Arret gnunet-arm -e

Démarrage serveur su - gnunet gnunet-arm -sm -c /etc/gnunet.conf

Démarrage coté utilisateur gnunet-arm -s

Lister les services démarrés gnunet-arm -I

mv /etc/gnunet.conf /var/lib/gnunet/.config/

ln -s ~/.config/gnunet.conf /etc/gnunet.conf

A faire dans sa session utilisateur

$ gnunet-gns-import
$ gnunet-gns-proxy-setup-ca
Generating CA
Generating a 2048 bit RSA private key
.........+++
....................+++
writing new private key to '/tmp/gnscakeyysBBXu.pem'
-----
Removing passphrase from key
writing RSA key
Importing CA into browsers
Importing CA info Firefox /home/jibe/.mozilla/firefox/uuqgp7im.default
Importing CA into Chrome
You can now start gnunet-gns-proxy and configure your browser to use a SOCKS proxy on port 7777
/etc/nsswitch.conf
hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4
hosts:          files gns [NOTFOUND=return] mdns4_minimal [NOTFOUND=return] dns mdns4
2025/03/24 15:06

Notes GNU screen

Je préfère tmux au bon vieux GNU screen Voir :

Mais tmux n'est pas capable de se connecter en console sur un cable série (RS-232)

Voir draft-console-cable-serie-croise-rs-232

screen /dev/ttyS0

Sauvegarder ses sessions screen

Redimensionner la taille de la fenêtre

Ctrl + a et l ((redisplay) Fully refresh current window.) Corrige la taille de la fenêtre

Autres

screen -RR # recover an old, detached screen, or start a new one.

2025/03/24 15:06
blog.txt · Dernière modification : de 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki