add deb building script using fpm
This commit is contained in:
parent
020ca59628
commit
f711eb1ae5
3 changed files with 154 additions and 0 deletions
84
sshpiperd/deb/build.sh
Executable file
84
sshpiperd/deb/build.sh
Executable file
|
|
@ -0,0 +1,84 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
BASEDIR=$(dirname $(readlink -f $0))
|
||||
|
||||
DIST_BIN=${1:-$GOPATH/bin/sshpiperd}
|
||||
DIST_BIN=`readlink -f $DIST_BIN`
|
||||
|
||||
if [ ! -x $DIST_BIN ];then
|
||||
echo "can not find sshpiper bin"
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "packing bin:$DIST_BIN"
|
||||
|
||||
VERSION=`$DIST_BIN --version | grep -Po "ver: .*? " | sed "s/ver: *//g" | sed "s/ *$//g"`
|
||||
VERSION=${VERSION#v} ## remove v
|
||||
|
||||
echo "building .deb for ver: $VERSION"
|
||||
|
||||
DIST_DIR=`mktemp -d`
|
||||
|
||||
|
||||
## copy from docker
|
||||
cat > $DIST_DIR/postinst <<'EOF'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
|
||||
update-rc.d sshpiperd defaults > /dev/null || true
|
||||
if [ -n "$2" ]; then
|
||||
_dh_action=restart
|
||||
else
|
||||
_dh_action=start
|
||||
fi
|
||||
service sshpiperd $_dh_action 2>/dev/null || true
|
||||
#DEBHELPER#
|
||||
EOF
|
||||
|
||||
cat > $DIST_DIR/prerm <<'EOF'
|
||||
#!/bin/sh
|
||||
set -e
|
||||
set -u
|
||||
service sshpiperd stop 2>/dev/null || true
|
||||
#DEBHELPER#
|
||||
EOF
|
||||
|
||||
chmod +x $DIST_DIR/postinst $DIST_DIR/prerm
|
||||
|
||||
|
||||
mkdir -p $DIST_DIR/root/var/sshpiper
|
||||
mkdir -p $DIST_DIR/root/etc/
|
||||
mkdir -p $DIST_DIR/root/usr/local/bin
|
||||
|
||||
cp $DIST_BIN $DIST_DIR/root/usr/local/bin
|
||||
cp $BASEDIR/sshpiperd.conf $DIST_DIR/root/etc
|
||||
|
||||
|
||||
NAME=sshpiperd
|
||||
MAINTAINER=tgic
|
||||
CATEGORY=net
|
||||
DESCRIPTION="Username based SSH Reverse Proxy"
|
||||
LICENSE="The MIT License (MIT)"
|
||||
HOMEPAGE="https://github.com/tg123/sshpiper"
|
||||
|
||||
echo $BASEDIR
|
||||
|
||||
fpm -f -s dir -t deb -n "$NAME" -v "$VERSION" \
|
||||
--deb-init $BASEDIR/init.d/sshpiperd \
|
||||
--deb-priority optional \
|
||||
--after-install $DIST_DIR/postinst \
|
||||
--before-remove $DIST_DIR/prerm \
|
||||
--prefix / \
|
||||
--maintainer "$MAINTAINER" \
|
||||
--description "$DESCRIPTION" \
|
||||
--category "$CATEGORY" \
|
||||
--depends libpam0g \
|
||||
--provides sshpiperd \
|
||||
--url "$HOMEPAGE" \
|
||||
--license "$LICENSE" \
|
||||
--config-files /etc/sshpiperd.conf \
|
||||
-C $DIST_DIR/root .
|
||||
|
||||
rm -rf $DIST_DIR
|
||||
47
sshpiperd/deb/init.d/sshpiperd
Normal file
47
sshpiperd/deb/init.d/sshpiperd
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
#! /bin/sh
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: sshpiperd
|
||||
# Required-Start: $remote_fs $syslog
|
||||
# Required-Stop: $remote_fs $syslog
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Username based SSH Reverse Proxy
|
||||
### END INIT INFO
|
||||
|
||||
. /lib/lsb/init-functions
|
||||
|
||||
SSHPIPERD_BIN=/usr/local/bin/sshpiperd
|
||||
SSHPIPERD_PID=/var/run/sshpiperd.pid
|
||||
|
||||
touch $SSHPIPERD_PID
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
log_begin_msg "Starting SSHPiperd"
|
||||
start-stop-daemon --start --background \
|
||||
--exec "$SSHPIPERD_BIN" \
|
||||
--pidfile "$SSHPIPERD_PID" --make-pidfile
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
stop)
|
||||
log_begin_msg "Stopping SSHPiperd"
|
||||
start-stop-daemon --stop --pidfile "$SSHPIPERD_PID"
|
||||
log_end_msg $?
|
||||
;;
|
||||
|
||||
restart)
|
||||
$0 stop
|
||||
$0 start
|
||||
;;
|
||||
|
||||
status)
|
||||
status_of_proc -p "$SSHPIPERD_PID" "$SSHPIPERD_BIN" "SSHPiperd"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
23
sshpiperd/deb/sshpiperd.conf
Normal file
23
sshpiperd/deb/sshpiperd.conf
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
## SSH Piper
|
||||
## Username based SSH Reverse Proxy
|
||||
## see https://github.com/tg123/sshpiper#configuration
|
||||
|
||||
## log path
|
||||
LOG=/var/log/sshpiperd.log
|
||||
|
||||
## Additional challenger name
|
||||
## https://github.com/tg123/sshpiper#additional-challenge
|
||||
#CHALLENGER=pam
|
||||
|
||||
# Server Key file for SSH Piper
|
||||
#SERVER_KEY=/etc/ssh/ssh_host_rsa_key
|
||||
|
||||
## Listening Address
|
||||
#LISTEN_ADDR=0.0.0.0
|
||||
|
||||
## Listening Port
|
||||
#PORT=2222
|
||||
|
||||
## Working Dir
|
||||
## https://github.com/tg123/sshpiper#files-inside-working-dir
|
||||
#WORKING_DIR=/var/sshpiper
|
||||
Loading…
Add table
Add a link
Reference in a new issue