From bed3e755f728872973d3862b27c955e50767fdcc Mon Sep 17 00:00:00 2001 From: Chteufleur Date: Mon, 7 Nov 2016 22:38:49 +0100 Subject: [PATCH] Add packaging instructions and script --- packaging/PACKAGE.md | 40 ++++++++++++++++++++++++++++ packaging/http-auth.service | 9 +++++++ scripts/http-auth.sh | 53 +++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 packaging/PACKAGE.md create mode 100644 packaging/http-auth.service create mode 100644 scripts/http-auth.sh diff --git a/packaging/PACKAGE.md b/packaging/PACKAGE.md new file mode 100644 index 0000000..a8e80de --- /dev/null +++ b/packaging/PACKAGE.md @@ -0,0 +1,40 @@ +# Packaging + +## Build libraries as shared + +In order to packaged the project, you will need to follow those different steps. +We will build libraries as shared libraries. + +The first step is to buid the GO standard library as shared. +``` +$ cd $GOPATH +$ go install -buildmode=shared std +``` + +Next, we will build the 2 libraries to make them shared… +``` +$ cd $GOPATH +$ go install -buildmode=shared -linkshared github.com/jimlawless/cfg +$ go install -buildmode=shared -linkshared git.kingpenguin.tk/chteufleur/go-xmpp.git/src/xmpp +``` + +Then finally, build the project with the option that tell to use libraries as shared and not static. +``` +$ cd $GOPATH +$ go install -linkshared git.kingpenguin.tk/chteufleur/HTTPAuthentificationOverXMPP.git +``` + +You will find shared libraries over here : + * ``$GOROOT/pkg/linux_amd64_dynlink/libstd.so`` + * ``$GOPATH/pkg/linux_amd64_dynlink/libgithub.com-jimlawless-cfg.so`` + * ``$GOPATH/pkg/linux_amd64_dynlink/libgit.kingpenguin.tk-chteufleur-go-xmpp.git-src-xmpp.so`` + +And the binary file here : + * ``$GOPATH/bin/HTTPAuthentificationOverXMPP.git`` + +An example can be found [here](https://github.com/jbuberel/buildmodeshared/tree/master/gofromgo). + +## Configuration + +At the installation, the folder ``$XDG_CONFIG_DIRS/http-auth/`` need to be created (example ``/etc/xdg/http-auth``) where to place the configuration file named ``httpAuth.conf``. + diff --git a/packaging/http-auth.service b/packaging/http-auth.service new file mode 100644 index 0000000..8561f0d --- /dev/null +++ b/packaging/http-auth.service @@ -0,0 +1,9 @@ +[Unit] +Description=Provide an HTTP authentication over XMPP (https://xmpp.org/extensions/xep-0070.html) + +[Service] +ExecStart=/etc/init.d/http-auth.sh start +ExecStop=/etc/init.d/http-auth.sh stop + +[Install] +WantedBy=multi-user.target diff --git a/scripts/http-auth.sh b/scripts/http-auth.sh new file mode 100644 index 0000000..2baf716 --- /dev/null +++ b/scripts/http-auth.sh @@ -0,0 +1,53 @@ +#!/bin/sh + +####################### +name="httpAuth" +dirPath="/usr/local/sbin" +####################### +sh="/bin/bash" +pidPath="/var/run/http-auth/http-auth.pid" +####################### + +do_start() { + nohup $dirPath/$name & + /bin/echo $! > $pidPath +} + +do_stop() { + if [ -e $pidPath ] + then + pid=$(/bin/cat $pidPath) + kill $pid + rm $pidPath + fi +} + +get_status() { + if [ -e $pidPath ] ; then + pid=$(/bin/cat $pidPath) ; + /bin/echo "$name is running with PID $pid" ; + else + /bin/echo "$name is stopped" ; + fi +} + + +case $1 in + start) + do_start + ;; + stop) + do_stop + ;; + restart) + do_stop + do_start + ;; + status) + get_status + ;; + *) + /bin/echo "Usage: $0 {start|stop|restart|status}" + exit 2 + ;; +esac