add snap build tools

This commit is contained in:
Boshi Lian 2018-02-22 18:51:45 +08:00
parent 8e411816c1
commit 687a0d78ba
6 changed files with 81 additions and 0 deletions

1
.gitignore vendored
View file

@ -23,3 +23,4 @@ _testmain.go
*.test
*.prof
sshpiperd/example/sshpiperd_key*
snap

4
sshpiperd/snap/build.sh Executable file
View file

@ -0,0 +1,4 @@
#!/bin/bash
snapcraft clean
snapcraft

View file

@ -0,0 +1,23 @@
version: '3'
services:
snap:
image: snapcore/snapcraft
volumes:
- build:/build
- .:/snap
working_dir: /snap
depends_on:
- piper
command:
- "./build.sh"
piper:
build: ../..
volumes:
- build:/build
command:
- "/bin/cp"
- "/go/bin/sshpiperd"
- "/build/sshpiperd"
volumes:
build:

View file

@ -0,0 +1,4 @@
!GlobalState
assets:
build-packages: []
build-snaps: []

26
sshpiperd/snap/snap/hooks/configure vendored Executable file
View file

@ -0,0 +1,26 @@
#!/bin/sh
set -e
bin=$SNAP/sshpiperd
config=$SNAP_DATA/sshpiperd.ini
args=""
for opt in $($bin options); do
v=$(snapctl get $opt)
if [ "$v" != "" ]; then
v=$(eval echo $v)
args="$args --$opt=$v"
# special default
elif [ "$opt" = "workingdir" ]; then
mkdir -p $SNAP_COMMON/workingdir
args="$args --$opt=$SNAP_COMMON/workingdir"
elif [ "$opt" = "auditor-typescriptlogger-outputdir" ]; then
mkdir -p $SNAP_COMMON/typescriptlog
args="$args --$opt=$SNAP_COMMON/typescriptlog"
fi
done
echo ";DO NOT MODIFY, USE snap set sshpiperd key=val, AUTO GENERATED" $(date) > $config
$bin --config /dev/null $args dumpconfig >> $config

View file

@ -0,0 +1,23 @@
name: sshpiperd
version: 0.3
summary: The missing reverse proxy for ssh
description: |
SSH Piper works as a proxy-like ware, and route connections by username, src ip , etc.
grade: devel
confinement: devmode
parts:
sshpiperd:
plugin: dump
source: /build
apps:
sshpiperd:
command: sshpiperd --config $SNAP_DATA/sshpiperd.ini
plugs: [network-bind]
daemon: simple
hooks:
configure:
plugs: []