parent
e2275ef05e
commit
b15066b513
|
@ -1,6 +1,8 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"log"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
@ -130,8 +132,6 @@ func readPid(pidFile string) (int, error) {
|
|||
var (
|
||||
file *os.File
|
||||
err error
|
||||
buf []byte
|
||||
n int
|
||||
pid64 int64
|
||||
)
|
||||
|
||||
|
@ -142,18 +142,15 @@ func readPid(pidFile string) (int, error) {
|
|||
_ = file.Close()
|
||||
}()
|
||||
|
||||
buf = make([]byte, 1024)
|
||||
n, err = file.Read(buf)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
scanner := bufio.NewScanner(file)
|
||||
if scanner.Scan() {
|
||||
if pid64, err = strconv.ParseInt(scanner.Text(), 10, 64); err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return int(pid64), nil
|
||||
} else {
|
||||
return 0, errors.New("invalid scanner")
|
||||
}
|
||||
|
||||
pid64, err = strconv.ParseInt(string(buf[:n]), 10, 64)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
return int(pid64), nil
|
||||
}
|
||||
|
||||
func startProcess(arg0 string, args ...string) {
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
FROM suyono/wingmate:alpine as source
|
||||
|
||||
FROM alpine:3.19
|
||||
|
||||
RUN apk update && apk add tzdata openssh-server && \
|
||||
ln -s /usr/share/zoneinfo/Australia/Sydney /etc/localtime && ssh-keygen -A
|
||||
|
||||
COPY --from=source /usr/local/bin/wingmate /usr/local/bin/
|
||||
COPY --from=source /usr/local/bin/wmpidproxy /usr/local/bin/
|
||||
ADD --chmod=755 example/ssh-docker/entry.sh /usr/local/bin/entry.sh
|
||||
ADD --chmod=755 example/ssh-docker/etc /etc
|
||||
|
||||
ENTRYPOINT [ "/usr/local/bin/entry.sh" ]
|
||||
CMD [ "/usr/local/bin/wingmate" ]
|
|
@ -0,0 +1,7 @@
|
|||
#!/bin/sh
|
||||
|
||||
if [ $# -gt 0 ]; then
|
||||
exec "$@"
|
||||
else
|
||||
exec /usr/local/bin/wingmate
|
||||
fi
|
|
@ -0,0 +1,3 @@
|
|||
#!/bin/sh
|
||||
|
||||
exec /usr/local/bin/wmpidproxy --pid-file /var/run/sshd.pid -- /usr/sbin/sshd
|
Loading…
Reference in New Issue