mirror of
https://github.com/zrepl/zrepl.git
synced 2024-11-24 17:35:01 +01:00
remove scratchpad
This commit is contained in:
parent
4b23648e6e
commit
0517b746a1
1
scratchpad/chunker/.gitignore
vendored
1
scratchpad/chunker/.gitignore
vendored
@ -1 +0,0 @@
|
||||
chunker
|
@ -1,84 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/zrepl/zrepl/sshbytestream"
|
||||
. "github.com/zrepl/zrepl/util"
|
||||
// "bytes"
|
||||
_ "bufio"
|
||||
// "strings"
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
_ "time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
mode := flag.String("mode", "", "incoming|outgoing")
|
||||
incomingFile := flag.String("incoming.file", "", "file to deliver to callers")
|
||||
outgoingHost := flag.String("outgoing.sshHost", "", "ssh host")
|
||||
outgoingUser := flag.String("outgoing.sshUser", "", "ssh user")
|
||||
outgoingIdentity := flag.String("outgoing.sshIdentity", "", "ssh private key")
|
||||
outgoingPort := flag.Uint("outgoing.sshPort", 22, "ssh port")
|
||||
outgoingFile := flag.String("outgoing.File", "", "")
|
||||
flag.Parse()
|
||||
|
||||
switch {
|
||||
case (*mode == "incoming"):
|
||||
|
||||
conn, err := sshbytestream.Incoming()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
file, err := os.Open(*incomingFile)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
chunker := NewChunker(file)
|
||||
|
||||
_, err = io.Copy(conn, &chunker)
|
||||
if err != nil && err != io.EOF {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
log.Printf("Chunk Count: %d\n", chunker.ChunkCount)
|
||||
|
||||
case *mode == "outgoing":
|
||||
|
||||
conn, err := sshbytestream.Outgoing(sshbytestream.SSHTransport{
|
||||
Host: *outgoingHost,
|
||||
User: *outgoingUser,
|
||||
IdentityFile: *outgoingIdentity,
|
||||
Port: uint16(*outgoingPort),
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
f, err := os.OpenFile(*outgoingFile, os.O_CREATE|os.O_WRONLY, 0600)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
unchunker := NewUnchunker(conn)
|
||||
|
||||
_, err = io.Copy(f, unchunker)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
conn.Close()
|
||||
|
||||
log.Printf("Chunk Count: %d\n", unchunker.ChunkCount)
|
||||
|
||||
os.Exit(0)
|
||||
|
||||
default:
|
||||
panic("unsupported mode!")
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
"time"
|
||||
)
|
||||
|
||||
var config struct {
|
||||
duration time.Duration
|
||||
}
|
||||
|
||||
func usage() {
|
||||
log.Printf("usage: repeat repeatInterval command [args...]")
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
args := os.Args
|
||||
|
||||
if len(args) < 3 {
|
||||
usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
repeatInterval, err := time.ParseDuration(args[1])
|
||||
if err != nil {
|
||||
log.Printf("cannot parse interval: %s", err)
|
||||
usage()
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
var lastStart time.Time
|
||||
|
||||
for {
|
||||
cmd := exec.Command(args[2], args[3:]...)
|
||||
cmd.Stdout = os.Stdout
|
||||
cmd.Stderr = os.Stderr
|
||||
lastStart = time.Now()
|
||||
if err := cmd.Run(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
time.Sleep(lastStart.Add(repeatInterval).Sub(time.Now()))
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#!/bin/sh
|
||||
echo -n ' start '
|
||||
date
|
||||
sleep $1
|
||||
echo -n 'done '
|
||||
date
|
Loading…
Reference in New Issue
Block a user